/** \brief UART initialization ** ** \param[in] baudrate baud rate for uart usb ** \param[in] fifolevel fifo trigger level for uart usb **/ static void uart_init(int32_t baudrate, int32_t fifolevel) { /* change baud rate for uart usb */ ciaaPOSIX_ioctl(fd_uart1, ciaaPOSIX_IOCTL_SET_BAUDRATE, (void *)baudrate); /* change FIFO TRIGGER LEVEL for uart usb */ ciaaPOSIX_ioctl(fd_uart1, ciaaPOSIX_IOCTL_SET_FIFO_TRIGGER_LEVEL, (void *)fifolevel); /* Send to UART controller configuration */ char tempMaxascii[10]; convert_temp_to_ascii((TEMP_MAX)*10, tempMaxascii); char tempMinascii[10]; convert_temp_to_ascii((TEMP_MIN)*10, tempMinascii); const char message[] = "------ Temperature Controller ------\r\n\n"; ciaaPOSIX_write(fd_uart1, message, ciaaPOSIX_strlen(message)); const char message2[] = "Maximum Temperature:\r\n"; ciaaPOSIX_write(fd_uart1, message2, ciaaPOSIX_strlen(message2)); ciaaPOSIX_write(fd_uart1, tempMaxascii, ciaaPOSIX_strlen(tempMaxascii)); const char message3[] = "\nMinimum Temperature:\r\n"; ciaaPOSIX_write(fd_uart1, message3, ciaaPOSIX_strlen(message3)); ciaaPOSIX_write(fd_uart1, tempMinascii, ciaaPOSIX_strlen(tempMinascii)); const char message4[] = "\n\nActual Temperature:\r\n"; ciaaPOSIX_write(fd_uart1, message4, ciaaPOSIX_strlen(message4)); }
int MPU6050_I2C_Escribir(uint8_t addr, uint8_t *pBuf, uint32_t len) { ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_SLAVEADD, (void *)addr); ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_REGISTERADDWIDTH, (void *)ciaaREGISTERADDWIDTH_0bits); ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_REGISTERADD, (void *)0x00); len = ciaaPOSIX_write(i2cExpansion, pBuf, len); return len; }
int AT24C512_I2C_Leer(uint8_t addr, uint8_t *pBuf_out, uint32_t len_out, uint8_t *pBuf_in, uint32_t len_in) { uint32_t reg = 0UL; reg |= ((uint32_t)pBuf_out[0]) << 8; reg |= ((uint32_t)pBuf_out[1]) << 0; ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_SLAVEADD, (void *)addr); ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_REGISTERADDWIDTH, (void *)len_out); ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_REGISTERADD, (void *)reg); len_in = ciaaPOSIX_read(i2cExpansion, pBuf_in, len_in); return len_in; }
int MPU6050_I2C_Leer(uint8_t addr, uint8_t *pBuf_out, uint32_t len_out, uint8_t *pBuf_in, uint32_t len_in) { uint32_t reg = 0UL; int i; for(i = 0; i < len_out; i++) { reg |= pBuf_out[i] << (8*i); } ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_SLAVEADD, (void *)addr); ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_REGISTERADDWIDTH, (void *)len_out); ciaaPOSIX_ioctl(i2cExpansion, ciaaPOSIX_IOCTL_SET_REGISTERADD, (void *)reg); len_in = ciaaPOSIX_read(i2cExpansion, pBuf_in, len_in); return len_in; }
void ciaaKeyboard_MainTask(void){ static uint8_t Column, Row = 0; static uint8_t prev_col = 5; static uint8_t prev_row = 5; uint8_t err; if(0 != change_keyb_func){ ciaaKeyboard_FunctionInit(change_keyb_func); } err = ciaaPOSIX_ioctl(fd_keyb,KEYB_LINE_CTRL,Row); if(err == (-1)){ /* Error. ioctl function cannot be done */ ciaaPOSIX_printf("Error changing Active Line\n"); while(1); } err = ciaaPOSIX_read(fd_keyb,&Column,1); if(err == (-1)){ /* Error. read function cannot be done */ ciaaPOSIX_printf("Error reading Keyboard\n"); while(1); } if(0xFF != Column) { if((Row != prev_row) && (Column != prev_col)) { err = functions[Row][Column](); prev_row = Row; prev_col = Column; } } if(MAX_COLUMN <= Row){ Row = 0; } else{ Row++; } }