Software System DesignMatthew Cohn
Bus Speed – 60MHz On-Chip Resources
• Programmable Interrupt Timer• 32kB SRAM
• 18kB Required• 256kB Flash
• 37kB Required, No Paging• Communications Modules
• UART• I2C• QSPI
Implemented• Real-time, preemptive, multitasking kernel• Priority based• Automatically corrects priority inversion• Delays, with 1ms tick period• Dynamic memory allocation (memory pools)• Intertask synchronization and communication
Mutexes Semaphores Queues Mailboxes
Will Not Be Implemented• Changing task states in ISRs
Includes semaphores, mutexes, mailboxes, delays inside ISR
• Deleting tasks• Returning from tasks• Flags
Task Name Priority
Average Execution
Average Period
Worst-Case Execution
Worst-Case Period
Worst-Case CPU Load
audioISR ISR 1μs -1 6μs 22.68μs 0.265
tskLoadAudio 1 0s2 ∞2 3.76ms 10ms 0.376
tskKeypad 2 -1 -1 30μs 5ms 0.006
tskUART 3 -1 -1 30μs 10ms 0.003
tskSystem 4 -1 -1 30μs 100ms 0.000
tskLCD 5 860μs Sporadic 6.88ms 100ms 0.069
tskIdle 7 -3 -3 -3 -3 -3
Total average load: 0.053 Total worst-case load: 0.719
1Average times are same as worst-case times2tskLoadAudio only operates when playing back audio3The idle task operates when no other tasks are ready to operate
Uses the EFSL library to load audio data from the SD card. Sends it to the appropriate decoding function (WAV or MP2)
Audio is then placed in the output circular buffer, and the buffer’s write position pointer is updated
Polls the states of each key
Provides software debouncing
Upon keypress, sends a message to tskSystem’s mailbox
Polls UART for new incoming data
If a command is received over UART, sends a message to TskSystem’s mailbox
If a command is queued in TskUART’s mailbox, sends the command over UART
Maintains the system state
Uses the EFSL library to read directory listings from the SD card, navigates files and directories
Provides the user interface by calling functions in the LCD module
Writes information to the LCD display
Handles multiple layers of information which is flattened to a final layer when displayed
Only transmits updated characters to the display
Module Name Tasks Public Functions and Data
audio.c audioISRtskLoadAudio
INT32U audioBuffer[1764]INT32U *writePointerplayAudio();stopAudio();nextTransition();setTransition();
lcd.c tskLCD All LCD functions
keypad.c tskKeypad None
uart.c tskUART ccMailbox transmitMailbox;
main.c tskSystem ccMailbox commandMailbox;updateStatus();audioFinished();
i2c.c i2cInit();I2cTransmit();
EFSL – Embedded File System Library © Lennart Ysboodt, Michael De Nil 2005
CFMP2DECAUDSW – ColdFire MPEG1/2 Layer 2 Decoder © Freescale
Public functions: bool playAudio(char *path);
Checks to see if the file exists and can be open Upon success, posts the playingAudio mutex and returns
true Upon failure, returns false
TskAudio pends on the playingAudio mutex After the audio file has finished, playingAudio is pended on
again bool stopAudio();
Upon success, returns true. If no audio playing, return false
Public functions: bool nextTransition();
Sets a flag specifying the user has requested the system stop looping at the next available transition
If an audio file is playing, returns true If no audio file is playing, returns false
bool setTransition(int transNumber); Sets an automatic transition Can be called once for each embedded loop Returns true on success, false on error
Public data: INT32U audioBuffer[1765];
1,765 16-bit stereo samples 441 x 4 + 1
INT32U *writePointer; Points past the last valid audio sample
No public functions No public data
No public functions Public data:
ccMailbox transmitMailbox for commands to transmit from the Dynamic Donut via UART
Public functions: void audioFinished();
Called by TskAudio when audio has finished playing void updateStatus();
Updates the playback time of audio when playing
Public data: ccMailbox commandMailbox for received commands
from UART or keypad
Public functions: void i2cInit();
Initializes the I2C hardware bool i2cTransmit();
Initiates a transfer on the I2C bus. If the transfer was successful and an ACK was received, return true. Otherwise, return false.
No public data
tskKeypad tskSystemExternal hardware
tskUART
Keypad
UART
tskKeypad
tskUART tskSystem
commandMailbox
.
audioISR
audioBuffer
writePointer
readPointer
audioISR External hardware
tskWriteAudio
Application
CS8406
CoolRunner v2
QSPIQWR
QAR
QDR
SD Card
GPIO
LcdWrite()
tskLCD External hardware
tskSystem
Application
LCD_BUFFER
lcdLayersKey(Mutex)
lcdModified(Semaphore)
Newhaven Display
tskAudio