-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlibrary.c
71 lines (49 loc) · 1.84 KB
/
library.c
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
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
63
64
65
66
67
68
69
70
71
/**
* This file implements a global initialization function that is responsible
* for initializing (not setting up) all of the drivers in the library.
*
* Initilization is different from Setup in that setup is performed by a user
* with user configuration, initialization is only configuring the drivers
* (dependency injection, etc...)
*
*
* Authors: Michael Rouse
*/
#include "library.h"
#include <stdio.h>
/**
* Include driver implementations
*/
#define RUN_SPEC_FILE_LIKE_C_FILE
#define LOAD_CUSTOM_DRIVER_CODE
/* Custom driver implementation of the Microcontroller */
#include "microcontroller/loader.h"
/* Custom Driver implementation of the CAN Controller */
#include "can_controller/loader.h"
#include "can/can.driver"
#include "spi/spi.driver"
#include "pin_control/pin_control.driver"
#include "interrupts/interrupts.driver"
#include "utils/utils.driver"
#undef LOAD_CUSTOM_DRIVER_CODE
#undef RUN_SPEC_FILE_LIKE_C_FILE
/**
* This function initializes all the drivers in this library
*
* It will run before the main() function does, so it should NEVER be called
* by the user.
*
* This function MUST be at the end of this file, if it's not you'll dereference NULL pointers out the ass :)
* when the microcontroller initialization tries to access any of the register arrays
*/
#ifndef UNIT_TEST
void __attribute__((constructor(999))) library_initialization(void)
{
/* Setup each driver */
__microcontroller_initialization();
__interrupt_initialization(__microcontroller_interrupts_configure, pin_set_mode);
__can_initialization(can_controller_setup, can_controller_poll, can_controller_transmit);
__spi_initialization(__microcontroller_spi_setup, __microcontroller_spi_transmit);
__can_controller_initialization(spi_transmit, pin_set_mode, pin_set_level, pin_read, interrupt_attach, __can_add_to_receive_queue);
}
#endif