FreeRTOS: FreeRTOS 蜂窝网库 v1.2.0
FreeRTOS 蜂窝网库
移植指南

将蜂窝网库移植到新平台的指南。

要使用蜂窝网库,平台必须实现以下组件:

  1. 配置宏
  2. 蜂窝通信接口
  3. 蜂窝平台依赖性

配置宏

必须在配置标头 cellular_config.h 中设置为宏的设置,或作为编译器选项传入的设置。

注意
如果未提供自定义配置标头 cellular_config.h ,则必须定义 CELLULAR_DO_NOT_USE_CUSTOM_CONFIG 宏。
另请参阅
配置

此外,整个库中使用以下日志记录宏:

蜂窝通信接口

FreeRTOS蜂窝网库使用通信接口与蜂窝模块通信。

CellularCommInterface 包括以下四个函数指针。参考原型文档页面。

蜂窝平台依赖性

蜂窝平台依赖性

FreeRTOS 蜂窝网库使用以下操作系统平台函数。
“cellular_pl platform.h” 在 FreeRTOS 蜂窝网库编译期间被引用。
FreeRTOS 蜂窝网库的用户应在 “cellular_pl platform.h” 中提供这些 API 和数据结构体。
FreeRTOS Labs 蜂窝演示中提供了 FreeRTOS 的默认实现。

  • 线程
    应在 cellular_pl platform.h 中提供以下 API 和宏
    bool Platform_CreateDetachedThread( void ( * threadRoutine )( void * ),
    void * pArgument,
    int32_t priority,
    size_t stackSize );
    #define PLATFORM_THREAD_DEFAULT_STACK_SIZE (2048U)
    #define PLATFORM_THREAD_DEFAULT_PRIORITY ( 5U )
  • 互斥锁
    应在 cellular_pl platform.h 中提供以下 API 和数据结构体。
    FreeRTOS蜂窝网库使用静态互斥分配。PlatformMutex 中的数据字段可以由开发人员定义。
    typedef struct PlatformMutex
    {
    ...
    } PlatformMutex_t;
    bool PlatformMutex_Create( PlatformMutex_t * pNewMutex,
    bool recursive );
    void PlatformMutex_Destroy( PlatformMutex_t * pMutex );
    void PlatformMutex_Lock( PlatformMutex_t * pMutex );
    bool PlatformMutex_TryLock( PlatformMutex_t * pMutex );
    void PlatformMutex_Unlock( PlatformMutex_t * pMutex );
  • 内存
    应在 cellular_pl platform.h 中提供以下 malloc/free 样式 API 。
    FreeRTOS 内存管理文档可以用于这些 API。
    // Example implementation of FreeRTOS malloc/free
    #define Platform_Malloc pvPortMalloc
    #define Platform_Free vPortFree
  • EventGroup
    以下 API 和句柄应在 cellular_pl platform.h 中提供。
    请参阅 FreeRTOS EvengGroup 函数原型
    // Example implementation of FreeRTOS EvengGroup
    #define PlatformEventGroupHandle_t EventGroupHandle_t
    #define PlatformEventGroup_Delete vEventGroupDelete
    #define PlatformEventGroup_ClearBits xEventGroupClearBits
    #define PlatformEventGroup_Create xEventGroupCreate
    #define PlatformEventGroup_GetBits xEventGroupGetBits
    #define PlatformEventGroup_SetBits xEventGroupSetBits
    #define PlatformEventGroup_SetBitsFromISR xEventGroupSetBitsFromISR
    #define PlatformEventGroup_WaitBits xEventGroupWaitBits
  • Delay
    应在 cellular_pl platform.h 中提供以下 API。
    请参阅 FreeRTOS 任务控制函数原型
    // Example implementation of FreeRTOS Task Control
    #define Platform_Delay( delayMs ) vTaskDelay( pdMS_TO_TICKS( delayMs ) )