Code: Select all
uart_config_t uart_config = {
.baud_rate = 9600,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 122,
};
uart_param_config(UART_NUM_1, &uart_config);
uart_set_pin(UART_NUM_1, 17, 16, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(UART_NUM_1, BUF_SIZE * 2, 0, 0, NULL, 0);
uint8_t* writeBuf = (uint8_t*) "$PMTK220,10000*2F\r\n";
uart_write_bytes(UART_NUM_1, (const char*)writeBuf, 0);
unsigned char buf[BUF_SIZE];
while(1) {
int size = uart_read_bytes(UART_NUM_1, buf, BUF_SIZE, 1000 / portTICK_RATE_MS);
if (size >0) {
printf("%s", buf);
}
}