RetroBSD

2.11BSD operating system for microcontrollers
It is currently Wed Feb 19, 2020 11:31 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Sep 21, 2015 8:51 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
We have got following SPI driver's calles in the spi.c

Code:
/*
 * SPI control operations:
 * - SPICTL_SETMODE   - set clock polarity and phase
 * - SPICTL_SETRATE   - set data rate in kHz
 * - SPICTL_SETSELPIN - set select pin
 * - SPICTL_IO8(n)    - n*8 bit RW transaction
 * - SPICTL_IO16(n)   - n*16 bit RW transaction
 * - SPICTL_IO32(n)   - n*32 bit RW transaction
 * - SPICTL_IO8R(n)    - n*8 bit R transaction
 * - SPICTL_IO16R(n)   - n*16 bit R transaction
 * - SPICTL_IO32R(n)   - n*32 bit R transaction
 * - SPICTL_IO8W(n)    - n*8 bit W transaction
 * - SPICTL_IO16W(n)   - n*16 bit W transaction
 * - SPICTL_IO32W(n)   - n*32 bit W transaction
 * - SPICTL_IO32RB(n)   - n*32 bit RB transaction (B - swaps byte's order)
 * - SPICTL_IO32WB(n)   - n*32 bit WB transaction
 * - SPICTL_IO32B(n)   - n*32 bit B transaction
 */


It seems we are missing (my bad too), the spi_select and spi_deselect commands in most of them - the good one
Code:
    case SPICTL_IO8(0):         /* transfer n*8 bits */
        spi_select(spi_fd[channel]);
        nelem = (cmd >> 16) & IOCPARM_MASK;
        if (baduaddr (addr) || baduaddr (addr + nelem - 1))
            return EFAULT;
        spi_bulk_rw(spi_fd[channel], nelem, cval);
        spi_deselect(spi_fd[channel]);
        break;

and the bad ones (they are many actually), ie.:
Code:
    case SPICTL_IO16R(0):        /* transfer n*16 bits */
        nelem = (cmd >> 16) & IOCPARM_MASK;
        if (((unsigned) addr & 1) ||
            baduaddr (addr) || baduaddr (addr + nelem*2 - 1))
            return EFAULT;
        spi_bulk_read_16(spi_fd[channel], nelem<<1, (char *)addr);
        break;

    case SPICTL_IO32R(0):        /* transfer n*32 bits */
        nelem = (cmd >> 16) & IOCPARM_MASK;
        if (((unsigned) addr & 3) ||
            baduaddr (addr) || baduaddr (addr + nelem*4 - 1))
            return EFAULT;
        spi_bulk_read_32(spi_fd[channel], nelem<<2, (char *)addr);
        break;

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Mon Sep 21, 2015 9:01 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
This issue has been fixed in the latest commit.
See: https://github.com/RetroBSD/retrobsd/blob/master/sys/pic32/spi.c#L200


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 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