void __led_set (led_id_t mask, int state) { if (STATUS_LED_BLUE == mask) { if (STATUS_LED_ON == state) blue_LED_on (); else blue_LED_off (); } else if (STATUS_LED_RED == mask) { if (STATUS_LED_ON == state) red_LED_on (); else red_LED_off (); } }
void __led_toggle (led_id_t mask) { if (STATUS_LED_BLUE == mask) { if (STATUS_LED_ON == saved_state[STATUS_LED_BLUE]) blue_LED_off (); else blue_LED_on (); } else if (STATUS_LED_RED == mask) { if (STATUS_LED_ON == saved_state[STATUS_LED_RED]) red_LED_off (); else red_LED_on (); } }
void __led_set(led_id_t mask, int state) { if (STATUS_LED_RED == mask) { if (STATUS_LED_ON == state) red_LED_on(); else red_LED_off(); } else if (STATUS_LED_GREEN == mask) { if (STATUS_LED_ON == state) green_LED_on(); else green_LED_off(); } }
void __led_toggle(led_id_t mask) { if (STATUS_LED_RED == mask) { if (STATUS_LED_ON == saved_state[STATUS_LED_RED]) red_LED_off(); else red_LED_on(); } else if (STATUS_LED_GREEN == mask) { if (STATUS_LED_ON == saved_state[STATUS_LED_GREEN]) green_LED_off(); else green_LED_on(); } }
/***** main loop *****/ int main(){ unsigned char i; init_status = no_init; volatile U8 led_toggle_counter = 0; U8 reset_cause = MCUSR; MCUSR = 0x00; //red_LED_toggle(); //external crystal, no prescaler CLKPR = 0x80; CLKPR = 0x00; //prepare the incremental_in_value_packet incremental_in_value_packet.id = 0x07; incremental_in_value_packet.length = 6; for (i = 0; i < incremental_in_value_packet.length; i++) { incremental_in_value_packet.data[i] = 0; } //prepare the init_ack_async_packet init_ack_sync_packet.id = 0x02; init_ack_sync_packet.length = 1; init_ack_sync_packet.data[0] = 0x14; communication_init(); //EICRA = 0x0C; //INT1 pin triggers async interrupt on rising edge //EICRB = 0xAA; //INT7-4 pins trigger sync interrupt on falling edge //EIMSK = 0xF2; //INT7-4 and INT1 are enabled //global interrupt enable sei(); if (prepare_rx(1,0x01,0xFF,incoming_init)) red_LED_on(); //debug for incoming message //TWBR = reset_cause; update_DA_A(STOP_DA_VAL); update_DA_B(STOP_DA_VAL); update_DA_C(STOP_DA_VAL); DA_LDAC_high(); DA_LDAC_low(); green_LED_on(); while(1){ if (init_status == init_2){ init_status = running; prepare_rx(3, 0x05, 0xFF, incoming_stop); prepare_rx(4, 0x06, 0xFF, incoming_DA_out_value); prepare_rx(6, 0x0B, 0xFF, incoming_request_incremental_value); prepare_rx(7, 0x0E, 0xFF, incoming_sync_command); } if (init_status == running) { prepare_incremental_in_value_packet(); while(!can_tx(5, &incremental_in_value_packet)) {}; if ((++led_toggle_counter) == 0xFF) { yellow_LED_toggle(); led_toggle_counter = 0; } } } return 0; }