Hi Ed On 7/11/23, Ed Sutter <edsutte...@gmail.com> wrote: > On 7/11/2023 2:00 PM, Alan C. Assis wrote: >> Hi Ed, >> >> Are you the Ed Sutter from uMon bootloader author? >> >> On 7/11/23, Ed Sutter<edsutte...@gmail.com> wrote: >>> Hi, >>> Are there any examples of application code accessing a SPI device on >>> Nuttx? >>> Thanks, >> Normally NuttX applications don't access the SPI Bus directly, an SPI >> device needs to be exported through the driver implementing its >> function, so an SPI temperature sensor will create a /dev/temp0, an >> SPI light sensor will create a /dev/light0, etc. >> >> Exception to this is when you want to test the SPI Bus directly using >> the SPI Tool (similar to I2C Tool idea), in this case you have to >> enable CONFIG_SPI_DRIVER and >> CONFIG_SYSTEM_SPITOOL (look at apps/system/spi). >> >> BR, >> >> Alan > Alan, > Ok, so I can use apps/system/spi for basic SPI interface testing. Now I'm > trying to digest > your first paragraph... I assume the same applies to I2C, is that true? > The actual interface > is transparent to the application because there's a functional layer between > them, correct? > Assuming that is the case, is there an example snippet of code (I2C or SPI, > doesn't matter) that > exports the function to the application?
There are thousands of them on NuttX, but I think the simple examples to get the idea are the sensor drivers (I2C/SPI) : $ ls drivers/sensors/ adt7320.c bh1749nuc.c hts221.c lm75.c mcp9844.c sensor_rpmsg.c adt7320.h bh1750fvi.c hyt271.c lm92.c mlx90393.c sgp30.c adxl345_base.c bmg160.c ina219.c lps25h.c mlx90614.c sht21.c adxl345.h bmi160.c ina226.c lsm303agr.c mpl115a.c sht3x.c adxl345_i2c.c bmi270.c ina3221.c lsm330_spi.c mpu60x0.c sps30.c adxl345_spi.c bmp180.c isl29023.c lsm6dsl.c mpu9250.c t67xx.c adxl372.c bmp280.c Kconfig lsm9ds1.c ms5611.c usensor.c aht10.c dhtxx.c kxtj9.c ltc4151.c ms58xx.c veml6070.c ak09912.c ds18b20.c l3gd20.c ltr308.c msa301.c vl53l1x.c apds9922.c fakesensor.c lis2dh.c Make.defs wtgahrs2.c apds9960.c fxos8700cq.c lis331dl.c max31855.c xen1210.c as5048a.c hall3ph.c lis3dh.c max44009.c scd30.c xen1210.h as5048b.c hc_sr04.c lis3dsh.c max6675.c scd41.c as726x.c hdc1008.c lis3mdl.c mb7040.c sensor.c Think of NuttX like a Unix system, where (*almost*) everything is a file. So, the application will read data from sensors reading i.e. /dev/temp0 BR, Alan