Skip to content

Commit

Permalink
Merge pull request #341 from jepler/esp32-camera-backlight-etc
Browse files Browse the repository at this point in the history
adafruit-camera-esp32s3: make LCD work
  • Loading branch information
hathach committed Jul 26, 2023
2 parents 55aff8d + c4c3a48 commit eaa0c13
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
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

0 comments on commit eaa0c13

Please sign in to comment.