void ICACHE_FLASH_ATTR dmx_task(os_event_t *events) { int i; if(twinkl_has_changes()) { INFO("Updating DMX channels\n"); twinkl_render(dmx_channels); } //INFO("Sending DMX channels\n"); //Space for break PIN_FUNC_SELECT(pin_mux[dmx_tx_pin], FUNC_GPIO2); gpio_output_set(0, BIT2, BIT2, 0); os_delay_us(125); //Mark After Break gpio_output_set(BIT2, 0, BIT2, 0); os_delay_us(50); //Looks the wrong way round, but reduces jitter somehow //Do not touch. PIN_FUNC_SELECT(pin_mux[dmx_tx_pin], FUNC_U1TXD_BK); uart_tx_one_char(1, 0); for(i = 0; i < TWINKL_CHANNEL_COUNT; i++) { uart_tx_one_char(1, dmx_channels[i]); } //INFO("Done sending DMX channels\n"); if(udp_server != NULL) { os_timer_arm(&dmx_update_timer, dmx_refresh_delay, 0); } }
void roomba_drive(unsigned int velocity, unsigned int radius) { roomba_startup(); uart_tx_one_char(DRIVE); uart_tx_one_char(velocity / 256); uart_tx_one_char(velocity); uart_tx_one_char(radius / 256); uart_tx_one_char(radius); }
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) { while (len--) { if (*str == '\n') { uart_tx_one_char(UART0, '\r'); } uart_tx_one_char(UART0, *str++); } }
void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len) { (void)env; while (len--) { if (*str == '\n') { uart_tx_one_char(UART0, '\r'); } uart_tx_one_char(UART0, *str++); } }
void unity_putc(int c) { if (c == '\n') { uart_tx_one_char('\r'); uart_tx_one_char('\n'); } else if (c == '\r') { } else { uart_tx_one_char(c); } }
//Init function void ICACHE_FLASH_ATTR user_init() { uint8 data[] = "Hello World"; uint8 hello[0x1000] = "1111111111"; uint32_t i; extern void ets_wdt_disable(void); uart_init(BIT_RATE_115200, BIT_RATE_115200); uart_tx_one_char(system_update_cpu_freq(SYS_CPU_160MHZ)); os_install_putc1(uart_tx_one_char); spi_flash_erase_sector(0x12); /* if ( spi_flash_write( 0x12000, (uint32 *)data, 10 ) != 0 ){ ets_uart_printf("Error"); } else { ets_uart_printf("Write done"); if ( spi_flash_read( 0x12000, (uint32 *)hello, 10 ) != 0 ){ ets_uart_printf("Error"); } else { ets_uart_printf("Read done"); uart_tx_one_char(hello[0]); uart_tx_one_char(hello[1]); uart_tx_one_char(hello[2]); uart_tx_one_char(hello[3]); uart_tx_one_char(hello[4]); uart_tx_one_char(hello[5]); uart_tx_one_char(hello[6]); uart_tx_one_char(hello[7]); uart_tx_one_char(hello[8]); uart_tx_one_char(hello[9]); ets_uart_printf("done"); } } */ spi_flash_write( 0x12000 + 501, (uint32 *)data, 5 ); spi_flash_read( 0x12000 , (uint32 *)hello, 0x1000 ); for ( i = 0; i < 0x1000; i++ ){ uart_tx_one_char(hello[i]); } /* spi_flash_read( 0x13000, (uint32 *)hello, 0x1000 ); for ( i = 0; i < 0x1000; i++ ){ uart_tx_one_char(hello[i]); }*/ }
/** * transfer device identifier to other module */ void synchronize_dev_id() { uart_dev_id_struct dev_id_struct; dev_id_struct.dev_id = dev_id; uart_tx_one_char(UART, DEVICE_IDENTIFIER); int i; for (i = 0; i < sizeof(dev_id_struct.bytes); i++) { uart_tx_one_char(UART, dev_id_struct.bytes[i]); } uart_tx_one_char(UART, 0); }
/****************************************************************************** * FunctionName : uart_init * Description : user interface for init uart * Parameters : UartBautRate uart0_br - uart0 bautrate * UartBautRate uart1_br - uart1 bautrate * Returns : NONE *******************************************************************************/ void ICACHE_FLASH_ATTR uart_init(UartBautRate uart0_br, UartBautRate uart1_br) { // rom use 74880 baut_rate, here reinitialize UartDev.baut_rate = uart0_br; uart_config(UART0); UartDev.baut_rate = uart1_br; uart_config(UART1); for (int i=0; i<4; i++) uart_tx_one_char(UART1, '\n'); for (int i=0; i<4; i++) uart_tx_one_char(UART0, '\n'); ETS_UART_INTR_ENABLE(); // install uart1 putc callback os_install_putc1((void *)uart0_write_char); }
size_t HardwareSerial::write(uint8_t oneChar) { //if (oneChar == '\0') return 0; uart_tx_one_char(oneChar); return 1; }
/****************************************************************************** * FunctionName : uart0_sendStr * Description : use uart0 to transfer buffer * Parameters : uint8 *buf - point to send buffer * uint16 len - buffer len * Returns : *******************************************************************************/ void ICACHE_FLASH_ATTR uart0_sendStr(const char *str) { while(*str) { uart_tx_one_char(UART0, *str++); } }
void ICACHE_FLASH_ATTR forthright_putChar( char ch ) { if( tcp_shell_is_connected() ) { tcp_shell_put_char(ch); } else { uart_tx_one_char( primaryPort, ch ); } }
/****************************************************************************** * FunctionName : uart0_tx_buffer * Description : use uart0 to transfer buffer * Parameters : uint8 *buf - point to send buffer * uint16 len - buffer len * Returns : *******************************************************************************/ void ICACHE_FLASH_ATTR uart0_tx_buffer (uint8 *buf, uint16 len) { while (len) { uart_tx_one_char (*buf); buf++; len--; } }
static unsigned char esp32_uart_tx(struct device *dev, unsigned char c) { ARG_UNUSED(dev); uart_tx_one_char(c); return 0; }
/****************************************************************************** * FunctionName : uart0_tx_buffer * Description : use uart0 to transfer buffer * Parameters : uint8 *buf - point to send buffer * uint16 len - buffer len * Returns : *******************************************************************************/ void ICACHE_FLASH_ATTR uart0_tx_buffer(char *buf, uint16 len) { uint16 i; for (i = 0; i < len; i++) { uart_tx_one_char(UART0, buf[i]); } }
void ICACHE_FLASH_ATTR forthright_echo_char( char ch ) { if( tcp_shell_is_connected() ) { if( ch == '\n' ) { tcp_shell_put_chars( " <ok>\n", 6 ); } } else { uart_tx_one_char( primaryPort, ch ); } }
/** * Transmit all the characters in the transmit buffer. * */ void esp8266_uartTransmitAll(IOEventFlags device) { // Get the next character to transmit. We will have reached the end when // the value of the character to transmit is -1. int c = jshGetCharToTransmit(device); while (c >= 0) { uart_tx_one_char(0, c); c = jshGetCharToTransmit(device); } // No more characters to transmit } // End of esp8266_transmitAll
LOCAL int ICACHE_FLASH_ATTR serial_put_chars( int port, char* str, int length ) { int i=0; for( i = 0; i < length; i++ ) { char ch = str[i]; int result = uart_tx_one_char(port, ch); if( result < 0 ) { return result; } } return i; }
size_t HardwareSerial::write(uint8_t oneChar) { //if (oneChar == '\0') return 0; // uart_tx_one_char(oneChar); // LOCAL STATUS uart_tx_one_char(0, oneChar); // uart0_write_char(oneChar); // UART_ResetFifo(UART0); return 1; }
void vfd_custom_char(uint8_t code, uint8_t row1, uint8_t row2, uint8_t row3, uint8_t row4, uint8_t row5, uint8_t row6, uint8_t row7) { uart_tx_one_char(UART1, '\x1a'); uart_tx_one_char(UART1, code); uart_tx_one_char(UART1, row1); uart_tx_one_char(UART1, row2); uart_tx_one_char(UART1, row3); uart_tx_one_char(UART1, row4); uart_tx_one_char(UART1, row5); uart_tx_one_char(UART1, row6); uart_tx_one_char(UART1, row7); }
//Called from UART. void ICACHE_FLASH_ATTR charrx( uint8_t byte_read ) { #if 0 uart_tx_one_char(1, byte_read); #endif static uint16_t payload_len = 0; /* did the sync pattern match already? */ if ( sync_idx < SYNC_PATTERN_SIZE ) { /* no, so read the incoming byte and continue with the sync pattern check process */ CheckSyncPattern(byte_read); } /* yes, but was it thanks to the previous byte read? */ else if ( payload_len == 0 ) { /* yes, therefore the incoming byte contains the payload length */ payload_len = byte_read; os_printf("payload_len: %d\n\r",payload_len); /* reset UART input buffer */ uart_input_buff[0] = 0; } /* no, then the byte is part of the cmd. Continue reading the cmd from FIFO */ else { /* store next byte */ uart_input_buff[os_strlen(uart_input_buff)] = byte_read; // read byte from FIFO /* did we read all bytes already? */ if ( payload_len == os_strlen(uart_input_buff) ) { /* yes, then the payload was received completely */ /* start an HTTP post request by starting a client TCP connection */ sint8 err = espconn_connect(pTcpConn); if (err != 0) { os_printf("Error connecting to a TCP server: %d\n", err); } os_printf("String received:\n\r%s\n\r",uart_input_buff); /* restart sync pattern check */ sync_idx = 0; /* reset payload lenght */ payload_len = 0; } } }
void uart_tx(unsigned char byte1, unsigned char byte2, char rssi, char *mac, unsigned char channel, unsigned int timestamp) { uart_data_struct tx; tx.count = packet_cnt; tx.identifier = dev_id; itstr((char *) tx.timestamp, sizeof(tx.timestamp), timestamp, 16, sizeof(tx.timestamp)); itstr((char *) tx.channel, 2, channel, 16, 2); itstr((char *) tx.rssi, sizeof(tx.rssi), (unsigned char) rssi, 16, sizeof(tx.rssi)); int i; for (i = 0; i < 6; i++) { itstr((char *) tx.mac[i], 2, mac[i], 16, 2); } itstr((char *) tx.byte1, 2, byte1, 16, 2); itstr((char *) tx.byte2, 2, byte2, 16, 2); // send control byte uart_tx_one_char(UART, CTRL_DATA); // send bytes constructed so far and termination byte for (i = 0; i < sizeof(tx.bytes); i++) { uart_tx_one_char(UART, tx.bytes[i]); } uart_tx_one_char(UART, 0); packet_cnt++; if (!packet_cnt) { packet_cnt = 1; } }
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void ICACHE_FLASH_ATTR user_init(void) { int i; // rom use 74880 baut_rate, here reinitialize uart_init(BIT_RATE_115200, BIT_RATE_115200); uart_tx_one_char('\r'); __printf("NodeLua %s (With liblua %s) Copyright (C) 2014 NodeLua.org free mem=%d\n", NODELUA_RELEASE NODELUA_RELEASE_LOC, LUA_RELEASE, system_get_free_heap_size()); // char *argv[] = {"lua", "-e", (char*)buf}; // for(i = 0; 1; i ++) // { // uint16_t val = system_adc_read(); // __printf("adc=%d\n", val); // luamain(sizeof(argv)/sizeof(char*), argv); // } struct station_config config; wifi_station_get_config(&config); if (wifi_get_opmode() == STATION_MODE && os_strlen(config.ssid) > 0) { os_timer_disarm(&check_sta_timer); os_timer_setfn(&check_sta_timer, (os_timer_func_t *)user_check_ip, 1); os_timer_arm(&check_sta_timer, 100, 0); } else { __printf("Please set wifi parameters to connect to an exist AP!\n"); luainit(""); } return; // #if ESP_PLATFORM // user_esp_platform_init(); // #endif // // user_devicefind_init(); // #ifdef SERVER_SSL_ENABLE // user_webserver_init(SERVER_SSL_PORT); // #else // user_webserver_init(SERVER_PORT); // #endif }
static void ICACHE_FLASH_ATTR user_rx_task(os_event_t *events) { if(events->sig == 0){ uint8 fifo_len = (READ_PERI_REG(UART_STATUS(UART0))>>UART_RXFIFO_CNT_S)&UART_RXFIFO_CNT; uint8 d_tmp = 0; uint8 idx=0; for(idx=0;idx<fifo_len;idx++) { d_tmp = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF; uart_tx_one_char(UART0, d_tmp); if( has_space() ) { serial_buffer[putpos++ & POS_MASK] = d_tmp; } } WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_FULL_INT_CLR|UART_RXFIFO_TOUT_INT_CLR); uart_rx_intr_enable(UART0); if( serial_datalen() && user_rx_callback ) { user_rx_callback(serial_datalen()); } }
static void user_procTask(os_event_t *events) { int rc = irmp_get_data (&irmp_data); if (rc) { os_printf("\nIRMP %10s(%2d): addr=0x%04x cmd=0x%04x, f=%d ", irmp_protocol_names[ irmp_data.protocol], irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags ); } // https://github.com/SuperHouse/esp-open-rtos/issues/18 // uart_rx_one_char ist offenbar eine ROM-Funktion. int c = my_rx_one_char(); if(c != -1) { uart_tx_one_char(0,c); os_printf("(0x%02x, %d) ",c,c); switch(c) { case '.': os_printf("\nTime=%d, GPIO12=%d, ", system_get_time(),GPIO_INPUT_GET(12)); os_printf("gpio=%08x ",gpio_input_get()); break; } } os_delay_us(100); system_os_post(user_procTaskPrio, 0, 0 ); }
// Send: version with and without mux void platform_uart_send( unsigned id, u8 data ) { uart_tx_one_char(id, data); }
void mp_hal_debug_str(const char *str) { while (*str) { uart_tx_one_char(UART0, *str++); } uart_flush(UART0); }
void mp_hal_stdout_tx_char(char c) { uart_tx_one_char(UART0, c); mp_uos_dupterm_tx_strn(&c, 1); }
/** * @brief Uart receive task. * @param events: contain the uart receive data * @retval None */ static void ICACHE_FLASH_ATTR /////// at_recvTask(os_event_t *events) { static uint8_t atHead[2]; static uint8_t *pCmdLine; uint8_t temp; // temp = events->par; // temp = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF; // temp = 'X'; //add transparent determine while(READ_PERI_REG(UART_STATUS(UART0)) & (UART_RXFIFO_CNT << UART_RXFIFO_CNT_S)) { // temp = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF; WRITE_PERI_REG(0X60000914, 0x73); //WTD temp = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF; /* if(at_state != at_statIpTraning) { temp = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF; if((temp != '\n') && (echoFlag)) { uart_tx_one_char(temp); //display back } } * */ if((at_state != at_statIpTraning) && (temp != '\n') && (echoFlag)) { uart_tx_one_char(UART0,temp); //display back // uart_tx_one_char(temp); //display back } switch(at_state) { case at_statIdle: //serch "AT" head atHead[0] = atHead[1]; atHead[1] = temp; if((os_memcmp(atHead, "AT", 2) == 0) || (os_memcmp(atHead, "at", 2) == 0)) { at_state = at_statRecving; pCmdLine = at_cmdLine; atHead[1] = 0x00; } else if(temp == '\n') //only get enter { uart0_sendStr("\r\nError\r\n"); } break; case at_statRecving: //push receive data to cmd line *pCmdLine = temp; if(temp == '\n') { system_os_post(at_procTaskPrio, 0, 0); at_state = at_statProcess; if(echoFlag) { uart0_sendStr("\r\n"); /////////// } } else if(pCmdLine >= &at_cmdLine[at_cmdLenMax - 1]) { at_state = at_statIdle; } pCmdLine++; break; case at_statProcess: //process data if(temp == '\n') { // system_os_post(at_busyTaskPrio, 0, 1); uart0_sendStr("\r\nbusy p...\r\n"); } break; case at_statIpSending: *pDataLine = temp; if((pDataLine >= &at_dataLine[at_sendLen - 1]) || (pDataLine >= &at_dataLine[at_dataLenMax - 1])) { system_os_post(at_procTaskPrio, 0, 0); at_state = at_statIpSended; } pDataLine++; // *pDataLine = temp; // if (pDataLine == &UartDev.rcv_buff.pRcvMsgBuff[at_sendLen-1]) // { // system_os_post(at_procTaskPrio, 0, 0); // at_state = at_statIpSended; // } // pDataLine++; break; case at_statIpSended: //send data if(temp == '\n') { // system_os_post(at_busyTaskPrio, 0, 2); uart0_sendStr("busy s...\r\n"); } break; case at_statIpTraning: os_timer_disarm(&at_delayChack); // *pDataLine = temp; if(pDataLine > &at_dataLine[at_dataLenMax - 1]) { os_printf("exceed\r\n"); return; } else if(pDataLine == &at_dataLine[at_dataLenMax - 1]) { temp = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF; *pDataLine = temp; pDataLine++; at_tranLen++; os_timer_arm(&at_delayChack, 1, 0); return; } else { temp = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF; *pDataLine = temp; pDataLine++; at_tranLen++; // if(ipDataSendFlag == 0) // { // os_timer_arm(&at_delayChack, 20, 0); // } os_timer_arm(&at_delayChack, 20, 0); } break; // os_timer_disarm(&at_delayChack); // *pDataLine = temp; // if(pDataLine >= &at_dataLine[at_dataLenMax - 1]) // { //// ETS_UART_INTR_DISABLE(); //// pDataLine++; // at_tranLen++; //// os_timer_arm(&at_delayChack, 1, 0); ///// // system_os_post(at_procTaskPrio, 0, 0); // break; // } // pDataLine++; // at_tranLen++; // if(ipDataSendFlag == 0) // { // os_timer_arm(&at_delayChack, 20, 0); // } // break; default: if(temp == '\n') { } break; } } if(UART_RXFIFO_FULL_INT_ST == (READ_PERI_REG(UART_INT_ST(UART0)) & UART_RXFIFO_FULL_INT_ST)) { WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_FULL_INT_CLR); } else if(UART_RXFIFO_TOUT_INT_ST == (READ_PERI_REG(UART_INT_ST(UART0)) & UART_RXFIFO_TOUT_INT_ST)) { WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_TOUT_INT_CLR); } ETS_UART_INTR_ENABLE(); }
void ICACHE_FLASH_ATTR uart0_write_char(char c) { //if (c == '\n') uart_tx_one_char(UART0, '\r'); uart_tx_one_char(UART0, c); }
void roomba_send_command(char command){ uart_tx_one_char(command); os_delay_us(1000); }