123
Fork of LG by
Device.c@149:abbf7663d27d, 2016-05-03 (annotated)
- Committer:
- Diletant
- Date:
- Tue May 03 05:12:26 2016 +0000
- Revision:
- 149:abbf7663d27d
- Parent:
- 137:14a0c452cf32
- Child:
- 156:e68ee0bcdcda
Device & ... update. Not final!!!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Diletant | 137:14a0c452cf32 | 1 | #include "Device.h" |
Diletant | 137:14a0c452cf32 | 2 | |
Diletant | 137:14a0c452cf32 | 3 | Device device; |
Diletant | 137:14a0c452cf32 | 4 | HashParam hashParamTable[HASH_PARAM_COUNT]; |
Diletant | 149:abbf7663d27d | 5 | HashFunc hashFuncTable[HASH_FUNC_COUNT]; |
Diletant | 137:14a0c452cf32 | 6 | |
Diletant | 137:14a0c452cf32 | 7 | void InitDevice(void) |
Diletant | 137:14a0c452cf32 | 8 | { |
Diletant | 137:14a0c452cf32 | 9 | //Init system |
Diletant | 137:14a0c452cf32 | 10 | SystemInit1(); // Инициализация контроллера: установка тактовых частот |
Diletant | 137:14a0c452cf32 | 11 | SystemCoreClockUpdate1(); // расчет тактовой частоты процессора перед инициализацией UART - 100MHz |
Diletant | 137:14a0c452cf32 | 12 | |
Diletant | 137:14a0c452cf32 | 13 | //Init timers |
Diletant | 137:14a0c452cf32 | 14 | Init_TIM1(7812); //Timer 1: CCLK / 7812 = 12800.819Hz; Vibro: Timer1/32 = 400.025Hz; |
Diletant | 137:14a0c452cf32 | 15 | Init_TIM2(); //Timer 2: CCLK / 4 / 250 = 100kHz |
Diletant | 137:14a0c452cf32 | 16 | enable_timer1(); |
Diletant | 137:14a0c452cf32 | 17 | enable_timer2(); |
Diletant | 137:14a0c452cf32 | 18 | |
Diletant | 149:abbf7663d27d | 19 | //Load default settings |
Diletant | 149:abbf7663d27d | 20 | InitAllWithDefaults(); |
Diletant | 149:abbf7663d27d | 21 | |
Diletant | 149:abbf7663d27d | 22 | //Load from flash |
Diletant | 149:abbf7663d27d | 23 | FlashReadAll(); |
Diletant | 137:14a0c452cf32 | 24 | |
Diletant | 149:abbf7663d27d | 25 | //Init flash memory |
Diletant | 149:abbf7663d27d | 26 | InitFlash(); |
Diletant | 149:abbf7663d27d | 27 | //Init service port |
Diletant | 149:abbf7663d27d | 28 | InitServicePort(); |
Diletant | 137:14a0c452cf32 | 29 | //Init host commununication port |
Diletant | 137:14a0c452cf32 | 30 | InitHostPort(); |
Diletant | 137:14a0c452cf32 | 31 | //Init host commununication protocol |
Diletant | 137:14a0c452cf32 | 32 | InitHostProtocol(); |
Diletant | 149:abbf7663d27d | 33 | InitSSP(); |
Diletant | 149:abbf7663d27d | 34 | |
Diletant | 149:abbf7663d27d | 35 | //Init light-up and back light unit |
Diletant | 149:abbf7663d27d | 36 | InitLightUp(); |
Diletant | 149:abbf7663d27d | 37 | //Init dither |
Diletant | 149:abbf7663d27d | 38 | InitDither(); |
Diletant | 149:abbf7663d27d | 39 | //Init path length control system |
Diletant | 149:abbf7663d27d | 40 | InitPathLengthControlSystem(); |
Diletant | 149:abbf7663d27d | 41 | } |
Diletant | 149:abbf7663d27d | 42 | |
Diletant | 149:abbf7663d27d | 43 | void StartDevice(void){ |
Diletant | 149:abbf7663d27d | 44 | StartLightUp(); |
Diletant | 149:abbf7663d27d | 45 | StartDither(); |
Diletant | 149:abbf7663d27d | 46 | } |
Diletant | 149:abbf7663d27d | 47 | |
Diletant | 149:abbf7663d27d | 48 | void InitAllWithDefaults(void){ |
Diletant | 149:abbf7663d27d | 49 | device.settings.address = 0; |
Diletant | 149:abbf7663d27d | 50 | device.settings.uart.startupBaudRate = 38400; |
Diletant | 149:abbf7663d27d | 51 | |
Diletant | 149:abbf7663d27d | 52 | InitFlashWithDefaults(); |
Diletant | 149:abbf7663d27d | 53 | InitServicePortWithDefaults(); |
Diletant | 149:abbf7663d27d | 54 | InitHostPortWithDefaults(); |
Diletant | 149:abbf7663d27d | 55 | InitHostProtocolWithDefaults(); |
Diletant | 149:abbf7663d27d | 56 | InitLightUpWithDefaults(); |
Diletant | 149:abbf7663d27d | 57 | InitSSPWithDefaults(); |
Diletant | 149:abbf7663d27d | 58 | InitDitherWithDefaults(); |
Diletant | 149:abbf7663d27d | 59 | InitPathLengthControlSystemWithDefaults(); |
Diletant | 149:abbf7663d27d | 60 | } |
Diletant | 149:abbf7663d27d | 61 | /* |
Diletant | 149:abbf7663d27d | 62 | int32_t FindByHash(uint32_t hash){ |
Diletant | 149:abbf7663d27d | 63 | for (uint32_t i = 0; i < HASH_PARAM_COUNT; i++){ |
Diletant | 149:abbf7663d27d | 64 | if (hashParamTable[i].hash == hash) return i; |
Diletant | 149:abbf7663d27d | 65 | } |
Diletant | 149:abbf7663d27d | 66 | return -1; |
Diletant | 149:abbf7663d27d | 67 | } |
Diletant | 149:abbf7663d27d | 68 | */ |