1 #include PLATFORM_HEADER
3 #include "hal/micro/micro-common.h"
6 #include "dev/button-sensor.h"
7 #include "dev/temperature-sensor.h"
8 #include "dev/acc-sensor.h"
17 static uint8_t sensors_status;
19 #define BUTTON_STATUS_ACTIVE (1 << 0)
20 #define TEMP_STATUS_ACTIVE (1 << 1)
21 #define ACC_STATUS_ACTIVE (1 << 2)
27 GPIO_PACFGL = (GPIOCFG_IN <<PA0_CFG_BIT)|
28 (GPIOCFG_IN <<PA1_CFG_BIT)|
29 (GPIOCFG_IN <<PA2_CFG_BIT)|
30 (GPIOCFG_IN <<PA3_CFG_BIT);
31 GPIO_PACFGH = (GPIOCFG_IN <<PA4_CFG_BIT)|
32 (GPIOCFG_IN <<PA5_CFG_BIT)|
33 (GPIOCFG_IN <<PA6_CFG_BIT)|
34 (GPIOCFG_IN <<PA7_CFG_BIT);
35 GPIO_PBCFGL = (GPIOCFG_IN <<PB0_CFG_BIT)|
36 (GPIOCFG_IN <<PB1_CFG_BIT)|
37 (GPIOCFG_IN <<PB2_CFG_BIT)|
38 (GPIOCFG_IN <<PB3_CFG_BIT);
39 GPIO_PBCFGH = (GPIOCFG_IN <<PB4_CFG_BIT)|
40 (GPIOCFG_IN <<PB5_CFG_BIT)|
41 (GPIOCFG_IN <<PB6_CFG_BIT)|
42 (GPIOCFG_IN <<PB7_CFG_BIT);
43 GPIO_PCCFGL = (GPIOCFG_IN <<PC0_CFG_BIT)|
44 (GPIOCFG_IN <<PC1_CFG_BIT)|
45 (GPIOCFG_IN <<PC2_CFG_BIT)|
46 (GPIOCFG_IN <<PC3_CFG_BIT);
47 GPIO_PCCFGH = (GPIOCFG_IN <<PC4_CFG_BIT)|
48 (GPIOCFG_IN <<PC5_CFG_BIT)|
49 (GPIOCFG_IN <<PC6_CFG_BIT)|
50 (GPIOCFG_IN <<PC7_CFG_BIT);
65 if(button_sensor.status(SENSORS_READY)){
66 sensors_status |= BUTTON_STATUS_ACTIVE;
68 if(temperature_sensor.status(SENSORS_READY)){
69 sensors_status |= TEMP_STATUS_ACTIVE;
71 if(acc_sensor.status(SENSORS_READY)){
72 sensors_status |= ACC_STATUS_ACTIVE;
74 SENSORS_DEACTIVATE(acc_sensor);
81 button_sensor.configure(SENSORS_HW_INIT, 0);
82 temperature_sensor.configure(SENSORS_HW_INIT, 0);
83 acc_sensor.configure(SENSORS_HW_INIT, 0);
85 if(sensors_status & BUTTON_STATUS_ACTIVE){
86 SENSORS_ACTIVATE(button_sensor);
88 if(sensors_status & TEMP_STATUS_ACTIVE){
89 SENSORS_ACTIVATE(temperature_sensor);
91 if(sensors_status & ACC_STATUS_ACTIVE){
92 SENSORS_ACTIVATE(acc_sensor);
99 GPIO_PACFGL = (GPIOCFG_IN <<PA0_CFG_BIT)|
100 (GPIOCFG_IN <<PA1_CFG_BIT)|
101 (GPIOCFG_IN <<PA2_CFG_BIT)|
102 (GPIOCFG_IN <<PA3_CFG_BIT);
103 GPIO_PACFGH = (GPIOCFG_IN <<PA4_CFG_BIT)|
104 (GPIOCFG_IN <<PA5_CFG_BIT)|
105 (GPIOCFG_IN <<PA6_CFG_BIT)|
106 (GPIOCFG_IN <<PA7_CFG_BIT);
107 GPIO_PBCFGL = (GPIOCFG_IN <<PB0_CFG_BIT)|
108 (GPIOCFG_OUT_ALT <<PB1_CFG_BIT)|
109 (GPIOCFG_IN <<PB2_CFG_BIT)|
110 (GPIOCFG_IN <<PB3_CFG_BIT);
111 GPIO_PBCFGH = (GPIOCFG_IN <<PB4_CFG_BIT)|
112 (GPIOCFG_IN <<PB5_CFG_BIT)|
113 (GPIOCFG_IN <<PB6_CFG_BIT)|
114 (GPIOCFG_IN <<PB7_CFG_BIT);
115 GPIO_PCCFGL = (GPIOCFG_IN <<PC0_CFG_BIT)|
116 (GPIOCFG_IN <<PC1_CFG_BIT)|
117 (GPIOCFG_IN <<PC2_CFG_BIT)|
118 (GPIOCFG_IN <<PC3_CFG_BIT);
119 GPIO_PCCFGH = (GPIOCFG_IN <<PC4_CFG_BIT)|
120 (GPIOCFG_IN <<PC5_CFG_BIT)|
121 (GPIOCFG_IN <<PC6_CFG_BIT)|
122 (GPIOCFG_IN <<PC7_CFG_BIT);