END_TEST START_TEST(test_gprotc_read_cont) { u16 addr = 0; for(addr=0; addr<32; addr++){ fail_unless(0 == gpc_setup_reg(addr, &gpc_dummy_register_map[addr])); } for(addr=0; addr<32; addr++){ gpc_dummy_register_map[addr] = addr | ((addr+1) << 8); } for(addr=0; addr<256; addr++){ fail_unless(1 == gpc_register_touched(addr)); fail_unless(0 == gpc_dummy_register_changed); fail_unless(0 == gpc_dummy_register_changed_addr); fail_unless((void *)0 == gpc_dummy_register_changed_data); } for(addr=0; addr<31; addr++){ fail_unless(0 == gpc_handle_byte(addr | GP_MODE_READ | GP_MODE_CONT)); fail_unless(0 == gpc_register_touched(addr)); fail_unless(addr == gpc_pickup_byte()); fail_unless(addr == gpc_pickup_byte()); fail_unless(addr+1 == gpc_pickup_byte()); fail_unless(-1 == gpc_pickup_byte()); fail_unless(0 == gpc_handle_byte(addr | GP_MODE_READ | GP_MODE_CONT)); fail_unless(1 == gpc_register_touched(addr)); fail_unless(0 == gpc_dummy_register_changed); fail_unless(0 == gpc_dummy_register_changed_addr); fail_unless((void *)0 == gpc_dummy_register_changed_data); } }
END_TEST START_TEST(test_gprotc_handle_byte_read) { u8 addr = 0; for(addr=0; addr<32; addr++){ fail_unless(0 == gpc_setup_reg(addr, &gpc_dummy_register_map[addr])); } for(addr=0; addr<32; addr++){ fail_unless(0 == gpc_handle_byte(addr | GP_MODE_READ | GP_MODE_PEEK)); fail_unless(1 == gpc_dummy_trigger_output_triggered); fail_unless((void *)1 == gpc_dummy_trigger_output_data); fail_unless(addr == gpc_pickup_byte()); fail_unless(0x55+addr == gpc_pickup_byte()); fail_unless(0xAA == gpc_pickup_byte()); fail_unless(-1 == gpc_pickup_byte()); gpc_dummy_trigger_output_triggered = 0; gpc_dummy_trigger_output_data = 0; } for(addr=0; addr<32; addr++){ fail_unless(1 == gpc_handle_byte(addr | GP_MODE_READ | GP_MODE_PEEK | GP_MODE_RESERVED)); fail_unless(0 == gpc_dummy_trigger_output_triggered); fail_unless((void *)0 == gpc_dummy_trigger_output_data); fail_unless(-1 == gpc_pickup_byte()); } }
/** * USART interrupt handler. */ void usart1_isr(void) { //TOGGLE(GREEN); /* input (RX) handler */ if ((USART_SR(USART1) & USART_SR_RXNE) != 0) { data_buf = usart_recv(USART1); if (gpc_handle_byte((u8)data_buf) != 0) { //LED_GREEN_TOGGLE(); } else { //LED_RED_ON(); } } /* output (TX) handler */ if ((USART_SR(USART1) & USART_SR_TXE) != 0) { if ((data_buf = gpc_pickup_byte()) >= 0) { usart_send(USART1, (uint16_t)data_buf); //LED_GREEN_TOGGLE(); } else { usart_disable_send(); } } }
void gpm_trigger_output_hook(void *data) { s32 dat; data = data; while(-1 != (dat = gpm_pickup_byte())){ if(gpc_handle_byte(dat)) printf("gpc_handle_byte %02X failed.\n", dat); } }
END_TEST START_TEST(test_gprotc_handle_byte_write) { u8 addr = 0; u16 data = 0xDADE; for(addr=0; addr<32; addr++){ fail_unless(0 == gpc_setup_reg(addr, &gpc_dummy_register_map[addr])); } for(addr=0; addr<32; addr++){ fail_unless(0 == gpc_handle_byte(addr | GP_MODE_WRITE)); fail_unless(0 == gpc_handle_byte(data & 0xFF)); fail_unless(0 == gpc_handle_byte(data >> 8)); fail_unless(1 == gpc_dummy_register_changed); fail_unless(addr == gpc_dummy_register_changed_addr); fail_unless((void *)1 == gpc_dummy_register_changed_data); fail_unless(data == gpc_dummy_register_map[addr]); gpc_dummy_register_changed = 0; gpc_dummy_register_changed_addr = 0; gpc_dummy_register_changed_data = 0; } for(addr=0; addr<32; addr++){ fail_unless(1 == gpc_handle_byte(addr | GP_MODE_WRITE | GP_MODE_RESERVED)); fail_unless(0 == gpc_dummy_register_changed); fail_unless(0 == gpc_dummy_register_changed_addr); fail_unless((void *)0 == gpc_dummy_register_changed_data); fail_unless(-1 == gpc_pickup_byte()); gpc_dummy_register_changed = 0; gpc_dummy_register_changed_addr = 0; gpc_dummy_register_changed_data = 0; } }
void usart3_irq_handler(void) { /* input (RX) handler */ if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET){ data_buf = USART_ReceiveData(USART3); if(!gpc_handle_byte(data_buf)){ LED_GREEN_TOGGLE(); }else{ LED_RED_ON(); } } /* output (TX) handler */ if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET){ if((data_buf = gpc_pickup_byte()) >= 0){ USART_SendData(USART3, data_buf); LED_GREEN_TOGGLE(); }else{ usart_disable_send(); } } }
int GovernorClient::handleByte(unsigned char byte) { return gpc_handle_byte(byte); }