don't call led_init() from mcu_init anymore, instead call the indiivdual LED_INIT(x) wherever they are used

This way we can actually define all the leds in the board files, but only initialized the actually used ones.
Otherwise we would render the ADC_1-3 useless by automatically initializing
the leds 6,7,8 on lisa/m 2.0 (which are not populated by default anyway).
This commit is contained in:
Felix Ruess
2012-05-16 01:43:03 +02:00
parent ee727383c4
commit 46f7182fe6
31 changed files with 154 additions and 12 deletions
+4
View File
@@ -103,6 +103,10 @@ void ADS8344_init( void ) {
/* configure SS pin */
SetBit( ADS8344_SS_IODIR, ADS8344_SS_PIN); /* pin is output */
ADS8344Unselect(); /* pin low */
// FIXME, no hardcoded led numbers
LED_INIT(2);
LED_OFF(2);
}
static inline void read_values( void ) {
@@ -120,6 +120,11 @@ void sys_time_arch_init( void ) {
_VIC_CNTL(TIMER0_VIC_SLOT) = VIC_ENABLE | VIC_TIMER0;
/* address of the ISR */
_VIC_ADDR(TIMER0_VIC_SLOT) = (uint32_t)TIMER0_ISR;
//FIXME, no hardcoded led number
#ifdef TRIGGER_EXT
LED_INIT(3);
#endif
}
+7 -1
View File
@@ -15,8 +15,14 @@ int main (int argc, char** argv) {
int tx=0, rx=0;
int tx_shadow=1, rx_shadow=1;
mcu_init();
led_init();
// FIXME, no hardcoded led numbers
LED_INIT(1);
LED_ON(1);
LED_INIT(2);
LED_OFF(2);
LED_INIT(3);
LED_OFF(3);
/* TXD0 and TXD1 output */
SetBit(IO0DIR, TXD0_PIN);
+9 -1
View File
@@ -46,7 +46,15 @@ int main( void ) {
mcu_init();
sys_time_init();
led_init();
// FIXME, no hardcoded led numbers
LED_INIT(1);
LED_ON(1);
LED_INIT(2);
LED_OFF(2);
LED_INIT(3);
LED_OFF(3);
VCOM_allow_linecoding(1);
#ifdef USE_USB_SERIAL
+1
View File
@@ -49,6 +49,7 @@ void baro_init( void ) {
baro_board.value_filtered = 0;
baro_board.data_available = FALSE;
#ifdef ROTORCRAFT_BARO_LED
LED_INIT(ROTORCRAFT_BARO_LED);
LED_OFF(ROTORCRAFT_BARO_LED);
#endif
}
+1
View File
@@ -43,6 +43,7 @@ void baro_init( void ) {
baro.absolute = 0;
baro.differential = 0; /* not handled on this board */
#ifdef ROTORCRAFT_BARO_LED
LED_INIT(ROTORCRAFT_BARO_LED);
LED_OFF(ROTORCRAFT_BARO_LED);
#endif
startup_cnt = STARTUP_COUNTER;
@@ -169,6 +169,15 @@ void init_ap( void ) {
mcu_init();
#endif /* SINGLE_MCU */
#ifdef POWER_SWITCH_LED
LED_INIT(POWER_SWITCH_LED);
LED_OFF(POWER_SWITCH_LED);
#endif
#ifdef AHRS_CPU_LED
LED_INIT(AHRS_CPU_LED);
LED_OFF(AHRS_CPU_LED);
#endif
/************* Sensors initialization ***************/
#if USE_GPS
gps_init();
+13 -1
View File
@@ -572,7 +572,19 @@ int main(void)
static inline void main_init( void ) {
mcu_init();
sys_time_init();
led_init();
LED_INIT(LED_RED);
LED_OFF(LED_RED);
LED_INIT(LED_GREEN);
LED_OFF(LED_GREEN);
LED_INIT(LED_YELLOW);
LED_OFF(LED_YELLOW);
//FIXME, no hardcoded led numbers
LED_INIT(1);
LED_OFF(1);
LED_INIT(2);
LED_OFF(2);
#ifdef USE_MAX11040
max11040_init_ssp();
@@ -78,6 +78,7 @@ void autopilot_init(void) {
autopilot_rc = TRUE;
autopilot_power_switch = FALSE;
#ifdef POWER_SWITCH_LED
LED_INIT(POWER_SWITCH_LED);
LED_ON(POWER_SWITCH_LED); // POWER OFF
#endif
autopilot_arming_init();
+5
View File
@@ -10,6 +10,11 @@ void overo_link_init(void) {
overo_link.crc_error = FALSE;
overo_link.timeout = FALSE;
overo_link_arch_init();
LED_INIT(OVERO_LINK_LED_OK);
LED_INIT(OVERO_LINK_LED_KO);
LED_OFF(OVERO_LINK_LED_OK);
LED_OFF(OVERO_LINK_LED_KO);
}
+2
View File
@@ -53,6 +53,8 @@ int main(void) {
static inline void main_init( void ) {
mcu_init();
LED_INIT(3);
LED_OFF(3);
sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
main_spi_slave_init();
}
+4
View File
@@ -52,6 +52,10 @@ int main(void) {
static inline void main_init( void ) {
mcu_init();
sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
LED_INIT(1);
LED_INIT(2);
LED_OFF(1);
LED_OFF(2);
}
static inline void main_periodic( void ) {
+3
View File
@@ -55,6 +55,9 @@ int main(void) {
mcu_init();
sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
LED_INIT(2);
LED_OFF(2);
/* init RCC */
RCC_APB2PeriphClockCmd(A_PERIPH , ENABLE);
// RCC_APB2PeriphClockCmd(B_PERIPH , ENABLE);
-3
View File
@@ -60,9 +60,6 @@ void mcu_init(void) {
#ifdef PERIPHERALS_AUTO_INIT
sys_time_init();
#ifdef USE_LED
led_init();
#endif
/* for now this means using spektrum */
#if defined RADIO_CONTROL & defined RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT & defined RADIO_CONTROL_BIND_IMPL_FUNC
RADIO_CONTROL_BIND_IMPL_FUNC();
+6
View File
@@ -29,6 +29,7 @@
#include "mcu_periph/sys_time.h"
#include "mcu.h"
#include "led.h"
struct sys_time sys_time;
@@ -69,6 +70,11 @@ void sys_time_update_timer(tid_t id, float duration) {
void sys_time_init( void ) {
sys_time_arch_init();
#ifdef SYS_TIME_LED
LED_INIT(SYS_TIME_LED);
LED_OFF(SYS_TIME_LED);
#endif
sys_time.nb_sec = 0;
sys_time.nb_sec_rem = 0;
sys_time.nb_tick = 0;
@@ -33,8 +33,12 @@ volatile uint8_t i2c_abuse_test_counter = 0;
volatile uint32_t i2c_abuse_test_bitrate = 1000;
void init_i2c_abuse_test(void) {
//LED_INIT(DEMO_MODULE_LED);
//LED_OFF(DEMO_MODULE_LED);
LED_INIT(4);
LED_OFF(4);
LED_INIT(5);
LED_OFF(5);
LED_INIT(I2C_ABUSE_LED);
LED_OFF(I2C_ABUSE_LED);
i2c_test1.status = I2CTransSuccess;
i2c_test1.slave_addr = 0x3C;
@@ -73,6 +73,8 @@ int16_t booz_cam_pan;
#endif
void booz_cam_init(void) {
LED_INIT(CAM_SWITCH_LED);
LED_ON(CAM_SWITCH_LED);
booz_cam_SetCamMode(BOOZ_CAM_DEFAULT_MODE);
#ifdef BOOZ_CAM_USE_TILT
booz_cam_tilt_pwm = BOOZ_CAM_TILT_NEUTRAL;
+4
View File
@@ -101,6 +101,10 @@ void cam_waypoint_target(void);
void cam_ac_target(void);
void cam_init( void ) {
#ifdef VIDEO_TX_SWITCH
LED_INIT(VIDEO_TX_SWITCH);
#endif
cam_mode = CAM_MODE0;
}
@@ -54,6 +54,17 @@ extern uint8_t dc_timer;
static inline void led_cam_ctrl_init(void)
{
LED_INIT(DC_SHUTTER_LED);
#ifdef DC_ZOOM_IN_LED
LED_INIT(DC_ZOOM_IN_LED);
#endif
#ifdef DC_ZOOM_OUT_LED
LED_INIT(DC_ZOOM_OUT_LED);
#endif
#ifdef DC_POWER_LED
LED_INIT(DC_POWER_LED);
#endif
// Call common DC init
dc_init();
+2
View File
@@ -152,6 +152,8 @@ static uint8_t gcs_index_max;
/*****************************************************************************/
void gsm_init(void) {
LED_INIT(GSM_ONOFF_LED);
if (gsm_status == STATUS_NONE) { /* First call */
LED_ON(GSM_ONOFF_LED);
gsm_status = STATUS_POWERON;
+3
View File
@@ -38,6 +38,9 @@ volatile uint8_t new_ins_attitude;
void ins_init( void )
{
// FIXME, don't use hardcode led number here
LED_INIT(3);
// uint8_t ping[7] = {CHIMU_STX, CHIMU_STX, 0x01, CHIMU_BROADCAST, MSG00_PING, 0x00, 0xE6 };
uint8_t rate[12] = {CHIMU_STX, CHIMU_STX, 0x06, CHIMU_BROADCAST, MSG10_UARTSETTINGS, 0x05, 0xff, 0x79, 0x00, 0x00, 0x01, 0x76 }; // 50Hz attitude only + SPI
uint8_t quaternions[7] = {CHIMU_STX, CHIMU_STX, 0x01, CHIMU_BROADCAST, MSG09_ESTIMATOR, 0x01, 0x39 }; // 25Hz attitude only + SPI
+3
View File
@@ -37,6 +37,9 @@ volatile uint8_t new_ins_attitude;
void ins_init( void )
{
// FIXME, don't use hardcode led number here
LED_INIT(3);
uint8_t ping[7] = {CHIMU_STX, CHIMU_STX, 0x01, CHIMU_BROADCAST, MSG00_PING, 0x00, 0xE6 };
uint8_t rate[12] = {CHIMU_STX, CHIMU_STX, 0x06, CHIMU_BROADCAST, MSG10_UARTSETTINGS, 0x05, 0xff, 0x79, 0x00, 0x00, 0x01, 0x76 }; // 50Hz attitude only + SPI
uint8_t quaternions[7] = {CHIMU_STX, CHIMU_STX, 0x01, CHIMU_BROADCAST, MSG09_ESTIMATOR, 0x01, 0x39 }; // 25Hz attitude only + SPI
+8
View File
@@ -226,6 +226,14 @@ volatile int xsens_configured = 0;
void ins_init( void ) {
// FIXME, don't use hardcode led number here
LED_INIT(3);
#ifdef GPS_LED
LED_INIT(GPS_LED);
LED_OFF(GPS_LED);
#endif
xsens_status = UNINIT;
xsens_configured = 20;
+6 -1
View File
@@ -237,8 +237,13 @@ uint8_t humid_sht_reset( void )
void humid_sht_init( void )
{
/* Configure DAT/SCL pin as GPIO */
// FIXME, should not use hardcoded led number
LED_INIT(2);
LED_OFF(2);
// FIXME, should not contain arch dependent code here
/* Configure DAT/SCL pin as GPIO */
#if (DAT_PIN<16)
PINSEL0 &= ~(_BV(DAT_PIN*2)|_BV(DAT_PIN*2+1));
#else
+4 -1
View File
@@ -36,7 +36,10 @@ int main( void ) {
static inline void main_init( void ) {
mcu_init();
sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
led_init();
LED_INIT(1);
LED_OFF(1);
Uart0Init();
spi_init();
@@ -46,6 +46,11 @@ void ahrs_aligner_init(void) {
samples_idx = 0;
ahrs_aligner.noise = 0;
ahrs_aligner.low_noise_cnt = 0;
#ifdef AHRS_ALIGNER_LED
LED_INIT(AHRS_ALIGNER_LED);
LED_OFF(AHRS_ALIGNER_LED);
#endif
}
#ifndef LOW_NOISE_THRESHOLD
+1
View File
@@ -38,6 +38,7 @@ void gps_init(void) {
gps.fix = GPS_FIX_NONE;
gps.cacc = 0;
#ifdef GPS_LED
LED_INIT(GPS_LED);
LED_OFF(GPS_LED);
#endif
#ifdef GPS_TYPE_H
+5
View File
@@ -71,6 +71,11 @@ static inline void radio_control_init ( void ) {
radio_control.frame_rate = 0;
radio_control.frame_cpt = 0;
radio_control_impl_init();
#if defined RADIO_CONTROL_LED
LED_INIT(RADIO_CONTROL_LED);
LED_OFF(RADIO_CONTROL_LED);
#endif
}
/************* PERIODIC ******************************************************/
@@ -11,6 +11,20 @@ static inline void main_event( void );
int main(void) {
mcu_init();
#ifdef LED_GREEN
LED_INIT(LED_GREEN);
LED_OFF(LED_GREEN);
#endif
#ifdef LED_BLUE
LED_INIT(LED_BLUE);
LED_OFF(LED_BLUE);
#endif
#ifdef LED_RED
LED_INIT(LED_RED);
LED_OFF(LED_RED);
#endif
unsigned int tmr_02 = sys_time_register_timer(0.2, NULL);
unsigned int tmr_03 = sys_time_register_timer(0.3, NULL);
sys_time_register_timer(0.5, main_periodic_05);
+6 -1
View File
@@ -61,6 +61,11 @@ static inline void main_init( void ) {
mcu_init();
#ifdef BOARD_LISA_L
LED_INIT(3);
LED_OFF(3);
#endif
sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
imu_init();
@@ -71,7 +76,7 @@ static inline void main_init( void ) {
static inline void led_toggle ( void ) {
#ifdef BOARD_LISA_L
LED_TOGGLE(3);
LED_TOGGLE(3);
#endif
}
+4 -1
View File
@@ -21,7 +21,10 @@ static struct adc_buf buf_adc[NB_ADC];
int main (int argc, char** argv) {
mcu_init();
sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
led_init();
LED_INIT(1);
LED_OFF(1);
adc_init();
adc_buf_channel(ADC_0, &buf_adc[0], ADC_NB_SAMPLES);