Callisto4Bootloader: ARK/platform_main_freertos.c File Reference

Callisto4Bootloader

Data Structures | Macros | Typedefs | Functions | Variables
platform_main_freertos.c File Reference
`#include <stdio.h>`
`#include <stdarg.h>`
`#include <arpa/inet.h>`
`#include "cJSON.h"`
`#include "FreeRTOS.h"`
`#include "fsl_gpio.h"`
`#include "task.h"`
`#include "platform-api.h"`
`#include "platform-memory-map.h"`
`#include "platform_coap.h"`
`#include "httpserver-netconn.h"`

Go to the source code of this file.

## Data Structures

struct | stContentHeader_t

## Macros

#define | STACKDEPTH_IN_BYTES 4U
#define | NUM_SUPPORTED_PORTS NUM_ELEMENTS(GPIOBaseArray)

## Typedefs

typedef int(* | pfn_snprintf_t) (char *, uint32_t, const char *,...)

## Functions

static uint32_t | GPIO_PinsRead (GPIO_Type *base, uint32_t uiPin, uint32_t uiPinMask)
| Read multiple GPIO pins at once. More...
static void | GPIO_PinsWrite (GPIO_Type *base, uint32_t uiPin, uint32_t uiPinMask, uint32_t uiNewValue)
| Write multiple GPIO pins at once. More...
static bool | sGetTimestamp (stPLATFORM_Timestamp_t *pstTimestamp)
| Get a PTP timestamp. More...
static bool | sTaskCreate (uint32_t uiPluginIndex, ePLATFORM_TaskSlot_t eTaskSlot, void(*pvTaskCode)(void *pvParams), const char *const pcTaskName, void *pvParams, uint32_t uiStackSizeInBytes, ePLATFORM_TaskPriority_t ePriority)
| Create and launch a new plugin task. More...
static void | sTaskSleep (uint32_t uiMsec)
| Sleep the current task for a specified number of milliseconds. More...
static volatile uint32_t | sTaskGetTickCount (void)
| Get the current task's tickcount value. More...
static void | sGPIO_PinInit (uint32_t uiPin, const stPLATFORM_pin_config_t *pstConfig)
| Initialise a GPIO pin. More...
static uint8_t | sGPIO_PinReadPadStatus (uint32_t uiPin)
| Read a GPIO pin's pad status. More...
static void | sGPIO_PinSetInterruptConfig (uint32_t uiPin, ePLATFORM_interrupt_mode_t pinInterruptMode)
| Configure the interrupt settings for a given GPIO pin. More...
static uint32_t | sGPIO_PinRead (uint32_t uiPin)
| Read a single GPIO pin. More...
static uint32_t | sGPIO_PinsRead (uint32_t uiPin, uint32_t uiNumPins)
| Read multiple GPIO pins in one go. More...
static void | sGPIO_PinWrite (uint32_t uiPin, uint32_t uiOutput)
| Write a value out to single GPIO pin. More...
static void | sGPIO_PinsWrite (uint32_t uiPin, uint32_t uiNumPins, uint32_t uiOutput)
| Write a value out across a set of multiple GPIO pins. More...
static void * | sMalloc (uint32_t uiSize)
| Allocate memory. More...
static void | sFree (void *pvPtr)
| Free previously-allocated memory block. More...
static void | sAssert (const char *pachBuffer, const char *pachFilename, int iLineNumber)
| Assert support call. More...
bool | Sampler_NONE_Setup (const ePLATFORM_SamplerConfig_t *paeSamplerConfig, uint32_t uiNumChannels, volatile stPLATFORM_SampleGrab_t *pastCircularBuffer, uint32_t uiBufferElements)
bool | Sampler_NONE_Start (uint32_t uiPeriod_Nsec)
bool | Sampler_NONE_Adjust (uint32_t uiDelay_Nsec, uint32_t uiPeriod_Nsec)
bool | Sampler_NONE_Stop (void)
uint32_t | Sampler_NONE_GetTimer (void)
uint32_t | Sampler_NONE_Grab (uint32_t uiEarliestTimer, volatile stPLATFORM_SampleGrab_t **papstGrabArray, uint32_t uiMaxSamplesToGrab)
static const char * | GetContentHeader (eWebFlags_t eWebFlags)
static bool | FileAdd (const char *pachFileName, eWebFlags_t eWebFlags, const char *pachFiledata, uint32_t uiFilesize)
static bool | CgiAdd (const char *pachCgiName, pfnCgiCallback_t pfnCgiCallback)
static bool | DNS_SD_Discovery (void(*pfnResponseCallback)(const char *pachResponse, uint32_t uiResponseLen))

## Variables

static const UBaseType_t | auxPriorityTable [ePLATFORM_TaskPriority_MAX]
static const UBaseType_t | auxInterruptModeTable [ePLATFORM_Int_MAX]
static TaskHandle_t | ahTaskHandles [PLUGINS_MAX][ePLATFORM_TaskSlot_MAX]
static GPIO_Type *const | GPIOBaseArray []
static const stContentHeader_t | astContentHeader []
const stPlatformCalls_t | stPlatformCalls_FreeRTOS

## Macro Definition Documentation

## ◆ NUM_SUPPORTED_PORTS

#define NUM_SUPPORTED_PORTS NUM_ELEMENTS(GPIOBaseArray)

Definition at line 66 of file platform_main_freertos.c.

## ◆ STACKDEPTH_IN_BYTES

#define STACKDEPTH_IN_BYTES 4U

Definition at line 23 of file platform_main_freertos.c.

## Typedef Documentation

## ◆ pfn_snprintf_t

typedef int(* pfn_snprintf_t) (char *, uint32_t, const char *,...)

Definition at line 382 of file platform_main_freertos.c.

## Function Documentation

## ◆ CgiAdd()

static bool CgiAdd | ( | const char * | pachCgiName,
|  | pfnCgiCallback_t | pfnCgiCallback
| ) |  |

static

Definition at line 482 of file platform_main_freertos.c.

## ◆ DNS_SD_Discovery()

static bool DNS_SD_Discovery | ( | void(*)(const char *pachResponse, uint32_t uiResponseLen) | pfnResponseCallback | ) |

static

The Orchestrator plugin would like the platform to send out a DNS-SD multicast message Any responses that come back should be routed to the callback passed down by the plugin.

Parameters

  [in] | pfnResponseCallback | Callback to call when a DNS-SD response arrives

Returns
  true if DNS-SD was able to be set in motion, else false

Definition at line 495 of file platform_main_freertos.c.

## ◆ FileAdd()

static bool FileAdd | ( | const char * | pachFileName,
|  | eWebFlags_t | eWebFlags,
|  | const char * | pachFiledata,
|  | uint32_t | uiFilesize
| ) |  |

static

Definition at line 471 of file platform_main_freertos.c.

References GetContentHeader().

## ◆ GetContentHeader()

static const char* GetContentHeader | ( | eWebFlags_t | eWebFlags | ) |

static

Definition at line 456 of file platform_main_freertos.c.

References astContentHeader, i, and stContentHeader_t::pachHeader.

Referenced by FileAdd().

## ◆ GPIO_PinsRead()

static uint32_t GPIO_PinsRead | ( | GPIO_Type * | base,
|  | uint32_t | uiPin,
|  | uint32_t | uiPinMask
| ) |  |

inlinestatic

Read multiple GPIO pins at once.

Parameters

  [in] | base | GPIO base address
  [in] | uiPin | Pin base index
  [in] | uiPinMask | Pin mask (e.g. 0x07 for three consecutive pins)

Returns
  Value read from the consecutive pins

Atomic function missing from GPIO library - read multiple GPIOs (on the same port) at once

Definition at line 84 of file platform_main_freertos.c.

References GPIO_Type::DR.

Referenced by sGPIO_PinsRead().

## ◆ GPIO_PinsWrite()

static void GPIO_PinsWrite | ( | GPIO_Type * | base,
|  | uint32_t | uiPin,
|  | uint32_t | uiPinMask,
|  | uint32_t | uiNewValue
| ) |  |

inlinestatic

Write multiple GPIO pins at once.

Parameters

  [in] | base | GPIO base address
  [in] | uiPin | Pin base index
  [in] | uiPinMask | Pin mask (e.g. 0x07 for three consecutive pins)
  [in] | uiNewValue | Value to write to the consecutive pins

Atomic function missing from GPIO library - write multiple GPIOs (on the same port) at once

Definition at line 98 of file platform_main_freertos.c.

References GPIO_Type::DR.

Referenced by sGPIO_PinsWrite().

## ◆ Sampler_NONE_Adjust()

bool Sampler_NONE_Adjust | ( | uint32_t | uiDelay_Nsec,
|  | uint32_t | uiPeriod_Nsec
| ) |  |

Definition at line 408 of file platform_main_freertos.c.

## ◆ Sampler_NONE_GetTimer()

uint32_t Sampler_NONE_GetTimer | ( | void |  | ) |

Definition at line 421 of file platform_main_freertos.c.

## ◆ Sampler_NONE_Grab()

uint32_t Sampler_NONE_Grab | ( | uint32_t | uiEarliestTimer,
|  | volatile stPLATFORM_SampleGrab_t ** | papstGrabArray,
|  | uint32_t | uiMaxSamplesToGrab
| ) |  |

Definition at line 426 of file platform_main_freertos.c.

## ◆ Sampler_NONE_Setup()

bool Sampler_NONE_Setup | ( | const ePLATFORM_SamplerConfig_t * | paeSamplerConfig,
|  | uint32_t | uiNumChannels,
|  | volatile stPLATFORM_SampleGrab_t * | pastCircularBuffer,
|  | uint32_t | uiBufferElements
| ) |  |

Definition at line 388 of file platform_main_freertos.c.

## ◆ Sampler_NONE_Start()

bool Sampler_NONE_Start | ( | uint32_t | uiPeriod_Nsec | ) |

Definition at line 401 of file platform_main_freertos.c.

## ◆ Sampler_NONE_Stop()

bool Sampler_NONE_Stop | ( | void |  | ) |

Definition at line 416 of file platform_main_freertos.c.

## ◆ sAssert()

static void sAssert | ( | const char * | pachBuffer,
|  | const char * | pachFilename,
|  | int | iLineNumber
| ) |  |

static

Assert support call.

Parameters

  [in] | pachBuffer | Buffer holding assert message
  [in] | pachFilename | Filename of file containing assert call
  [in] | iLineNumber | Line number of line inside file where assert call can be found

Assert support call

Definition at line 377 of file platform_main_freertos.c.

## ◆ sFree()

static void sFree | ( | void * | pvPtr | ) |

static

Free previously-allocated memory block.

Parameters

  [in] | pvPtr | Pointer to previously allocated memory block

Free previously-allocated memory block (on platform heap)

Definition at line 364 of file platform_main_freertos.c.

## ◆ sGetTimestamp()

static bool sGetTimestamp | ( | stPLATFORM_Timestamp_t * | pstTimestamp | ) |

static

Get a PTP timestamp.

Parameters

  [out] | pstTimestamp | Timestamp to update with the current time

Return values

  false | Unable to get timestamp
  true | Got timestamp fine.

Get a PTP timestamp (not implemented yet, update this when PTP is working)

Definition at line 119 of file platform_main_freertos.c.

## ◆ sGPIO_PinInit()

static void sGPIO_PinInit | ( | uint32_t | uiPin,
|  | const stPLATFORM_pin_config_t * | pstConfig
| ) |  |

static

Initialise a GPIO pin.

Parameters

  [in] | uiPin | Index of pin to initialise
  [in] | pstConfig | Configuration parameters to use for this pin

Initialise a GPIO pin

Definition at line 207 of file platform_main_freertos.c.

References assert, GPIOBaseArray, and NUM_SUPPORTED_PORTS.

## ◆ sGPIO_PinRead()

static uint32_t sGPIO_PinRead | ( | uint32_t | uiPin | ) |

static

Read a single GPIO pin.

Parameters

  [in] | uiPin | Index of pin that caller would like to read

Return values

  0 | Pin is low
  1 | Pin is high

Read a single GPIO pin

Definition at line 266 of file platform_main_freertos.c.

References assert, GPIOBaseArray, and NUM_SUPPORTED_PORTS.

## ◆ sGPIO_PinReadPadStatus()

static uint8_t sGPIO_PinReadPadStatus | ( | uint32_t | uiPin | ) |

static

Read a GPIO pin's pad status.

Parameters

  [in] | uiPin | Index of pin whose pad status caller would like to read

Returns
  Specified pin's pad status

Read a GPIO pin's pad status

Definition at line 231 of file platform_main_freertos.c.

References assert, GPIOBaseArray, and NUM_SUPPORTED_PORTS.

## ◆ sGPIO_PinSetInterruptConfig()

static void sGPIO_PinSetInterruptConfig | ( | uint32_t | uiPin,
|  | ePLATFORM_interrupt_mode_t | pinInterruptMode
| ) |  |

static

Configure the interrupt settings for a given GPIO pin.

Parameters

  [in] | uiPin | Index of pin whose interrupt settings caller would like to set
  [in] | pinInterruptMode | Interrupt settings to use

Configure the interrupt settings for a given GPIO pin

Definition at line 247 of file platform_main_freertos.c.

References assert, auxInterruptModeTable, GPIOBaseArray, and NUM_SUPPORTED_PORTS.

## ◆ sGPIO_PinsRead()

static uint32_t sGPIO_PinsRead | ( | uint32_t | uiPin,
|  | uint32_t | uiNumPins
| ) |  |

static

Read multiple GPIO pins in one go.

Parameters

  [in] | uiPin | Index of base pin that caller would like to read
  [in] | uiNumPins | Number of contiguous pins that caller would like to read

Returns
  value of pins packed from LSB upwards

Read multiple GPIO pins in one go

Definition at line 283 of file platform_main_freertos.c.

References assert, GPIO_PinsRead(), GPIOBaseArray, and NUM_SUPPORTED_PORTS.

## ◆ sGPIO_PinsWrite()

static void sGPIO_PinsWrite | ( | uint32_t | uiPin,
|  | uint32_t | uiNumPins,
|  | uint32_t | uiOutput
| ) |  |

static

Write a value out across a set of multiple GPIO pins.

Parameters

  [in] | uiPin | Index of base pin that caller would like to write
  [in] | uiNumPins | Number of contiguous pins to write to
  [in] | uiOutput | Value to write out the single GPIO pin

Write a value out across a set of multiple GPIO pins

Definition at line 321 of file platform_main_freertos.c.

References assert, GPIO_PinsWrite(), GPIOBaseArray, and NUM_SUPPORTED_PORTS.

## ◆ sGPIO_PinWrite()

static void sGPIO_PinWrite | ( | uint32_t | uiPin,
|  | uint32_t | uiOutput
| ) |  |

static

Write a value out to single GPIO pin.

Parameters

  [in] | uiPin | Index of pin that caller would like to read
  [in] | uiOutput | Value to write out the single GPIO pin

Write a value out to single GPIO pin

Definition at line 303 of file platform_main_freertos.c.

References assert, GPIOBaseArray, and NUM_SUPPORTED_PORTS.

## ◆ sMalloc()

static void* sMalloc | ( | uint32_t | uiSize | ) |

static

Allocate memory.

Parameters

  [in] | uiSize | Size of memory block to allocate

Return values

  NULL | If allocate operation was unsuccessful
  (ptr) | Pointer to allocated area of memory

Allocate memory (on platform heap)

Definition at line 345 of file platform_main_freertos.c.

References NULL.

## ◆ sTaskCreate()

static bool sTaskCreate | ( | uint32_t | uiPluginIndex,
|  | ePLATFORM_TaskSlot_t | eTaskSlot,
|  | void(*)(void *pvParams) | pvTaskCode,
|  | const char *const | pcTaskName,
|  | void * | pvParams,
|  | uint32_t | uiStackSizeInBytes,
|  | ePLATFORM_TaskPriority_t | ePriority
| ) |  |

static

Create and launch a new plugin task.

Parameters

  [in] | uiPluginIndex | Index of plugin slot
  [in] | eTaskSlot | Index of task slot (in this plugin's set of task slots)
  [in] | pvTaskCode | Pointer to task code
  [in] | pcTaskName | Task name
  [in] | pvParams | Parameter to pass to created task
  [in] | uiStackSizeInBytes | Task stack size
  [in] | ePriority | Task stack priority

Return values

  false | Unable to create plugin task.
  true | Started plugin task just fine.

Create and launch a new plugin task

Definition at line 148 of file platform_main_freertos.c.

References ahTaskHandles, assert, auxPriorityTable, and STACKDEPTH_IN_BYTES.

## ◆ sTaskGetTickCount()

static volatile uint32_t sTaskGetTickCount | ( | void |  | ) |

static

Get the current task's tickcount value.

Returns
  Current task's tickcount value

Get the current task's tickcount value (in 1ms ticks)

Definition at line 195 of file platform_main_freertos.c.

## ◆ sTaskSleep()

static void sTaskSleep | ( | uint32_t | uiMsec | ) |

static

Sleep the current task for a specified number of milliseconds.

Parameters

  [in] | uiMsec | Number of milliseconds to sleep

Definition at line 184 of file platform_main_freertos.c.

## Variable Documentation

## ◆ ahTaskHandles

TaskHandle_t ahTaskHandles[PLUGINS_MAX][ePLATFORM_TaskSlot_MAX]

static

Definition at line 53 of file platform_main_freertos.c.

Referenced by sTaskCreate().

## ◆ astContentHeader

const stContentHeader_t astContentHeader[]

static

Initial value:
=
{
{ eWebFlags_HTML, "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n" },
{ eWebFlags_JavaScript, "HTTP/1.1 200 OK\r\nContent-type: text/javascript\r\n\r\n" },
{ eWebFlags_CSS, "HTTP/1.1 200 OK\r\nContent-type: text/css\r\n\r\n" },
{ eWebFlags_GIF, "HTTP/1.1 200 OK\r\nContent-type: image/gif\r\n\r\n" },
{ eWebFlags_JPG, "HTTP/1.1 200 OK\r\nContent-type: image/jpeg\r\n\r\n" },
{ eWebFlags_PNG, "HTTP/1.1 200 OK\r\nContent-type: image/png\r\n\r\n" },
{ eWebFlags_WEBP, "HTTP/1.1 200 OK\r\nContent-type: image/webp\r\n\r\n" },
{ eWebFlags_PDF, "HTTP/1.1 200 OK\r\nContent-type: application/pdf\r\n\r\n" },
{ eWebFlags_JSON, "HTTP/1.1 200 OK\r\nContent-type: application/json\r\n\r\n" }
}

Definition at line 443 of file platform_main_freertos.c.

Referenced by GetContentHeader().

## ◆ auxInterruptModeTable

const UBaseType_t auxInterruptModeTable[ePLATFORM_Int_MAX]

static

Initial value:
=
{
kGPIO_NoIntmode,
kGPIO_IntLowLevel,
kGPIO_IntHighLevel,
kGPIO_IntRisingEdge,
kGPIO_IntFallingEdge,
kGPIO_IntRisingOrFallingEdge
}

Definition at line 38 of file platform_main_freertos.c.

Referenced by sGPIO_PinSetInterruptConfig().

## ◆ auxPriorityTable

const UBaseType_t auxPriorityTable[ePLATFORM_TaskPriority_MAX]

static

Initial value:
=
{
6U,
7U,
8U,
12U
}

Definition at line 29 of file platform_main_freertos.c.

Referenced by sTaskCreate().

## ◆ GPIOBaseArray

GPIO_Type* const GPIOBaseArray[]

static

Initial value:
=
{
GPIO1,
GPIO2,
GPIO3,
GPIO4
}

Definition at line 58 of file platform_main_freertos.c.

Referenced by sGPIO_PinInit(), sGPIO_PinRead(), sGPIO_PinReadPadStatus(), sGPIO_PinSetInterruptConfig(), sGPIO_PinsRead(), sGPIO_PinsWrite(), and sGPIO_PinWrite().

## ◆ stPlatformCalls_FreeRTOS

const stPlatformCalls_t stPlatformCalls_FreeRTOS

Definition at line 505 of file platform_main_freertos.c.

GPIO1
#define GPIO1
Definition: MIMXRT1062.h:20740
GPIO4
#define GPIO4
Definition: MIMXRT1062.h:20752
GPIO2
#define GPIO2
Definition: MIMXRT1062.h:20744
GPIO3
#define GPIO3
Definition: MIMXRT1062.h:20748