int main(void) { debug_init(SOFTWARE_NAME); PIO_InitializeInterrupts(AT91C_AIC_PRIOR_LOWEST); char_display_init(); LED_Configure(0); LED_Configure(1); if (! BCAN_Init(1000, 0, NULL)) { printf("INIT FAIL"); LED_Set(1); return 1; } printf("INIT OK\n\r"); LED_Set(0); BCAN_InitMailboxRegisters( 0, 2, AT91C_CAN_MIDvA, (0x5AC << 18), AT91C_CAN_MOT_RX, 0x0); char_display_number(6); while(1) { CAN_Packet packet = BCAN_ReadAndClear(0,2); if (packet.valid) { char_display_number(packet.data_low); } char_display_tick(); for (unsigned volatile int i = 0xFF; i > 0; i--) ; } return 0; }
void char_display_write (int row, int start_pos, const char *ptr) { if (!char_display_init()) return; if (row != LCD_ROW_ONE && row != LCD_ROW_TWO) return; if (start_pos < 0 || start_pos > 15) return; alt_up_character_lcd_set_cursor_pos(LCD_port, start_pos, row); alt_up_character_lcd_string(LCD_port, ptr); }
int main(void) { unsigned int switchPressed; debug_init(SOFTWARE_NAME); PIO_InitializeInterrupts(AT91C_AIC_PRIOR_LOWEST); switches_init(); char_display_init(); LED_Configure(0); LED_Configure(1); if (! BCAN_Init(1000, 0, NULL)) { printf("INIT FAIL"); LED_Set(1); return 1; } printf("INIT OK\n\r"); LED_Set(0); BCAN_InitMailboxRegisters( 0, 1, 0x0, (0x5AC << 18), AT91C_CAN_MOT_TX, 0x0); while(1) { DisplayMenu(); switchPressed = -1; while (switchPressed == -1) { if (switches_pressed(0)) { TRACE_INFO("Switch 0 is pressed\n\r"); switchPressed = 0; } else if (switches_pressed(1)) { TRACE_INFO("Switch 1 is pressed\n\r"); switchPressed = 1; } else if (switches_pressed(2)) { TRACE_INFO("Switch 2 is pressed\n\r"); switchPressed = 2; } else if (switches_pressed(3)) { TRACE_INFO("Switch 3 is pressed\n\r"); switchPressed = 3; } else { //TRACE_INFO("No Switch is pressed\n\r"); } char_display_tick(); for (volatile unsigned int i = 0xFF; i > 0; i--) ; } unsigned int result = -1; while (result != CAN_STATUS_SUCCESS) { result = BCAN_Write(0, 1, 0, switchPressed, 0x1); } char_display_number(switchPressed); } return 0; }
void char_display_hide_cursor () { if (!char_display_init()) return; alt_up_character_lcd_cursor_off(LCD_port); }
void char_display_clear () { if (!char_display_init()) return; alt_up_character_lcd_init(LCD_port); }