Driver Porting Guide¶
Porting Layer Files¶
wlan_irq_adapt.cspi_adapt.cosi_filesystem.cosi_freertos.c
ti_drivers_config.h.WLAN Enable/Disable¶
The CC33XX device can be enabled and disabled by controlling the WLAN_EN signal via GPIO output.
`wlan_irq_adapt`_:
TurnOn_WL: Toggles the WLAN_EN signal high, then delays 2 seconds.TurnOff_WL: Toggles the WLAN_EN signal low.GetState_WL: Checks the current state of the WLAN_EN signal.
Host Interface¶
The host communication interface is SPI. The porting layer requires functionality for SPI open, close, read, write, and registering an interrupt handler routine for the IRQ signal.
The SPI interface on the host MCU has the following hardware requirements:
- Master mode
- 4 pin mode
- Chip select active low
- Polarity 0 phase 0
- Max frequency: 32000000 Hz
- Data block: 32 bits
`spi_adapt`_:
spi_Init: Initialize and open the host MCU SPI modulespi_ReadSync: Read from SPI (blocking)spi_WriteSync: Write to SPI (blocking)
The host interface also requires an IRQ signal with a registered interrupt and a GPIO to control the CC33xx Enable pin.
`wlan_irq_adapt`_:
wlan_IRQInit: Initialize the GPIO input and register a pin interruptwlan_IRQDeinit: Destroy the GPIO interruptwlan_IRQEableInt: Enable GPIO interrupt. If working with edge-trigger, this is not required.wlan_IRQDisableInt: Disable GPIO interrupt. If working with edge-trigger, this is not required.wlan_IRQClearInt: Clear GPIO interrupt. If working with edge-trigger, this is not required.wlan_TurnOffWlan: Set the CC33xx enable pin (GPIO) to off state.wlan_TurnOnWlan: Set the CC33xx enable pin (GPIO) to on state.wlan_GetStateWlan: Retrieve the CC33xx enable pin (GPIO) state.
OS Abstraction¶
This software package utilizes Free-RTOS, which is included with the MCU-PLUS-AM243X-SDK. The porting layer defines generic “osi” APIs used by the firmware. This allows the firmware to adapt to another RTOS.
`osi_freertos`_:
osi_SyncObjCreate: Create a sync object (e.g. a semaphore or a message queue) where a thread can block and wait for an external eventosi_SyncObjDelete: Delete sync objectosi_SyncObjSignal: Generate a sync signal, or give the sempahoreosi_SyncObjSignalFromISR: Generate a sync signal from the ISR contextosi_SyncObjWait: Wait for a sync signal, or take the semaphoreosi_SyncObjClear: Clear sync objectosi_LockObjCreate: Create a locking objectosi_LockObjDelete: Delete the locking objectosi_LockObjLock: Lock the locking objectosi_LockObjUnlock: Unlock the locking objectosi_MsgQCreate: Create a message queueosi_MsgQDelete: Delete message queueosi_MsgQWrite: Post message to queueosi_MsgQRead: Read message from queueosi_MsgQCount: Returns the number of messages in the message queueosi_MsgQIsEmpty: Boolean returns whether the message count in the queue is zeroosi_ThreadCreate: Create a task. In the example, this API uses a legacy osi_TaskCreate.osi_ThreadDelete: Delete the task. In the example, this API uses a legacy osi_TaskDelete.osi_EnterCritical: Enter critical section (lock + context switch prevention)osi_ExitCritical: Exit critical sectionassert: Assert function
Memory Management¶
The control block for the host driver requires memory allocation.
`osi_freertos`_:
os_malloc: Allocate dynamic memoryos_realloc: Reallocate dynamic memoryos_realloc_array: Reallocate and zero memory blocksos_calloc: Allocate and zero memory blocksos_zalloc: Allocate and zero memoryos_free: Free memory
Timer Mechanism¶
This timestamp mechanism is used to determine timeouts for the host driver.
`osi_freertos`_:
osi_Sleep: Put the thread to sleep (seconds)osi_uSleep: Put the thread to sleep (microseconds)osi_GetTimeMS: Get the running tick count (milliseconds)osi_TimerCreate: Create a timerosi_TimerDelete: Delete timerosi_TimerStart: Start timerosi_TimerStop: Stop timerosi_TimerGetRemainingTime: Get remaining time
The system tick period for the target host MCU must be set in the define TICK_PERIOD_US at the top of osi_freertos.c.
File System¶
These functions are required for the file management of the host driver. For now the driver only uses the read function to retrieve the pre-installed firmware when downloading it as part of the cc33xx init.
`osi_filesystem`_:
osi_fopen: File openosi_fclose: File closeosi_fread: File readosi_write: File write (not used currently)osi_filelength: Get file size
Asynchronous Event Handler¶
Wlan_Start. The event handler should be customized for the application.WlanEventHandler() defined in network_terminal.c.