int main(void) { main_init(); timer_a0_init(); // PGA2311 needs to get the digital power after a delay // otherwise it will lock up timer_a0_delay_ccr4(_1s); pga_enable; spi_init(); spi_fast_mode(); // set chip selects high (deselect all slaves) P1OUT |= 0x54; P2OUT |= 0x1; P4OUT |= 0x84; settings_init(FLASH_ADDR); get_temperature(); #ifdef USE_UART uart1_init(); uart1_iface_init(); #endif #ifdef USE_I2C i2c_slave_init(); i2c_iface_init(); #endif sys_messagebus_register(&timer_a0_ovf_irq, SYS_MSG_TIMER0_IFG); led_off; while (1) { // go into low power mode until an IRQ wakes us up _BIS_SR(LPM0_bits + GIE); __no_operation(); //wake_up(); #ifdef USE_WATCHDOG WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL; #endif check_events(); } }
int main(void) { main_init(); rtca_init(); timer_a0_init(); uart0_init(); sim900_init_messagebus(); sim900.next_state = SIM900_OFF; settings_init(SEGMENT_B, VERSION_BASED); //settings_apply(); m.e = 0x0; m.seg[0] = 0x0; m.seg_num = 1; stat.http_post_version = POST_VERSION; stat.fix_id = 1; sim900.imei[0] = 0; sim900.flags = 0; gps_trigger_next = 0; gprs_trigger_next = s.gprs_loop_interval; rtca_set_next = 0; rtc_not_set = 1; gps_next_state = MAIN_GPS_IDLE; if (s.gps_invalidate_interval > s.gps_loop_interval) { s.gps_invalidate_interval = s.gps_loop_interval; } gprs_tx_trig = 0; gprs_tx_next = s.gprs_static_tx_interval; gprs_blackout_lift = 0; #ifdef DEBUG_GPS uart1_init(9600); uart1_tx_str("gps debug state\r\n", 17); #endif #ifdef DEBUG_GPRS uart0_tx_str("gprs debug state\r\n", 18); display_menu(); #endif #ifdef CALIBRATION sys_messagebus_register(&adc_calibration, SYS_MSG_RTC_SECOND); #else #ifndef DEBUG_GPRS sys_messagebus_register(&schedule, SYS_MSG_RTC_SECOND); sys_messagebus_register(&parse_gps, SYS_MSG_UART0_RX); #else sys_messagebus_register(&parse_UI, SYS_MSG_UART0_RX); #endif #ifndef DEBUG_GPS sys_messagebus_register(&parse_gprs, SYS_MSG_UART1_RX); #endif #endif #ifdef FM24_HAS_SLEEP_MODE fm24_sleep(); #endif // main loop while (1) { _BIS_SR(LPM3_bits + GIE); //wake_up(); #ifdef USE_WATCHDOG // reset watchdog counter WDTCTL = (WDTCTL & 0xff) | WDTPW | WDTCNTCL; #endif // new messages can be sent from within a check_events() call, so // parse the message linked list multiple times check_events(); check_events(); check_events(); #ifdef FM24_HAS_SLEEP_MODE // sleep if (fm24_status & FM24_AWAKE) { fm24_sleep(); } #endif // P4.0 and P4.1 //P4SEL &= ~0x3; /* PMMCTL0_H = 0xA5; SVSMHCTL &= ~SVMHE; SVSMLCTL &= ~(SVSLE+SVMLE); PMMCTL0_H = 0x00; */ } }