Changeset - a02651c5dd9b
[Not reviewed]
default
0 3 0
Ethan Zonca - 17 months ago 2024-01-15 14:16:47
ez@ethanzonca.com
Add missing includes and update readme
3 files changed with 15 insertions and 3 deletions:
0 comments (0 inline, 0 general)
README.md
Show inline comments
 
# Protofusion ESP32S3 Template
 

	
 
## Configure
 
Set target with `idf.y set-target esp32s3`
 

	
 
Run menuconfig with `idf.py menuconfig` and choose the Protofusion menu option.
 

	
 
Set target with `idf.y set-target esp32s3`
 

	
 
Rename the project by editing CMakeLists.txt and change `project(protofusion_template)` to reflect your project name
 

	
 
Note that clean doesn't always clean everything... do `idf.py fullclean` to make sure all generated files are removed (especially when switching processors).
 

	
 
## Build and Flash
 

	
 
Build the project and flash it to the board, then run monitor tool to view serial output:
 
Build the project
 

	
 
```bash
 
idf.py build
 
```
 

	
 
Flash to board and run monitor tool to view serial output:
 

	
 
```bash
 
idf.py flash monitor
 
```
 

	
 
(To exit the serial monitor, type ``Ctrl-]``.)
 

	
main/can.c
Show inline comments
 
//
 
// can
 
//
 

	
 
#include "can.h"
 
#include "esp_log.h"
 
#include "driver/twai.h"
 
#include "freertos/FreeRTOS.h"
 
#include "freertos/task.h"
 
#include "freertos/event_groups.h"
 

	
 
// EMZ FIXME
 
#define TX_GPIO_NUM 5
 
#define RX_GPIO_NUM 6
 
#define RX_TASK_PRIO 3
 

	
 

	
 
// Private variables
 
static const char *TAG = "canbus";
 

	
 

	
 
// static QueueHandle_t tx_task_queue;
 
// static QueueHandle_t rx_task_queue;
 

	
 

	
 
// Task for receiving CAN messages
 
static void twai_receive_task(void *arg)
 
{
 
    while (1) {
 
        twai_message_t rx_msg;
 
        twai_receive(&rx_msg, portMAX_DELAY);
 
        if (rx_msg.identifier == 0xdead) {
 
            ESP_LOGI(TAG, "Received data ");
 
        }
main/wifi.c
Show inline comments
 
//
 
// wifi
 
//
 

	
 
#include "wifi.h"
 
#include "esp_wifi.h"
 
#include "esp_event.h"
 
#include "esp_log.h"
 
#include "lwip/err.h"
 
#include "lwip/sys.h"
 
#include "display.h"
 

	
 
#include "freertos/FreeRTOS.h"
 
#include "freertos/task.h"
 
#include "freertos/event_groups.h"
 

	
 
// Private variables
 

	
 
// FreeRTOS event group to signal when we are connected
 
static EventGroupHandle_t s_wifi_event_group;
 
static const char *TAG = "wifi station";
 
static int s_retry_num = 0;
 

	
 

	
 
// Handler for wifi events
 
static void __event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data)
 
{
 
    if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
 
        esp_wifi_connect();
 
    }
 
    else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) 
 
    {
 
        if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY) 
 
        {
 
            esp_wifi_connect();
 
            s_retry_num++;
 
            ESP_LOGI(TAG, "retry to connect to the AP");
 
            display_update_text("AP Connect Retry");
 

	
0 comments (0 inline, 0 general)