worked on SPI, fixed some bugs

adjusted LCD code
added code for INA3221
worked on UI
This commit is contained in:
2020-06-24 21:28:44 +02:00
parent 6dfce7803a
commit ccd7f119d3
11 changed files with 258 additions and 88 deletions

View File

@@ -51,7 +51,7 @@ private:
buscfg.sclk_io_num = PIN_NUM_CLK;
buscfg.quadwp_io_num = -1;
buscfg.quadhd_io_num = -1;
buscfg.max_transfer_sz = MAX_LEN;//320*240*2;
buscfg.max_transfer_sz = MAX_LEN;
buscfg.flags = 0;
buscfg.intr_flags = 0;
@@ -80,9 +80,12 @@ public:
void write(const uint8_t* data, size_t len) {
spi_transaction_t t;
memset(&t, 0, sizeof(spi_transaction_t));
while(len > 0) {
// ensure the transaction is reset to defaults.
// this is mandatory! as the ESP adjusts some parameters while/after sending!
memset(&t, 0, sizeof(spi_transaction_t));
const size_t chunkLen = min(MAX_LEN, (len));
t.length = 8 * chunkLen; // in bits
@@ -136,6 +139,23 @@ public:
}
/** send 4 bytes onto the bus while reading 4 bytes response */
uint8_t readWriteByte(uint8_t write) {
spi_transaction_t t;
memset(&t, 0, sizeof(spi_transaction_t));
t.length = 8*1;
t.rxlength = 8*1;
t.tx_data[0] = (write >> 0) & 0xFF;
t.flags = SPI_TRANS_USE_RXDATA | SPI_TRANS_USE_TXDATA;
esp_err_t ret = spi_device_polling_transmit(spi, &t);
ESP_ERROR_CHECK(ret);
return (static_cast<uint32_t>(t.rx_data[0]));
}
/** send 4 bytes onto the bus while reading 4 bytes response */
uint32_t readWriteQuad(uint32_t write) {
@@ -220,6 +240,10 @@ public:
ESP_ERROR_CHECK(ret);
}
static size_t min(size_t a, size_t b) {
return (a < b) ? a : b;
}