tmedicci opened a new pull request, #17041:
URL: https://github.com/apache/nuttx/pull/17041
## Summary
* include/nuttx/spi/spi_bitbang: Fix incompatible pointer type issue
This commit fixes the incompatible pointer type issue due to incompatible
types of the `bitexchange_t` callback.
## Impact
Impact on user: Yes. Users can build SPI bitbang driver.
Impact on build: Yes. Fix the `-Wincompatible-pointer-types` warning.
Impact on hardware: No.
Impact on documentation: No.
Impact on security: No.
Impact on compatibility: No.
## Testing
Testing can be performed with any device that supports the SPI bitbang
driver. Taking ESP32-C6 as an example:
### Building
```
make -j distclean && ./tools/configure.sh esp32c6-devkitc:nsh &&
kconfig-tweak -e SPI_DRIVER && kconfig-tweak -e ESPRESSIF_SPI_BITBANG && make
olddefconfig && make flash ESPTOOL_PORT=/dev/ttyUSB0 ESPTOOL_BINDIR=./ -s
-j$(nproc) && picocom -b 115200 /dev/ttyUSB0
```
### Running
The device can boot properly and enable the SPI bitbang peripheral:
```
ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x40800000,len:0x48ec
load:0x408048f0,len:0x7ec
SHA-256 comparison failed:
Calculated: 2bd849e0235a655f626df75c90131908f1c4c5e34b7f97430b3025237b679038
Expected: 00000000e0ae0000000000000000000000000000000000000000000000000000
Attempting to boot anyway...
entry 0x408045bc
pmu_param(dbg): blk_version is less than 3, act dbias not burnt in efuse
*** Booting NuttX ***
dram: lma 0x00000020 vma 0x40800000 len 0x48ec (18668)
dram: lma 0x00004914 vma 0x408048f0 len 0x7ec (2028)
padd: lma 0x00005118 vma 0x00000000 len 0xaee0 (44768)
imap: lma 0x00010000 vma 0x42020000 len 0xb090 (45200)
padd: lma 0x0001b098 vma 0x00000000 len 0x4f60 (20320)
imap: lma 0x00020000 vma 0x42000000 len 0x1de48 (122440)
total segments stored 6
Initializing /dev/spi3...
NuttShell (NSH) NuttX-10.4.0
nsh> ls /dev/
/dev:
console
null
random
spi3
ttyS0
zero
nsh>
```
### Results
The device fails even to build before applying this patch:
#### Before
```
$ make -j distclean && ./tools/configure.sh esp32c6-devkitc:nsh &&
kconfig-tweak -e SPI_DRIVER && kconfig-tweak -e ESPRESSIF_SPI_BITBANG && make
olddefconfig && make flash ESPTOOL_PORT=/dev/ttyUSB0 ESPTOOL_BINDIR=./ -s
-j$(nproc) && picocom -b 115200 /dev/ttyUSB0
...
nuttx/include/nuttx/spi/spi_bitbang.c:255:22: error: assignment to
'bitexchange_t' {aka 'unsigned char (*)(unsigned char, long unsigned int)'}
from incompatible pointer type 'uint16_t (*)(uint16_t, uint32_t)' {aka 'short
unsigned int (*)(short unsigned int, long unsigned int)'}
[-Wincompatible-pointer-types]
255 | priv->exchange = spi_bitexchange0;
```
#### After
The device builds properly and the SPI bitbang device is properly registered
at `/dev/spi3`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]