Skip to content
Open
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
2 changes: 1 addition & 1 deletion drivers/gpio/gpio_aw9523b.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ static int gpio_aw9523b_init(const struct device *dev)
return err;
}

if (!config->port0_push_pull) {
if (config->port0_push_pull) {
/* Configure port0 to push-pull mode */
err = i2c_reg_update_byte_dt(&config->i2c, AW9523B_REG_CTL, AW9523B_GPOMD, 0xFF);
if (err) {
Expand Down
11 changes: 9 additions & 2 deletions drivers/spi/spi_esp32_spim.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,10 @@ static int IRAM_ATTR spi_esp32_configure(const struct device *dev,

ctx->config = spi_cfg;

if (spi_cfg->operation & SPI_HALF_DUPLEX) {
LOG_ERR("Half-duplex not supported");
bool request_half_duplex = (spi_cfg->operation & SPI_HALF_DUPLEX) != 0U;

if (request_half_duplex && !cfg->half_duplex) {
LOG_ERR("Half-duplex requested but not enabled in devicetree");
return -ENOTSUP;
}

Expand All @@ -435,6 +437,9 @@ static int IRAM_ATTR spi_esp32_configure(const struct device *dev,
return ret;
}

hal_dev->half_duplex = cfg->half_duplex || request_half_duplex;
hal_dev->sio = cfg->sio && hal_dev->half_duplex;

/* input parameters to calculate timing configuration */
spi_hal_timing_param_t timing_param = {
.half_duplex = hal_dev->half_duplex,
Expand Down Expand Up @@ -663,6 +668,8 @@ static DEVICE_API(spi, spi_api) = {
.dma_enabled = DT_INST_PROP(idx, dma_enabled), \
.dma_host = DT_INST_PROP(idx, dma_host), \
SPI_DMA_CFG(idx), \
.half_duplex = DT_INST_PROP(idx, half_duplex), \
.sio = DT_INST_PROP(idx, sio), \
.cs_setup = DT_INST_PROP_OR(idx, cs_setup_time, 0), \
.cs_hold = DT_INST_PROP_OR(idx, cs_hold_time, 0), \
.line_idle_low = DT_INST_PROP(idx, line_idle_low), \
Expand Down
2 changes: 2 additions & 0 deletions drivers/spi/spi_esp32_spim.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ struct spi_esp32_config {
#else
int dma_clk_src;
#endif
bool half_duplex;
bool sio;
int cs_setup;
int cs_hold;
bool line_idle_low;
Expand Down
11 changes: 11 additions & 0 deletions samples/boards/espressif/m5stack_cores3_spi_lcd_raw/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.20.0)

set(DTC_OVERLAY_FILE boards/m5stack_cores3.overlay)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(m5stack_cores3_spi_lcd_raw)

zephyr_include_directories(${ZEPHYR_BASE}/drivers)

target_sources(app PRIVATE src/main.c)
target_include_directories(app PRIVATE ${ZEPHYR_BASE} ${ZEPHYR_BASE}/drivers)
40 changes: 40 additions & 0 deletions samples/boards/espressif/m5stack_cores3_spi_lcd_raw/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.. _m5stack_cores3_spi_lcd_raw:

M5Stack CoreS3 raw SPI LCD sample
=================================

Overview
--------

This sample shows how to talk to the ILI9342C based display that is fitted to
M5Stack CoreS3 without using Zephyr's display drivers. It enables the
Espressif SPI controller 3-wire mode so that 9-bit transfers (command bit plus
8 data bits) can be issued directly. After a minimal initialization sequence a
simple RGB gradient is written to the screen to demonstrate how to pack the
command/data bit into the transmit stream.

Requirements
------------

* `M5Stack CoreS3 <https://docs.m5stack.com/en/core/CoreS3>`_

Building and running
--------------------

Use the following command to build and flash the sample::

west build -b m5stack_cores3/esp32s3/procpu \
samples/boards/espressif/m5stack_cores3_spi_lcd_raw --pristine
west flash

After programming the board and resetting it the display should shortly show a
full-screen colour gradient and the console will print status messages similar
to::

*** Booting Zephyr OS build v3.x.x ***
[00:00:00.025,000] <inf> spi_lcd_raw: Resetting LCD
[00:00:00.320,000] <inf> spi_lcd_raw: Drawing gradient
[00:00:00.750,000] <inf> spi_lcd_raw: Gradient complete

The SD card slot is disabled by the sample overlay while the display is driven
in half-duplex 3-wire mode.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
&spi2 {

Check warning on line 1 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

Copyright missing

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:1 File has no SPDX-FileCopyrightText header, consider adding one.

Check warning on line 1 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

License missing

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:1 File has no SPDX-License-Identifier header, consider adding one.
status = "okay";
half-duplex;
sio;
use-iomux;
dummy-comp;
clock-frequency = <40000000>;

lcd_spi: display@0 {

Check failure on line 9 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:9 code indent should use tabs where possible
compatible = "zephyr,spi-device";

Check warning on line 10 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:10 please, no spaces at the start of a line

Check failure on line 10 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:10 code indent should use tabs where possible
reg = <0>;

Check warning on line 11 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:11 please, no spaces at the start of a line

Check failure on line 11 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:11 code indent should use tabs where possible
spi-max-frequency = <40000000>;

Check warning on line 12 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:12 please, no spaces at the start of a line

Check failure on line 12 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:12 code indent should use tabs where possible
spi-interframe-delay-ns = <0>;

Check warning on line 13 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:13 please, no spaces at the start of a line

Check failure on line 13 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:13 code indent should use tabs where possible
status = "okay";

Check warning on line 14 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:14 please, no spaces at the start of a line

Check failure on line 14 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:14 code indent should use tabs where possible
};

Check warning on line 15 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LEADING_SPACE

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:15 please, no spaces at the start of a line

Check failure on line 15 in samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

CODE_INDENT

samples/boards/espressif/m5stack_cores3_spi_lcd_raw/boards/m5stack_cores3.overlay:15 code indent should use tabs where possible
};

&sd0 {
status = "disabled";
};
6 changes: 6 additions & 0 deletions samples/boards/espressif/m5stack_cores3_spi_lcd_raw/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_SPI=y
CONFIG_I2C=y
CONFIG_LOG_MODE_IMMEDIATE=y
14 changes: 14 additions & 0 deletions samples/boards/espressif/m5stack_cores3_spi_lcd_raw/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sample:
description: Raw SPI access to the CoreS3 LCD using 3-wire mode
name: m5stack_cores3_spi_lcd_raw

common:
tags:
- display
- spi

tests:
sample.boards.espressif.m5stack_cores3_spi_lcd_raw:
build_only: true
platform_allow:
- m5stack_cores3/esp32s3/procpu
Loading
Loading