Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adafruit-camera-esp32s3: make LCD work #341

Merged
merged 2 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion ports/espressif/boards/adafruit_camera_esp32s3/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@
// Number of neopixels
#define NEOPIXEL_NUMBER 1

//Peripheral power is enabled through I2C connected AW9523
#define I2C_MASTER_SCL_IO 34
#define I2C_MASTER_SDA_IO 33
#define I2C_MASTER_NUM 0
#define I2C_MASTER_FREQ_HZ 400000
#define I2C_MASTER_TX_BUF_DISABLE 0
#define I2C_MASTER_RX_BUF_DISABLE 0
#define I2C_MASTER_TIMEOUT_MS 1000
#define I2C_WAIT 40 //Timing (in microseconds) for I2C


#define AW9523_ADDR (0x5B)
#define AW9523_REG_SOFTRESET (0x7f)
#define AW9523_REG_OUTPUT0 (0x02)
#define AW9523_REG_CONFIG0 (0x04)
#define AW9523_DEFAULT_OUTPUT (0)
#define AW9523_DEFAULT_CONFIG (0x2)

//--------------------------------------------------------------------+
// TFT
//--------------------------------------------------------------------+
Expand All @@ -76,7 +94,7 @@

// Memory Data Access Control & // Vertical Scroll Start Address
#define DISPLAY_MADCTL (TFT_MADCTL_MX | TFT_MADCTL_MY | TFT_MADCTL_MV)
#define DISPLAY_VSCSAD 140
#define DISPLAY_VSCSAD 80

#define DISPLAY_TITLE "AdaCamera"

Expand Down
40 changes: 37 additions & 3 deletions ports/espressif/boards/boards.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void dotstar_init(void);
void dotstar_write(uint8_t const rgb[]);
#endif

#ifdef TCA9554_ADDR
#if defined(TCA9554_ADDR) || defined(AW9523_ADDR)
#include "esp_err.h"
#include "driver/i2c.h"
#endif
Expand Down Expand Up @@ -140,7 +140,7 @@ void app_main(void)
void board_init(void)
{
// Peripheral control through I2C Expander
#ifdef TCA9554_ADDR
#if defined(TCA9554_ADDR) || defined(AW9523_ADDR)
int i2c_num = I2C_MASTER_NUM;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
Expand All @@ -153,6 +153,7 @@ void board_init(void)
i2c_param_config(i2c_num, &conf);
i2c_driver_install(i2c_num, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);

#if defined(TCA9554_ADDR)
// Turn on PERI_POWER that is controlled by TC9554 I2C Expander
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
Expand All @@ -171,10 +172,43 @@ void board_init(void)
i2c_master_stop(cmd);
i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
i2c_driver_delete(i2c_num);

#endif

#if defined(AW9523_ADDR)
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, AW9523_ADDR << 1 | I2C_MASTER_WRITE, true);
i2c_master_write_byte(cmd, AW9523_REG_SOFTRESET, true);
i2c_master_write_byte(cmd, 0, true);
i2c_master_stop(cmd);
i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);

cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, AW9523_ADDR << 1 | I2C_MASTER_WRITE, true);
i2c_master_write_byte(cmd, AW9523_REG_CONFIG0, true);
i2c_master_write_byte(cmd, AW9523_DEFAULT_CONFIG >> 8, true);
i2c_master_write_byte(cmd, AW9523_DEFAULT_CONFIG & 0xff, true);
i2c_master_stop(cmd);
i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);

cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, AW9523_ADDR << 1 | I2C_MASTER_WRITE, true);
i2c_master_write_byte(cmd, AW9523_REG_OUTPUT0, true);
i2c_master_write_byte(cmd, AW9523_DEFAULT_OUTPUT >> 8, true);
i2c_master_write_byte(cmd, AW9523_DEFAULT_OUTPUT & 0xff, true);
i2c_master_stop(cmd);
i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
#endif

i2c_driver_delete(i2c_num);
#endif

#ifdef LED_PIN
ledc_timer_config_t ledc_timer =
{
Expand Down