-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/embedded'
- Loading branch information
Showing
15 changed files
with
498 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
tools/venv/* | ||
|
||
.idea |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "edstream.h" | ||
#include "edstream_hal.h" | ||
|
||
#include <ssd1306.h> | ||
|
||
#define LOG_LOCAL_LEVEL ESP_LOG_ERROR | ||
#include "esp_log.h" | ||
|
||
void receiver(void *pvParameters) | ||
{ | ||
struct eds_hal_config eds_hal_conf = eds_hal_default(); | ||
eds_hal_init(&eds_hal_conf); | ||
|
||
ssd1306_128x64_i2c_init(); | ||
|
||
ssd1306_clearScreen(); | ||
|
||
uint8_t cmd[512]; | ||
int read; | ||
|
||
while(true) { | ||
vTaskDelay(1); | ||
read = eds_hal_recv(cmd, 512); | ||
if (read <= 0) continue; | ||
ESP_LOGD("RX", "Read bytes: %d", read); | ||
eds_decode_message(cmd, read); | ||
} | ||
|
||
vTaskDelete(NULL); | ||
} | ||
|
||
void app_main() | ||
{ | ||
xTaskCreate(receiver, "receiver", 8192, NULL, 0, NULL); // Yep, this is a huge amount of memory | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* EDStream HAL implementation | ||
* (c) 2021 - Project EDStream | ||
* | ||
* ESP32 I2C_0 and UART_0 | ||
*/ | ||
|
||
#include "edstream_hal.h" | ||
|
||
#define LOG_LOCAL_LEVEL ESP_LOG_NONE | ||
#include "esp_log.h" | ||
#include "ssd1306.h" | ||
#include "driver/uart.h" | ||
|
||
static struct eds_hal_config configuration; | ||
|
||
static uint8_t uart_num_mem; | ||
static QueueHandle_t queue_handle; | ||
|
||
void eds_hal_init(const struct eds_hal_config *config) { | ||
|
||
configuration = *config; | ||
|
||
// I2C | ||
ssd1306_platform_i2cConfig_t cfg = { | ||
.sda = config->i2c_pins.sda, | ||
.scl = config->i2c_pins.scl | ||
}; | ||
ssd1306_platform_i2cInit(config->i2c_num, 0, &cfg); | ||
|
||
// UART | ||
ESP_ERROR_CHECK(uart_param_config(config->uart_num, &(config->uart_conf))); | ||
ESP_ERROR_CHECK(uart_set_pin(config->uart_num, config->uart_pins.tx, config->uart_pins.rx, config->uart_pins.rts, config->uart_pins.cts)); | ||
ESP_ERROR_CHECK(uart_driver_install(config->uart_num, config->uart_buf_size, config->uart_buf_size, 10, &queue_handle, 0)); | ||
uart_num_mem = config->uart_num; | ||
} | ||
|
||
int eds_hal_send_byte(uint8_t x) { | ||
return eds_hal_send(&x, 1); | ||
} | ||
|
||
int eds_hal_send(const uint8_t *src, int n) { | ||
size_t res = uart_write_bytes(uart_num_mem, (const char*) src, n); | ||
uart_wait_tx_done(uart_num_mem, 100); // timeout of 100 ticks | ||
return res; | ||
} | ||
|
||
int eds_hal_recv(uint8_t *dst, int n) { | ||
return uart_read_bytes(UART_NUM_0, dst, n, 100 / portTICK_RATE_MS); | ||
} | ||
|
||
int eds_hal_display_show(const uint8_t *frame) { | ||
ssd1306_drawBuffer(0, 0, OLED_W, OLED_H, frame); | ||
return 0; | ||
} |
Oops, something went wrong.