Dynamic Donut

21
Software System Design Matthew Cohn

description

Dynamic Donut. Software System Design Matthew Cohn. Microcontroller – MCF52233. Bus Speed – 60MHz On-Chip Resources Programmable Interrupt Timer 32kB SRAM 18kB Required 256kB Flash 37kB Required, No Paging Communications Modules UART I 2 C QSPI. Operating System – CuteC/OS. - PowerPoint PPT Presentation

Transcript of Dynamic Donut

Page 1: Dynamic Donut

Software System DesignMatthew Cohn

Page 2: Dynamic Donut

Bus Speed – 60MHz On-Chip Resources

• Programmable Interrupt Timer• 32kB SRAM

• 18kB Required• 256kB Flash

• 37kB Required, No Paging• Communications Modules

• UART• I2C• QSPI

Page 3: Dynamic Donut

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

Page 4: Dynamic Donut

Will Not Be Implemented• Changing task states in ISRs

Includes semaphores, mutexes, mailboxes, delays inside ISR

• Deleting tasks• Returning from tasks• Flags

Page 5: Dynamic Donut

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

Page 6: Dynamic Donut

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

Page 7: Dynamic Donut

Polls the states of each key

Provides software debouncing

Upon keypress, sends a message to tskSystem’s mailbox

Page 8: Dynamic Donut

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

Page 9: Dynamic Donut

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

Page 10: Dynamic Donut

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

Page 11: Dynamic Donut

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

Page 12: Dynamic Donut

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

Page 13: Dynamic Donut

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

Page 14: Dynamic Donut

Public data: INT32U audioBuffer[1765];

1,765 16-bit stereo samples 441 x 4 + 1

INT32U *writePointer; Points past the last valid audio sample

Page 15: Dynamic Donut

No public functions No public data

Page 16: Dynamic Donut

No public functions Public data:

ccMailbox transmitMailbox for commands to transmit from the Dynamic Donut via UART

Page 17: Dynamic Donut

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

Page 18: Dynamic Donut

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

Page 19: Dynamic Donut

tskKeypad tskSystemExternal hardware

tskUART

Keypad

UART

tskKeypad

tskUART tskSystem

commandMailbox

.

Page 20: Dynamic Donut

audioISR

audioBuffer

writePointer

readPointer

audioISR External hardware

tskWriteAudio

Application

CS8406

CoolRunner v2

QSPIQWR

QAR

QDR

SD Card

Page 21: Dynamic Donut

GPIO

LcdWrite()

tskLCD External hardware

tskSystem

Application

LCD_BUFFER

lcdLayersKey(Mutex)

lcdModified(Semaphore)

Newhaven Display

tskAudio