void I2C_PrintErrorFlags(void) { if (!i2c_error_flags) { COM_Printf("\r\nNo I2C error\r\n"); return; } COM_Printf("\r\nI2C failure: %04X",i2c_error_flags); if (i2c_error_flags & I2C_SR1_SB) COM_Puts(", Bus busy"); if (i2c_error_flags & I2C_SR1_BERR) COM_Puts(", Bus error"); if (i2c_error_flags & I2C_SR1_ARLO) COM_Puts(", Arbitration lost"); if (i2c_error_flags & I2C_SR1_AF) COM_Puts(", Acknowledge fail"); if (i2c_error_flags & I2C_SR1_OVR) COM_Puts(", Overrun"); if (i2c_error_flags & I2C_SR1_PECERR) COM_Puts(", PEC error"); if (i2c_error_flags & I2C_SR1_TIMEOUT) COM_Puts(", SMBus timeout"); if (i2c_error_flags & I2C_SR1_SMBALERT) COM_Puts(", SMBus alert"); COM_Puts("\r\n"); }
Ecode_t COM_PrintCarriageReturn(COM_Port_t port) { if (checkValidPort(port)==false) { return EMBER_ERR_FATAL; } return COM_Printf(port, "\r\n"); }
static void keyboard_task(void *par) { uint8_t keyb_last,code; keyb_last = 0; code = 0; I2C_RandWrite(KEYBCTRL_ADDR,KBREG_CTRL,1,&keyb_last,1); while (!GPIO_ReadInputDataBit(KBD_IRQn_PORT,KBD_IRQn_PIN)) { keyboard_stroke(); vTaskDelay(kDec/2); } xSemaphoreTake(xSemaKeybo,0); NVIC_EnableIRQ(KBD_IRQn_EXTI_IRQn); for (;;) { keyboard_irq_eve(portMAX_DELAY); if (I2C_RandRead(KEYBCTRL_ADDR,KBREG_MASK,1,&code,1)) { Dprintf(DBGLVL_Keyboard,"keyboard: code=%02X",code); keyboard_stroke(); if (code) { keyb_last = key_decode(code); Dprintf(DBGLVL_Keyboard,"keyboard: %02X",keyb_last); if (keyb_last) { COM_Printf("\r\n*KEYB: %02X,\"%c\"\r\n",code,keyb_last); if (!keyboard_irq_eve(KEYPRESSED_TIME)) { // still pressed key_putstroke(keyb_last,0); //BuzzerSet(BUZTYPE_TOCK); } else { // released keyboard_stroke(); Dprintf(DBGLVL_Keyboard,"keyboard: invalid pressure time"); continue; // already released } } keyboard_waitrelease(); key_putstroke(keyb_last | KEY_RELEASED,0); Dprintf(DBGLVL_Keyboard,"keyboard: released"); } } } }