SPI api example...

2023-07-11 Thread Ed Sutter

Hi,
Are there any examples of application code accessing a SPI device on Nuttx?
Thanks,
Ed



Re: SPI api example...

2023-07-11 Thread Tim Hardisty
On 11/07/2023 18:28, Ed Sutter wrote:
Hi,
Are there any examples of application code accessing a SPI device on Nuttx?
Thanks,
Ed



Plenty - MAX31855 K-type thermocouple interface for example. Look at the 
examples in the  Applications setup within menuconfig.

SPI devices will be accessed via character drivers (for example/dev/ktytpe0).


Re: SPI api example...

2023-07-11 Thread Alan C. Assis
Hi Ed,

Are you the Ed Sutter from uMon bootloader author?

On 7/11/23, Ed Sutter  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


Re: SPI api example...

2023-07-11 Thread Ed Sutter

On 7/11/2023 1:57 PM, Tim Hardisty wrote:

On 11/07/2023 18:28, Ed Sutter wrote:
Hi,
Are there any examples of application code accessing a SPI device on Nuttx?
Thanks,
Ed



Plenty - MAX31855 K-type thermocouple interface for example. Look at the 
examples in the  Applications setup within menuconfig.

SPI devices will be accessed via character drivers (for example/dev/ktytpe0).

Ahhh yes!!!  Thanks!  I was searching for files that used .sndblock.  Woulda been smarter 
to look for files with "SPI" in the name!!!
:-)

Re: SPI api example...

2023-07-11 Thread Ed Sutter

On 7/11/2023 2:00 PM, Alan C. Assis wrote:

Hi Ed,

Are you the Ed Sutter from uMon bootloader author?

Yep.  Hi Alan!
I just finished I2C and used apps/system/i2c as my test.
I'm just getting old I guess... I didn't even notice the spi peer directory 
there.
If it is similar in function to the apps/system/i2c, then that is exactly what 
I'm
looking for.
Thanks


On 7/11/23, Ed Sutter  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


Re: SPI api example...

2023-07-11 Thread Alan C. Assis
Hi Ed,

On 7/11/23, Ed Sutter  wrote:
> On 7/11/2023 2:00 PM, Alan C. Assis wrote:
>> Hi Ed,
>>
>> Are you the Ed Sutter from uMon bootloader author?
> Yep.  Hi Alan!
> I just finished I2C and used apps/system/i2c as my test.

Nice! I2CTools is very useful to verify if the device is in the bus
and also to debug it:

https://acassis.wordpress.com/2020/04/12/using-nuttx-i2c-scan-to-detect-max30100/

> I'm just getting old I guess... I didn't even notice the spi peer directory
> there.

Hehehe, don't worry, we all are getting old, times fly!

> If it is similar in function to the apps/system/i2c, then that is exactly
> what I'm
> looking for.

Yes, this is very similar!

BR,

Alan


Re: [Article] NuttX on RISC-V: Star64 JH7110 SBC

2023-07-11 Thread Venkat Ranganathan
Thanks for the steps.  I got a VisionFive2 8GB board and will try.

Venkat

On Sat, Jul 8, 2023 at 5:24 PM Tomek CEDRO  wrote:
>
> On Sun, Jul 9, 2023 at 1:16 AM Lee, Lup Yuen wrote:
> > In this article we’ll boot a tiny bit of NuttX on the Pine64 Star64 64-bit
> > RISC-V Single-Board Computer. (Based on StarFive JH7110 SoC)
> >
> > Check out the article:
> > https://lupyuen.codeberg.page/articles/nuttx2.html
>
> wow! :-)
>
> --
> CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



-- 
Regards

Venkat


Re: SPI api example...

2023-07-11 Thread Ed Sutter

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  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?
Thanks,
Ed

Re: SPI api example...

2023-07-11 Thread Alan C. Assis
Hi Ed

On 7/11/23, Ed Sutter  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  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.clm75.cmcp9844.c
sensor_rpmsg.c
adt7320.h   bh1750fvi.c   hyt271.clm92.cmlx90393.c  sgp30.c
adxl345_base.c  bmg160.c  ina219.clps25h.c  mlx90614.c  sht21.c
adxl345.h   bmi160.c  ina226.clsm303agr.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.cusensor.c
aht10.c dhtxx.c   kxtj9.c ltc4151.c ms58xx.cveml6070.c
ak09912.c   ds18b20.c l3gd20.cltr308.c  msa301.cvl53l1x.c
apds9922.c  fakesensor.c  lis2dh.cMake.defs wtgahrs2.c
apds9960.c  fxos8700cq.c  lis331dl.c  max31855.cxen1210.c
as5048a.c   hall3ph.c lis3dh.cmax44009.cscd30.c xen1210.h
as5048b.c   hc_sr04.c lis3dsh.c   max6675.c scd41.c
as726x.chdc1008.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