SRD Standelone programmation box: main.c File Reference

| SRD Standelone programmation box 2.0 (16/11/15 10:00:00) Documentation of the SRD standelone programmation box

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Enumerations Enumerator Macros Pages
Functions
main.c File Reference

main. More...

`#include "device.h"`
`#include "watchdog.h"`
`#include "tick.h"`
`#include "uart0.h"`
`#include "UsbUart.h"`
`#include "uart2.h"`
`#include "spi0.h"`
`#include "FM25V20.h"`
`#include "led.h"`
`#include "button.h"`
`#include "display.h"`
`#include "rtc.h"`
`#include "BQ27510DRZRG2.h"`
`#include "FM25V20MemTest.h"`
`#include "LTC4160.h"`
`#include "StringTools.h"`
`#include "PowerManager.h"`
`#include "ButtonManager.h"`
`#include "UsbManager.h"`
`#include "RFIDManager.h"`
Include dependency graph for main.c:

Go to the source code of this file.

## Functions

void | CriticalInit (void)
| Function used to initialize some critical peripheral. More...
void | Setup (void)
| Function used to initialize all non critical peripheral. More...
void | StartScheduling (void)
| Function used to start scheduling operations. More...
void | taskBackground (void)
| Function used to deal background task. More...
void | taskSchedulerOverrun (void)
| Function used to deal task overrun. More...
void | main (void)
| Main function. More...
void | task10ms (void)
| Periodic tasks. More...
void | task100ms (void)
| Periodic tasks. More...
void | task1s (void)
| Periodic tasks. More...
void | task1min (void)
| Periodic tasks. More...

## Detailed Description

main.

Author
  Thibaut LALUQUE 3D-Ouest

Date
  26/09/2014

Version
  1.0

All Right Reserved.

Definition in file main.c.

## Function Documentation

void CriticalInit | ( | void |  | ) |

Function used to initialize some critical peripheral.

Initialize the watchdog, the processor clock and the RTC.

Definition at line 196 of file main.c.

References DeviceClockSwitchHighPower(), DeviceInit(), RtcInit(), WATCHDOG_PERIOD_MIDDLE, WATCHDOG_SOURCE_CLOCK_LPO, WatchdogKick(), and WatchdogStart().

Referenced by main().

196 {
197
198 /*=== Critical device init ===*/
199 DeviceInit();
200
201 /*=== Watchdog init ===*/
202 WatchdogKick();
203 WatchdogStart(WATCHDOG_SOURCE_CLOCK_LPO, WATCHDOG_PERIOD_MIDDLE);
204 //WatchdogStop();
205 DeviceClockSwitchHighPower();
206 WatchdogKick();
207
208 /*=== Init RTC ===*/
209 RtcInit();
210 //RtcSetTime(0);
211 WatchdogKick();
212
213 }
WatchdogStart
void WatchdogStart(tWatchdogSourceClock clockSource, tWatchdogPeriod period)
start watchdog (can be call only ones and can't call after WatchdogStop()).
Definition: watchdog.c:78
WatchdogKick
void WatchdogKick(void)
Kick the watchdog to avoid reset after the watchdog have started.
Definition: watchdog.c:86
WATCHDOG_SOURCE_CLOCK_LPO
Definition: watchdog.h:46
WATCHDOG_PERIOD_MIDDLE
Definition: watchdog.h:58
DeviceClockSwitchHighPower
void DeviceClockSwitchHighPower(void)
Function to switch the processor on the highest clock speed allowed.
Definition: device.c:148
DeviceInit
void DeviceInit(void)
Function to initialize the device clock.
Definition: device.c:78
RtcInit
void RtcInit(void)
Function used to initialized the RTC module.
Definition: rtc.c:78

Here is the call graph for this function:

Here is the caller graph for this function:

void main | ( | void |  | ) |

Main function.

This is the entry point of the program.

Definition at line 149 of file main.c.

References tTickCtrl::bits, CriticalInit(), tTickCtrl::flags, Setup(), StartScheduling(), task100ms(), task10ms(), task1min(), task1s(), taskBackground(), taskSchedulerOverrun(), TickCtrl, and WatchdogKick().

149 {
150
151 CriticalInit();
152
153 Setup();
154
155 StartScheduling();
156
157 while(1) {
158
159 WatchdogKick();
160
161 if(TickCtrl.flags.bits.flag10ms) {
162 task10ms();
163 TickCtrl.flags.bits.flag10ms = 0;
164 }
165
166 if(TickCtrl.flags.bits.flag100ms) {
167 task100ms();
168 TickCtrl.flags.bits.flag100ms = 0;
169 }
170
171 if(TickCtrl.flags.bits.flag1s) {
172 task1s();
173 TickCtrl.flags.bits.flag1s = 0;
174 }
175
176 if(TickCtrl.flags.bits.flag1min) {
177 task1min();
178 TickCtrl.flags.bits.flag1min = 0;
179 }
180
181 if(TickCtrl.flags.bits.overrun) {
182 taskSchedulerOverrun();
183 TickCtrl.flags.bits.overrun = 0;
184
185 #ifdef SCHEDULER_OVERRUN_XOR_BACKGROUND
186 } else {
187 #else
188 }{
189 #endif
190 taskBackground();
191 }
192 }
193 }
task1s
void task1s(void)
Periodic tasks.
Definition: main.c:268
task1min
void task1min(void)
Periodic tasks.
Definition: main.c:272
WatchdogKick
void WatchdogKick(void)
Kick the watchdog to avoid reset after the watchdog have started.
Definition: watchdog.c:86
tTickCtrl::flags
union tTickCtrl::@19 flags
tTickCtrl::bits
struct tTickCtrl::@19::@20 bits
taskSchedulerOverrun
void taskSchedulerOverrun(void)
Function used to deal task overrun.
Definition: main.c:287
task100ms
void task100ms(void)
Periodic tasks.
Definition: main.c:264
Setup
void Setup(void)
Function used to initialize all non critical peripheral.
Definition: main.c:215
taskBackground
void taskBackground(void)
Function used to deal background task.
Definition: main.c:276
TickCtrl
tTickCtrl TickCtrl
Tick control variable.
Definition: tick.c:60
CriticalInit
void CriticalInit(void)
Function used to initialize some critical peripheral.
Definition: main.c:196
StartScheduling
void StartScheduling(void)
Function used to start scheduling operations.
Definition: main.c:253
task10ms
void task10ms(void)
Periodic tasks.
Definition: main.c:260

Here is the call graph for this function:

void Setup | ( | void |  | ) |

Function used to initialize all non critical peripheral.

All non critical peripheral are initialized by this function as the UART modules, I2C module, GPIO,...

Definition at line 215 of file main.c.

References ButtonManagerInit(), DISPLAY_POWER_OFF, DisplayInit(), DisplaySetPower(), LedInit(), MemoryManagerInit(), PowerManagerInit(), RFIDManagerInit(), TickInit(), UART1EnableReceiver, UsbUartInit, and WatchdogKick().

Referenced by main().

215 {
216
217 /*=== Init Power manager ===*/
218 PowerManagerInit();
219 WatchdogKick();
220
221 /*=== Led init ===*/
222 LedInit();
223 WatchdogKick();
224
225 /*=== Switch init ===*/
226 ButtonManagerInit();
227 WatchdogKick();
228
229 /*=== Init USB UART ===*/
230 UsbUartInit();
231 UART1EnableReceiver();
232 WatchdogKick();
233
234 /*=== CR95 Init ===*/
235 RFIDManagerInit();
236
237 /*=== Tick init ===*/
238 TickInit();
239 WatchdogKick();
240
241 /*=== Display Init ===*/
242 DisplayInit();
243 DisplaySetPower(DISPLAY_POWER_OFF);
244 WatchdogKick();
245
246 /*=== Memory manager init ===*/
247 MemoryManagerInit();
248 WatchdogKick();
249
250 }
DISPLAY_POWER_OFF
Definition: display.h:117
UsbUartInit
#define UsbUartInit()
Map the USB/UART functions on the rigth uart module functions.
Definition: UsbUart.h:78
PowerManagerInit
void PowerManagerInit(void)
Variable used by the power manager.
Definition: PowerManager.c:88
WatchdogKick
void WatchdogKick(void)
Kick the watchdog to avoid reset after the watchdog have started.
Definition: watchdog.c:86
ButtonManagerInit
void ButtonManagerInit(void)
Function used to initialize the button manager.
Definition: ButtonManager.c:342
MemoryManagerInit
void MemoryManagerInit(void)
function use to initialize the memory manager.
Definition: MemoryManager.c:73
RFIDManagerInit
void RFIDManagerInit(void)
Function used to initialize the RFID manager.
Definition: RFIDManager.c:79
UART1EnableReceiver
#define UART1EnableReceiver()
Enable / Disable receiver and its interrupt.
Definition: uart1.h:209
DisplaySetPower
void DisplaySetPower(tDisplayPowerState power)
Function used to enable/disable the display power.
Definition: display.c:204
LedInit
void LedInit(void)
Function used to initialize the leds.
Definition: led.c:78
DisplayInit
void DisplayInit(void)
Function used to initialized the display.
Definition: display.c:71
TickInit
void TickInit(void)
Function used to initialize the Tick module .
Definition: tick.c:123

Here is the call graph for this function:

Here is the caller graph for this function:

void StartScheduling | ( | void |  | ) |

Function used to start scheduling operations.

!! peut etre actif que lorsque connecté

Definition at line 253 of file main.c.

References TickEnable, and UsbUartEnableReceiver.

Referenced by main().

253 {
254
255 TickEnable();
256 UsbUartEnableReceiver(); //!!! peut etre actif que lorsque connecté
257
258 }
UsbUartEnableReceiver
#define UsbUartEnableReceiver()
Map the USB/UART functions on the rigth uart module functions.
Definition: UsbUart.h:83
TickEnable
#define TickEnable()
Macro used to enable or disable the tick.
Definition: tick.h:145

Here is the caller graph for this function:

void task100ms | ( | void |  | ) |

Periodic tasks.

Definition at line 264 of file main.c.

Referenced by main().

264 {
265
266 }

Here is the caller graph for this function:

void task10ms | ( | void |  | ) |

Periodic tasks.

Definition at line 260 of file main.c.

Referenced by main().

260 {
261
262 }

Here is the caller graph for this function:

void task1min | ( | void |  | ) |

Periodic tasks.

Definition at line 272 of file main.c.

Referenced by main().

272 {
273
274 }

Here is the caller graph for this function:

void task1s | ( | void |  | ) |

Periodic tasks.

Definition at line 268 of file main.c.

References PowerManager().

Referenced by main().

268 {
269 PowerManager();
270 }
PowerManager
void PowerManager(void)
power manager.
Definition: PowerManager.c:104

Here is the call graph for this function:

Here is the caller graph for this function:

void taskBackground | ( | void |  | ) |

Function used to deal background task.

Definition at line 276 of file main.c.

References ButtonManager(), PowerManagerLPMController(), RFIDManager(), and UsbManager().

Referenced by main().

276 {
277
278 UsbManager();
279
280 ButtonManager();
281
282 RFIDManager();
283
284 PowerManagerLPMController();
285 }
RFIDManager
void RFIDManager(void)
RFID manager.
Definition: RFIDManager.c:93
UsbManager
void UsbManager(void)
USB manager.
Definition: UsbManager.c:83
ButtonManager
void ButtonManager(void)
Button manager function.
Definition: ButtonManager.c:354
PowerManagerLPMController
void PowerManagerLPMController(void)
Low Power mode controller.
Definition: PowerManager.c:332

Here is the call graph for this function:

Here is the caller graph for this function:

void taskSchedulerOverrun | ( | void |  | ) |

Function used to deal task overrun.

Definition at line 287 of file main.c.

Referenced by main().

287 {
288
289 }

Here is the caller graph for this function: