uart.h: Add uart_get_baud/uart_set_baud functions, change default baud rate from 74906 to 115200
This commit is contained in:
parent
707d0ed981
commit
3ceadfc0a6
14 changed files with 18 additions and 42 deletions
|
@ -16,8 +16,8 @@
|
|||
#include "common_macros.h"
|
||||
#include "xtensa_ops.h"
|
||||
#include "esp/rom.h"
|
||||
#include "esp/uart.h"
|
||||
#include "esp/iomux_regs.h"
|
||||
#include "esp/uart_regs.h"
|
||||
#include "esp/spi_regs.h"
|
||||
#include "esp/dport_regs.h"
|
||||
#include "esp/wdev_regs.h"
|
||||
|
@ -30,7 +30,6 @@
|
|||
|
||||
void user_init(void);
|
||||
|
||||
#define UART_DIVISOR 1068 // 74906 bps (yeah, I don't understand it either)
|
||||
#define BOOT_INFO_SIZE 28
|
||||
//TODO: phy_info should probably be a struct (no idea about its organization, though)
|
||||
#define PHY_INFO_SIZE 128
|
||||
|
@ -293,8 +292,8 @@ static void init_networking(uint8_t *phy_info, uint8_t *mac_addr) {
|
|||
printf("FATAL: sdk_register_chipv6_phy failed");
|
||||
halt();
|
||||
}
|
||||
sdk_uart_div_modify(0, UART_DIVISOR);
|
||||
sdk_uart_div_modify(1, UART_DIVISOR);
|
||||
uart_set_baud(0, 115200);
|
||||
uart_set_baud(1, 115200);
|
||||
sdk_phy_disable_agc();
|
||||
sdk_ieee80211_phy_init(sdk_g_ic.s.phy_mode);
|
||||
sdk_lmacInit();
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "esp/types.h"
|
||||
#include "esp/uart_regs.h"
|
||||
#include "esp/clocks.h"
|
||||
|
||||
#define UART_FIFO_MAX 127
|
||||
|
||||
|
@ -110,4 +111,17 @@ static inline void uart_flush_rxfifo(int uart_num) {
|
|||
uart_clear_rxfifo(uart_num);
|
||||
}
|
||||
|
||||
/* Set uart baud rate to the desired value */
|
||||
static inline void uart_set_baud(int uart_num, int bps)
|
||||
{
|
||||
uint32_t divider = APB_CLK_FREQ / bps;
|
||||
UART(uart_num).CLOCK_DIVIDER = divider;
|
||||
}
|
||||
|
||||
/* Returns the current baud rate for the UART */
|
||||
static inline int uart_get_baud(int uart_num)
|
||||
{
|
||||
return APB_CLK_FREQ / FIELD2VAL(UART_CLOCK_DIVIDER_VALUE, UART(uart_num).CLOCK_DIVIDER);
|
||||
}
|
||||
|
||||
#endif /* _ESP_UART_H */
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* This sample code is in the public domain.
|
||||
*/
|
||||
#include "espressif/esp_common.h"
|
||||
#include "espressif/sdk_private.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "esp8266.h"
|
||||
|
@ -53,7 +52,6 @@ void blinkenRegisterTask(void *pvParameters)
|
|||
|
||||
void user_init(void)
|
||||
{
|
||||
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
|
||||
xTaskCreate(blinkenTask, (signed char *)"blinkenTask", 256, NULL, 2, NULL);
|
||||
//xTaskCreate(blinkenRegisterTask, (signed char *)"blinkenRegisterTask", 256, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* This sample code is in the public domain.
|
||||
*/
|
||||
#include "espressif/esp_common.h"
|
||||
#include "espressif/sdk_private.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "esp8266.h"
|
||||
|
@ -33,8 +32,6 @@ void frc2_interrupt_handler(void)
|
|||
|
||||
void user_init(void)
|
||||
{
|
||||
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
|
||||
|
||||
/* configure GPIOs */
|
||||
gpio_enable(gpio_frc1, GPIO_OUTPUT);
|
||||
gpio_enable(gpio_frc2, GPIO_OUTPUT);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* This sample code is in the public domain.
|
||||
*/
|
||||
#include "espressif/esp_common.h"
|
||||
#include "espressif/sdk_private.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
@ -83,22 +82,9 @@ void bmp180_task(void *pvParameters)
|
|||
}
|
||||
}
|
||||
|
||||
// Setup HW
|
||||
void user_setup(void)
|
||||
{
|
||||
// Set UART Parameter
|
||||
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
|
||||
|
||||
// Give the UART some time to settle
|
||||
sdk_os_delay_us(500);
|
||||
}
|
||||
|
||||
void user_init(void)
|
||||
{
|
||||
// Setup HW
|
||||
user_setup();
|
||||
|
||||
// Just some infomations
|
||||
// Just some informations
|
||||
printf("\n");
|
||||
printf("SDK version : %s\n", sdk_system_get_sdk_version());
|
||||
printf("GIT version : %s\n", GITSHORTREV);
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
* This sample code is in the public domain.
|
||||
*/
|
||||
#include "espressif/esp_common.h"
|
||||
#include "espressif/sdk_private.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
@ -75,7 +74,6 @@ void GPIO_HANDLER(void)
|
|||
|
||||
void user_init(void)
|
||||
{
|
||||
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
|
||||
gpio_enable(gpio, GPIO_INPUT);
|
||||
|
||||
tsqueue = xQueueCreate(2, sizeof(uint32_t));
|
||||
|
|
|
@ -94,8 +94,6 @@ esp_open_rtos::thread::queue_t<uint32_t> MyQueue;
|
|||
*/
|
||||
extern "C" void user_init(void)
|
||||
{
|
||||
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
|
||||
|
||||
MyQueue.queue_create(10);
|
||||
|
||||
task_1.queue = MyQueue;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
* This experimental reverse engineering code is in the public domain.
|
||||
*/
|
||||
#include "espressif/esp_common.h"
|
||||
#include "espressif/sdk_private.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "esp8266.h"
|
||||
|
@ -118,7 +117,6 @@ void frc2_handler(void)
|
|||
|
||||
void user_init(void)
|
||||
{
|
||||
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
|
||||
xTaskCreate(timerRegTask, (signed char *)"timerRegTask", 1024, NULL, 2, NULL);
|
||||
|
||||
TIMER(0).CTRL = VAL2FIELD(TIMER_CTRL_CLKDIV, TIMER_CLKDIV_256) | TIMER_CTRL_RELOAD;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "esp/rom.h"
|
||||
#include "esp/timer.h"
|
||||
#include "espressif/esp_common.h"
|
||||
#include "espressif/sdk_private.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
@ -214,8 +213,6 @@ void sanity_tests(void);
|
|||
|
||||
void user_init(void)
|
||||
{
|
||||
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
|
||||
|
||||
gpio_enable(2, GPIO_OUTPUT); /* used for LED debug */
|
||||
gpio_write(2, 1); /* active low */
|
||||
|
||||
|
|
|
@ -114,7 +114,6 @@ void http_get_task(void *pvParameters)
|
|||
|
||||
void user_init(void)
|
||||
{
|
||||
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
|
||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||
|
||||
struct sdk_station_config config = {
|
||||
|
|
|
@ -331,7 +331,6 @@ void http_get_task(void *pvParameters)
|
|||
|
||||
void user_init(void)
|
||||
{
|
||||
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
|
||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||
|
||||
struct sdk_station_config config = {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
* NOT SUITABLE TO PUT ON THE INTERNET OR INTO A PRODUCTION ENVIRONMENT!!!!
|
||||
*/
|
||||
#include "espressif/esp_common.h"
|
||||
#include "espressif/sdk_private.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "esp8266.h"
|
||||
|
@ -18,8 +17,6 @@
|
|||
|
||||
void user_init(void)
|
||||
{
|
||||
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
|
||||
|
||||
rboot_config_t conf = rboot_get_config();
|
||||
printf("\r\n\r\nOTA Basic demo.\r\nCurrently running on flash slot %d / %d.\r\n\r\n",
|
||||
conf.current_rom, conf.count);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* Very basic example that just demonstrates we can run at all!
|
||||
*/
|
||||
#include "espressif/esp_common.h"
|
||||
#include "espressif/sdk_private.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
@ -36,7 +35,6 @@ static xQueueHandle mainqueue;
|
|||
|
||||
void user_init(void)
|
||||
{
|
||||
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
|
||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||
mainqueue = xQueueCreate(10, sizeof(uint32_t));
|
||||
xTaskCreate(task1, (signed char *)"tsk1", 256, &mainqueue, 2, NULL);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
This sample code is in the public domain.
|
||||
*/
|
||||
#include "espressif/esp_common.h"
|
||||
#include "espressif/sdk_private.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
@ -58,7 +57,6 @@ void task1(void *pvParameters)
|
|||
|
||||
extern "C" void user_init(void)
|
||||
{
|
||||
sdk_uart_div_modify(0, UART_CLK_FREQ / 115200);
|
||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||
xTaskCreate(task1, (signed char *)"tsk1", 256, NULL, 2, NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue