daniel-p-carvalho opened a new pull request, #20449:
URL: https://github.com/apache/nuttx/pull/20449
## Summary
* `arch/mips/pic32mz: do not exceed the requested SPI frequency.`
`spi_setfrequency()` rounded the baud rate divisor down, so the SCK
frequency could be higher than the one requested by the device driver
(e.g. 20 MHz requested with a 100 MHz PBCLK2 gave 25 MHz). A request above
PBCLK/2 gave a zero divisor and a division by zero when computing the
actual frequency; the SST26 driver's default of 64 MHz does that with any
peripheral bus clock below 128 MHz. The divisor is now rounded up.
* `arch/mips/pic32mz: fix nxstyle issues in pic32mz_i2c.c and pic32mz_spi.c.`
and `arch/mips/pic32mz: fix nxstyle issues in pic32mz_serial.c.`
Pre-existing nxstyle errors (mostly switch/case indentation), fixed so that
later changes to these files pass checkpatch. No functional change
(`git show -w` shows only comment re-wrapping, one wrapped call and blank
lines after declarations).
These changes were found while porting NuttX to the PIC32MZ-W1 (draft PR
#20448), which needs to modify these files.
## Impact
* SPI on PIC32MZ: the actual SCK frequency never exceeds the requested one.
Boards whose requested frequency is not an exact divisor of PBCLK/2 now
run SPI at a lower clock than before (e.g. 16.7 MHz instead of 25 MHz for a
20 MHz request with a 100 MHz PBCLK2). Requests above PBCLK/2 now give
PBCLK/2 instead of a division by zero.
* Style commits: no functional change.
* No new Kconfig options, no API changes.
## Testing
* checkpatch: `./tools/checkpatch.sh -c -u -m -g upstream/master..HEAD`
passes.
* Build (Pinguino p32-gcc 4.9.2, as in CI): `pic32mz-starterkit:nsh`,
`flipnclick-pic32mz:nxlines` (uses SPI), `chipkit-wifire:nsh`. No new
warnings.
* Hardware: the divisor change was tested on a PIC32MZ-W1 (WFI32E01PE) board
from the port in #20448, reading the JEDEC ID of an SST26VF032B on SPI1
with the driver's default 64 MHz request (25 MHz actual from a 50 MHz
PBCLK3). With the old code that request gives a zero divisor (found by
reading the code, not run). Not tested on PIC32MZ EC/EF hardware.
--
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]