Split sintables into separate source/header files so it actually compiles

aprs_dev
Richard Meadows 2015-04-01 10:34:38 +01:00
rodzic 746a1d278e
commit 46bd5f255f
3 zmienionych plików z 149 dodań i 73 usunięć

Wyświetl plik

@ -6,62 +6,26 @@
#define AX25_SINTABLE_H
#define AX25_SINTABLE_ORDER 8
#define AX25_SINTABLE_LENGTH 256
#include "samd20.h"
#define AX25_SINTABLE_ORDER 9
#define AX25_SINTABLE_LENGTH 512
/**
* 1st quadrant sin lookup table for 1.6kHz deviation
* 1st quadrant sin lookup table for 1.5kHz deviation
*
* Length: 256
* Length: 512
* Frequency Resolution: 7.805 Hz
*/
uint16_t sintable_256_1600hz[] = {
0, 1, 3, 4, 5, 6, 8, 9, 10, 11, 13, 14, 15, 16, 18,
19, 20, 21, 23, 24, 25, 26, 28, 29, 30, 31, 33, 34, 35, 36,
38, 39, 40, 41, 42, 44, 45, 46, 47, 49, 50, 51, 52, 53, 55,
56, 57, 58, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 73,
74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90,
91, 92, 93, 94, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
138, 139, 140, 140, 141, 142, 143, 144, 145, 146, 147, 148, 148, 149, 150,
151, 152, 153, 154, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 162,
163, 164, 165, 165, 166, 167, 168, 168, 169, 170, 170, 171, 172, 173, 173,
174, 175, 175, 176, 176, 177, 178, 178, 179, 180, 180, 181, 181, 182, 183,
183, 184, 184, 185, 185, 186, 186, 187, 187, 188, 188, 189, 189, 190, 190,
191, 191, 192, 192, 193, 193, 193, 194, 194, 195, 195, 195, 196, 196, 197,
197, 197, 198, 198, 198, 199, 199, 199, 199, 200, 200, 200, 201, 201, 201,
201, 202, 202, 202, 202, 202, 203, 203, 203, 203, 203, 203, 204, 204, 204,
204, 204, 204, 204, 204, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205,
205
};
uint16_t sintable_512_1500hz[512];
/**
* 1st quadrant sin lookup table for 2.5kHz deviation
*
* Length: 256
* Length: 512
* Frequency Resolution: 7.805 Hz
*/
uint16_t sintable_256_2500hz[] = {
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 27,
29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57,
59, 61, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 85,
87, 89, 91, 93, 95, 97, 99, 100, 102, 104, 106, 108, 110, 112, 113,
115, 117, 119, 121, 123, 124, 126, 128, 130, 132, 133, 135, 137, 139, 140,
142, 144, 146, 148, 149, 151, 153, 154, 156, 158, 160, 161, 163, 165, 166,
168, 170, 171, 173, 175, 176, 178, 180, 181, 183, 184, 186, 188, 189, 191,
192, 194, 196, 197, 199, 200, 202, 203, 205, 206, 208, 209, 211, 212, 214,
215, 217, 218, 219, 221, 222, 224, 225, 226, 228, 229, 231, 232, 233, 235,
236, 237, 239, 240, 241, 243, 244, 245, 246, 248, 249, 250, 251, 253, 254,
255, 256, 257, 258, 260, 261, 262, 263, 264, 265, 266, 267, 268, 270, 271,
272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 282, 283, 284, 285,
286, 287, 288, 289, 290, 290, 291, 292, 293, 294, 294, 295, 296, 297, 297,
298, 299, 300, 300, 301, 302, 302, 303, 304, 304, 305, 305, 306, 307, 307,
308, 308, 309, 309, 310, 310, 311, 311, 312, 312, 313, 313, 313, 314, 314,
315, 315, 315, 316, 316, 316, 317, 317, 317, 317, 318, 318, 318, 318, 319,
319, 319, 319, 319, 319, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320,
320
};
uint16_t sintable_512_2500hz[512];
#endif /* AX25_SINTABLE_H */

Wyświetl plik

@ -0,0 +1,94 @@
/**
* Autogenerated sine tables. See tools/ax25_lookup/ax25_lookup.py
*/
#include "samd20.h"
/**
* 1st quadrant sin lookup table for 1.5kHz deviation
*
* Length: 512
* Frequency Resolution: 7.805 Hz
*/
uint16_t sintable_512_1500hz[] = {
0, 1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 8, 8,
9, 9, 10, 11, 11, 12, 12, 13, 14, 14, 15, 15, 16, 16, 17,
18, 18, 19, 19, 20, 21, 21, 22, 22, 23, 24, 24, 25, 25, 26,
26, 27, 28, 28, 29, 29, 30, 31, 31, 32, 32, 33, 33, 34, 35,
35, 36, 36, 37, 37, 38, 39, 39, 40, 40, 41, 42, 42, 43, 43,
44, 44, 45, 46, 46, 47, 47, 48, 48, 49, 50, 50, 51, 51, 52,
52, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 59, 59, 60, 60,
61, 61, 62, 63, 63, 64, 64, 65, 65, 66, 66, 67, 68, 68, 69,
69, 70, 70, 71, 71, 72, 72, 73, 74, 74, 75, 75, 76, 76, 77,
77, 78, 78, 79, 79, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85,
85, 86, 86, 87, 87, 88, 89, 89, 90, 90, 91, 91, 92, 92, 93,
93, 94, 94, 95, 95, 96, 96, 97, 97, 98, 98, 99, 99, 100, 100,
101, 101, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108,
108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 114, 115,
115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 121, 122,
122, 123, 123, 124, 124, 125, 125, 126, 126, 126, 127, 127, 128, 128, 129,
129, 129, 130, 130, 131, 131, 132, 132, 133, 133, 133, 134, 134, 135, 135,
135, 136, 136, 137, 137, 138, 138, 138, 139, 139, 140, 140, 140, 141, 141,
142, 142, 142, 143, 143, 144, 144, 144, 145, 145, 146, 146, 146, 147, 147,
147, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 152, 152, 152, 153,
153, 153, 154, 154, 154, 155, 155, 155, 156, 156, 156, 157, 157, 157, 158,
158, 158, 159, 159, 159, 160, 160, 160, 161, 161, 161, 162, 162, 162, 163,
163, 163, 164, 164, 164, 165, 165, 165, 165, 166, 166, 166, 167, 167, 167,
167, 168, 168, 168, 169, 169, 169, 169, 170, 170, 170, 171, 171, 171, 171,
172, 172, 172, 172, 173, 173, 173, 173, 174, 174, 174, 174, 175, 175, 175,
175, 176, 176, 176, 176, 177, 177, 177, 177, 178, 178, 178, 178, 178, 179,
179, 179, 179, 180, 180, 180, 180, 180, 181, 181, 181, 181, 181, 182, 182,
182, 182, 182, 182, 183, 183, 183, 183, 183, 184, 184, 184, 184, 184, 184,
185, 185, 185, 185, 185, 185, 186, 186, 186, 186, 186, 186, 186, 187, 187,
187, 187, 187, 187, 187, 188, 188, 188, 188, 188, 188, 188, 188, 188, 189,
189, 189, 189, 189, 189, 189, 189, 189, 190, 190, 190, 190, 190, 190, 190,
190, 190, 190, 190, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
191, 191, 191, 191, 191, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
192, 192
};
/**
* 1st quadrant sin lookup table for 2.5kHz deviation
*
* Length: 512
* Frequency Resolution: 7.805 Hz
*/
uint16_t sintable_512_2500hz[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
59, 60, 61, 62, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 84, 85, 86,
87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 113, 114,
115, 116, 117, 118, 119, 120, 121, 122, 123, 123, 124, 125, 126, 127, 128,
129, 130, 131, 132, 132, 133, 134, 135, 136, 137, 138, 139, 140, 140, 141,
142, 143, 144, 145, 146, 147, 148, 148, 149, 150, 151, 152, 153, 154, 154,
155, 156, 157, 158, 159, 160, 160, 161, 162, 163, 164, 165, 166, 166, 167,
168, 169, 170, 171, 171, 172, 173, 174, 175, 175, 176, 177, 178, 179, 180,
180, 181, 182, 183, 184, 184, 185, 186, 187, 188, 188, 189, 190, 191, 192,
192, 193, 194, 195, 196, 196, 197, 198, 199, 199, 200, 201, 202, 202, 203,
204, 205, 205, 206, 207, 208, 208, 209, 210, 211, 211, 212, 213, 214, 214,
215, 216, 217, 217, 218, 219, 219, 220, 221, 222, 222, 223, 224, 224, 225,
226, 226, 227, 228, 229, 229, 230, 231, 231, 232, 233, 233, 234, 235, 235,
236, 237, 237, 238, 239, 239, 240, 241, 241, 242, 243, 243, 244, 244, 245,
246, 246, 247, 248, 248, 249, 249, 250, 251, 251, 252, 253, 253, 254, 254,
255, 255, 256, 257, 257, 258, 258, 259, 260, 260, 261, 261, 262, 262, 263,
264, 264, 265, 265, 266, 266, 267, 267, 268, 268, 269, 270, 270, 271, 271,
272, 272, 273, 273, 274, 274, 275, 275, 276, 276, 277, 277, 278, 278, 279,
279, 280, 280, 281, 281, 282, 282, 282, 283, 283, 284, 284, 285, 285, 286,
286, 287, 287, 287, 288, 288, 289, 289, 290, 290, 290, 291, 291, 292, 292,
292, 293, 293, 294, 294, 294, 295, 295, 296, 296, 296, 297, 297, 297, 298,
298, 298, 299, 299, 300, 300, 300, 301, 301, 301, 302, 302, 302, 303, 303,
303, 304, 304, 304, 304, 305, 305, 305, 306, 306, 306, 307, 307, 307, 307,
308, 308, 308, 308, 309, 309, 309, 309, 310, 310, 310, 310, 311, 311, 311,
311, 312, 312, 312, 312, 313, 313, 313, 313, 313, 314, 314, 314, 314, 314,
315, 315, 315, 315, 315, 315, 316, 316, 316, 316, 316, 316, 317, 317, 317,
317, 317, 317, 317, 318, 318, 318, 318, 318, 318, 318, 318, 318, 319, 319,
319, 319, 319, 319, 319, 319, 319, 319, 319, 319, 320, 320, 320, 320, 320,
320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320,
320, 320
};

Wyświetl plik

@ -3,11 +3,15 @@
import numpy as np
import math
length = 256
deviation_f = 2500
length = 512
def file_header(f):
print >>f, "/**"
print >>f, " * Autogenerated sine tables. See tools/ax25_lookup/ax25_lookup.py"
print >>f, " */"
print >>f, ""
def print_sintable(deviation_f):
def print_sintable(f, deviation_f, defonly):
f_resolution = 7.805347443
deviation = (deviation_f/f_resolution)
@ -28,35 +32,49 @@ def print_sintable(deviation_f):
lines = [string[x:x+line_len].rstrip() for x in range(0, len(string), line_len)]
string = "\n ".join(lines)
print "/**"
print " * 1st quadrant sin lookup table for {0:0.1f}kHz deviation".format(deviation_f/1000.0)
print " *"
print " * Length: {0}".format(length)
print " * Frequency Resolution: {0:0.3f} Hz".format(f_resolution)
print " */"
print "uint16_t sintable_{0}_{1}hz[] = {{".format(length, deviation_f)
print " "+string
print "};"
print
print >>f, "/**"
print >>f, " * 1st quadrant sin lookup table for {0:0.1f}kHz deviation".format(deviation_f/1000.0)
print >>f, " *"
print >>f, " * Length: {0}".format(length)
print >>f, " * Frequency Resolution: {0:0.3f} Hz".format(f_resolution)
print >>f, " */"
if defonly:
print >>f, "uint16_t sintable_{0}_{1}hz[{0}];".format(length, deviation_f)
else:
print >>f, "uint16_t sintable_{0}_{1}hz[] = {{".format(length, deviation_f)
print >>f, " "+string
print >>f, "};"
print >>f, ""
print "/**"
print " * Autogenerated sine tables. See tools/ax25_lookup/ax25_lookup.py"
print " */"
print
source = open('src/ax25_sintable.c','w')
header = open('inc/ax25_sintable.h','w')
print "#ifndef AX25_SINTABLE_H"
print "#define AX25_SINTABLE_H"
print
print
file_header(source)
file_header(header)
print "#define AX25_SINTABLE_ORDER {0:d}".format(int(math.log(length, 2)))
print "#define AX25_SINTABLE_LENGTH {0:d}".format(length)
print
print
print >>source, "#include \"samd20.h\""
print >>source, ""
print_sintable(1600)
print_sintable(2500)
print_sintable(source, 1500, False)
print_sintable(source, 2500, False)
print "#endif /* AX25_SINTABLE_H */"
print >>header, "#ifndef AX25_SINTABLE_H"
print >>header, "#define AX25_SINTABLE_H"
print >>header, ""
print >>header, ""
print >>header, "#include \"samd20.h\""
print >>header, ""
print >>header, "#define AX25_SINTABLE_ORDER {0:d}".format(int(math.log(length, 2)))
print >>header, "#define AX25_SINTABLE_LENGTH {0:d}".format(length)
print >>header, ""
print >>header, ""
print_sintable(header, 1500, True)
print_sintable(header, 2500, True)
print >>header, "#endif /* AX25_SINTABLE_H */"