RetroBSD

2.11BSD operating system for microcontrollers
It is currently Sun Mar 29, 2020 9:12 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: SPI Development
PostPosted: Mon Dec 28, 2015 10:28 pm 
User avatar

Joined: Fri Mar 06, 2015 9:13 pm
Posts: 37
Location: Barcelona, SP
Based on sample of Mr. Pito from RetroBSD i make simple test for the spi
on the Whitecat X1 we have two free spi spi2 and spi4 I used spi4 for the test

Code:
spi1 at pins sdi=RD2/sdo=RD3/sck=RD1
spi2 at pins sdi=RG7/sdo=RG8/sck=RG6
spi3 at pins sdi=RB10/sdo=RB9/sck=RB14
spi4 at pins sdi=RD11/sdo=RD0/sck=RD10


This is the code I placed 16Mhz and use saleae analizer but not activity on the spi. I think code is correct.....

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/spi.h>

static int spi;                         // SPI driver descriptor
#define SPI_DEVNAME         "/dev/spi4" // analizer connected here
#define SPI_KHZ             16000       // Clock speed 16 MHz
#define SPI_SELPIN          0x0049      // select pin RD9

int main(){

        int i = 0;
        spi = open (SPI_DEVNAME, O_RDWR);
        if (spi < 0) {
                perror (SPI_DEVNAME);
                exit (-1);
        }

//      ioctl (spi, SPICTL_SETMODE, 0);
        ioctl (spi, SPICTL_SETRATE, SPI_KHZ);
        ioctl (spi, SPICTL_SETSELPIN, SPI_SELPIN);

        while(i < 100) {
                printf("START...\r\n");
                ioctl (spi, SPICTL_IO8(1), 0xff);
                printf("...STOP\r\n");
                i++;
        }
        close(spi);
        exit(0);

}


The idea is to implement code to use this LoRa module

http://www.semtech.com/wireless-rf/rf-transceivers/sx1276/

_________________
Dennis MacAlistair Ritchie (Sep.09.1941 - Oct.12.2011)


Top
 Profile  
 
 Post subject: Re: SPI Development
PostPosted: Wed Dec 30, 2015 8:21 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Did you enable the spi4 in the board config?
You have to recompile and reflash the kernel.
That is not easy however.
Easy way is you delete your_board directory in "../LiteBSD/sys/compile/your_board" and run "bmake kernel" from top.
You will get your board's directory back. Reflash the vmunix.hex from the board's dir then.
Doublecheck the timestamp of the vmunix.hex, must be the latest after the kernel build.

Interesting chip, indeed:
The SX1276/77/78/79 transceivers feature the LoRa® long range modem that provides ultra-long range spread spectrum communication and high interference immunity whilst minimizing current consumption.
Any experience with it?

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
 Post subject: Re: SPI Development
PostPosted: Wed Dec 30, 2015 10:27 pm 
User avatar

Joined: Fri Mar 06, 2015 9:13 pm
Posts: 37
Location: Barcelona, SP
Pito wrote:
Did you enable the spi4 in the board config?
You have to recompile and reflash the kernel.


Yes Pito, was enabled you can look at the top of the first post this message comes from the boot...

Sure it will works sd card it's working (also fine at 25Mbit/sec) then I hope the driver too is ok, will look maybe to the driver itself when have a little time....

We got some modules from Microchip RN2483 inside pic18lf46k22 with SX1276 we need to manage power consumption and we are developing some nodes with LF series and sleep all the time.

On the microchip nanowatt XLP calculator does not appear PIC32 series why :lol: :lol: :lol: ??

They are projects for the comming year at the moment on the development stage, looking for old cheap GSM big antennas will be interesting too, hope will increase the range and works fine....

The good thing will be when be available in small quantity the SX1301 or out of the LoRa® Alliance members, then make LiteBSD LoRa® gateway will be nice due to small traffic, etc....

Cheers Pito and Merry Christmas and Happy New Year !!

_________________
Dennis MacAlistair Ritchie (Sep.09.1941 - Oct.12.2011)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron




Powered by phpBB® Forum Software © phpBB Group

BSD Daemon used with permission