Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Sharing the SPI bus.

Posted by Nobody/Anonymous on July 19, 2006
Hi,

I'm new to FreeRTOS, I got up and running earlier today. I've just looked at the schematic for our board and realise that the 2 main peripherals on our system are on the same spi bus.

We're using the SAM7S series.

Bearing in mind that I will have different tasks handling both peripherals, what's the best way to attack this?

The way I see it is that I create a transmission queue, and when something wants to transmit on spi it adds the message to the queue. A task then takes the message from the queue (providing it's not currently transmitting) and transmits it. Reads from the bus are obviously done in a similar manner as they're dummy writes.

Once the message is fully read, it's place into the correct read queue for the peripheral and the task that deals with that peripheral awakes and processes the data.

Both peripherals can also cause interrupts, so when the interrupt occurs I have to set up the system to do a read.

Being new to using FreeRTOS (or any off the shelf RTOS) I'm wondering if I'm thinking in the right way or have I totally got it wrong! Any ideas or information on how other people have done this would be gratefully accepted.

Thanks.

Adrian

RE: Sharing the SPI bus.

Posted by Nobody/Anonymous on July 19, 2006
Some would approach this by having a semaphore to guard access to the bus. You must first obtain the semaphore before accessing the bus. This way any task can access it. Personally I think this is nearly always a bad idea.

Take a look at the UART drivers given as examples. These let any task send data to the UART without the risk of corruption by queueing data to transmit within a function (just a simple function, it does not need to be a task provided you use a scheduler lock around access). An interrupt can be used to read data from the queue directly.

Directing received data to the correct task is a little more complex and requires some decoding of addresses prior to posting onto a queue.

Also take a look at the I2C driver that is in the WizNET WEB server demo. This will give an example of how to send discrete framed messages rather than a single stream of bytes.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists