Contiki 2.6
|
00001 #include PLATFORM_HEADER 00002 #include BOARD_HEADER 00003 #include "hal/micro/micro-common.h" 00004 #include "hal/micro/cortexm3/micro-common.h" 00005 00006 #include "dev/button-sensor.h" 00007 #include "dev/temperature-sensor.h" 00008 #include "dev/acc-sensor.h" 00009 #include "dev/leds.h" 00010 00011 void halBoardInit(void) 00012 { 00013 00014 return; 00015 } 00016 00017 static uint8_t sensors_status; 00018 00019 #define BUTTON_STATUS_ACTIVE (1 << 0) 00020 #define TEMP_STATUS_ACTIVE (1 << 1) 00021 #define ACC_STATUS_ACTIVE (1 << 2) 00022 00023 00024 void halBoardPowerDown(void) 00025 { 00026 /* Set everything to input value except LEDs */ 00027 GPIO_PACFGL = (GPIOCFG_IN <<PA0_CFG_BIT)| 00028 (GPIOCFG_IN <<PA1_CFG_BIT)| 00029 (GPIOCFG_IN <<PA2_CFG_BIT)| 00030 (GPIOCFG_IN <<PA3_CFG_BIT); 00031 GPIO_PACFGH = (GPIOCFG_IN <<PA4_CFG_BIT)| /* PTI EN */ 00032 (GPIOCFG_IN <<PA5_CFG_BIT)| /* PTI_DATA */ 00033 (GPIOCFG_IN <<PA6_CFG_BIT)| 00034 (GPIOCFG_IN <<PA7_CFG_BIT); 00035 GPIO_PBCFGL = (GPIOCFG_IN <<PB0_CFG_BIT)| 00036 (GPIOCFG_IN <<PB1_CFG_BIT)| /* Uart TX */ 00037 (GPIOCFG_IN <<PB2_CFG_BIT)| /* Uart RX */ 00038 (GPIOCFG_IN <<PB3_CFG_BIT); 00039 GPIO_PBCFGH = (GPIOCFG_IN <<PB4_CFG_BIT)| 00040 (GPIOCFG_IN <<PB5_CFG_BIT)| 00041 (GPIOCFG_IN <<PB6_CFG_BIT)| 00042 (GPIOCFG_IN <<PB7_CFG_BIT); 00043 GPIO_PCCFGL = (GPIOCFG_IN <<PC0_CFG_BIT)| 00044 (GPIOCFG_IN <<PC1_CFG_BIT)| 00045 (GPIOCFG_IN <<PC2_CFG_BIT)| 00046 (GPIOCFG_IN <<PC3_CFG_BIT); 00047 GPIO_PCCFGH = (GPIOCFG_IN <<PC4_CFG_BIT)| 00048 (GPIOCFG_IN <<PC5_CFG_BIT)| 00049 (GPIOCFG_IN <<PC6_CFG_BIT)| /* OSC32K */ 00050 (GPIOCFG_IN <<PC7_CFG_BIT); /* OSC32K */ 00051 00052 leds_init(); 00053 00054 } 00055 00056 /* Remember state of sensors (if active or not), in order to 00057 * resume their original state after calling powerUpSensors(). 00058 * Useful when entering in sleep mode, since all system 00059 * peripherals have to be reinitialized. */ 00060 00061 void sensorsPowerDown(){ 00062 00063 sensors_status = 0; 00064 00065 if(button_sensor.status(SENSORS_READY)){ 00066 sensors_status |= BUTTON_STATUS_ACTIVE; 00067 } 00068 if(temperature_sensor.status(SENSORS_READY)){ 00069 sensors_status |= TEMP_STATUS_ACTIVE; 00070 } 00071 if(acc_sensor.status(SENSORS_READY)){ 00072 sensors_status |= ACC_STATUS_ACTIVE; 00073 // Power down accelerometer to save power 00074 SENSORS_DEACTIVATE(acc_sensor); 00075 } 00076 } 00077 00078 /**/ 00079 void sensorsPowerUp(){ 00080 00081 button_sensor.configure(SENSORS_HW_INIT, 0); 00082 temperature_sensor.configure(SENSORS_HW_INIT, 0); 00083 acc_sensor.configure(SENSORS_HW_INIT, 0); 00084 00085 if(sensors_status & BUTTON_STATUS_ACTIVE){ 00086 SENSORS_ACTIVATE(button_sensor); 00087 } 00088 if(sensors_status & TEMP_STATUS_ACTIVE){ 00089 SENSORS_ACTIVATE(temperature_sensor); 00090 } 00091 if(sensors_status & ACC_STATUS_ACTIVE){ 00092 SENSORS_ACTIVATE(acc_sensor); 00093 } 00094 } 00095 00096 void halBoardPowerUp(void) 00097 { 00098 /* Set everything to input value */ 00099 GPIO_PACFGL = (GPIOCFG_IN <<PA0_CFG_BIT)| 00100 (GPIOCFG_IN <<PA1_CFG_BIT)| 00101 (GPIOCFG_IN <<PA2_CFG_BIT)| 00102 (GPIOCFG_IN <<PA3_CFG_BIT); 00103 GPIO_PACFGH = (GPIOCFG_IN <<PA4_CFG_BIT)| /* PTI EN */ 00104 (GPIOCFG_IN <<PA5_CFG_BIT)| /* PTI_DATA */ 00105 (GPIOCFG_IN <<PA6_CFG_BIT)| 00106 (GPIOCFG_IN <<PA7_CFG_BIT); 00107 GPIO_PBCFGL = (GPIOCFG_IN <<PB0_CFG_BIT)| 00108 (GPIOCFG_OUT_ALT <<PB1_CFG_BIT)| /* Uart TX */ 00109 (GPIOCFG_IN <<PB2_CFG_BIT)| /* Uart RX */ 00110 (GPIOCFG_IN <<PB3_CFG_BIT); 00111 GPIO_PBCFGH = (GPIOCFG_IN <<PB4_CFG_BIT)| 00112 (GPIOCFG_IN <<PB5_CFG_BIT)| 00113 (GPIOCFG_IN <<PB6_CFG_BIT)| 00114 (GPIOCFG_IN <<PB7_CFG_BIT); 00115 GPIO_PCCFGL = (GPIOCFG_IN <<PC0_CFG_BIT)| 00116 (GPIOCFG_IN <<PC1_CFG_BIT)| 00117 (GPIOCFG_IN <<PC2_CFG_BIT)| 00118 (GPIOCFG_IN <<PC3_CFG_BIT); 00119 GPIO_PCCFGH = (GPIOCFG_IN <<PC4_CFG_BIT)| 00120 (GPIOCFG_IN <<PC5_CFG_BIT)| 00121 (GPIOCFG_IN <<PC6_CFG_BIT)| /* OSC32K */ 00122 (GPIOCFG_IN <<PC7_CFG_BIT); /* OSC32K */ 00123 00124 }