|
ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
|
Interface for the controller module. More...
Functions | |
| void | ControllerInit (void) |
| Shared initialization for all esp32 modules. | |
| void | ControllerDeinit (void) |
| Shared deinitialize for all esp32 modules. | |
| void | ControllerWakeup (void) |
| Trigger esp32 wakeup pin. | |
| void | ControllerDeviceReset (void) |
| Resets the controller interface. | |
| enum | ControllerStatus { CONTROLLER_SUCCESS = 0 , CONTROLLER_ERROR , CONTROLLER_TIMEOUT , CONTROLLER_MUTEX } |
| ControllerStatus | ControllerTransmit (void) |
| Send bytes to esp32. | |
| ControllerStatus | ControllerReceive (void) |
| Receive bytes from esp32. | |
| ControllerStatus | ControllerTransaction (void) |
| Send message and receive response from esp32. | |
| Buffer * | ControllerTx (void) |
| Get reference to transmit buffer. | |
| Buffer * | ControllerRx (void) |
| Get reference to receive buffer. | |
Interface for the controller module.
| enum ControllerStatus |
| Enumerator | |
|---|---|
| CONTROLLER_SUCCESS | Success |
| CONTROLLER_ERROR | General error |
| CONTROLLER_TIMEOUT | Timeout for i2c functions |
| CONTROLLER_MUTEX | For mutex violations |
Definition at line 26 of file communication.h.
| void ControllerDeinit | ( | void | ) |
Shared deinitialize for all esp32 modules.
Free memory associated with the tx and rx buffers.
Definition at line 41 of file controller.c.
References ControllerRx(), ControllerTx(), Buffer::data, Buffer::len, and Buffer::size.
Referenced by main().
| void ControllerDeviceReset | ( | void | ) |
Resets the controller interface.
Toggles the enable pin for the esp32.
100ms delay between off and on seems to be sufficient.
A delay is necessary to give the ESP32 enough time to initialize. Not recommended to go below 500 ms. ESP32 may fail to receive a subsequent command when there is <500 ms delay between ESP32_EN being enabled and the next I2C transaction with the ESP32.
Definition at line 70 of file controller.c.
Referenced by main().
| void ControllerInit | ( | void | ) |
Shared initialization for all esp32 modules.
Allocates memory to the tx and rx buffers.
Definition at line 14 of file controller.c.
References ControllerRx(), ControllerTx(), Buffer::data, Buffer::len, and Buffer::size.
Referenced by main().
| ControllerStatus ControllerReceive | ( | void | ) |
Receive bytes from esp32.
Definition at line 101 of file communication.c.
References CONTROLLER_ERROR, CONTROLLER_SUCCESS, Buffer::data, Buffer::len, and Buffer::size.
Referenced by ControllerTransaction().
| Buffer * ControllerRx | ( | void | ) |
Get reference to receive buffer.
Buffers needs to first be initialized with ControllerInit().
Definition at line 189 of file communication.c.
Referenced by ControllerDeinit(), ControllerInit(), ControllerMicroSDLog(), ControllerMicroSDSave(), ControllerMicroSDUserConfig(), ControllerUserConfigRequest(), ControllerUserConfigSend(), ControllerUserConfigStart(), IrrigationCommandTransaction(), PowerCommandTransaction(), and WiFiCommandTransaction().
| ControllerStatus ControllerTransaction | ( | void | ) |
Send message and receive response from esp32.
| timeout | Timeout duration in ms |
Definition at line 172 of file communication.c.
References CONTROLLER_SUCCESS, ControllerReceive(), and ControllerTransmit().
Referenced by ControllerMicroSDLog(), ControllerMicroSDSave(), ControllerMicroSDUserConfig(), ControllerUserConfigRequest(), ControllerUserConfigSend(), ControllerUserConfigStart(), IrrigationCommandTransaction(), PowerCommandTransaction(), and WiFiCommandTransaction().
| ControllerStatus ControllerTransmit | ( | void | ) |
Send bytes to esp32.
Definition at line 42 of file communication.c.
References CONTROLLER_ERROR, CONTROLLER_SUCCESS, ControllerWakeupEsp32(), Buffer::data, Buffer::len, and Buffer::size.
Referenced by ControllerTransaction().
| Buffer * ControllerTx | ( | void | ) |
Get reference to transmit buffer.
Buffers needs to first be initialized with ControllerInit().
Definition at line 187 of file communication.c.
Referenced by ControllerDeinit(), ControllerInit(), ControllerMicroSDLog(), ControllerMicroSDSave(), ControllerMicroSDUserConfig(), ControllerUserConfigRequest(), ControllerUserConfigSend(), ControllerUserConfigStart(), IrrigationCommandTransaction(), PowerCommandTransaction(), and WiFiCommandTransaction().
| void ControllerWakeup | ( | void | ) |
Trigger esp32 wakeup pin.
After this function is called and the controller is initialized with ControllerInit(), the function ControllerPowerWakeup() should be used to check that the esp32 has correctly woken up.
Since this is blocking code, a small internal delay is added for the startup time on the esp32.
Definition at line 60 of file controller.c.