AnsweredAssumed Answered

MKW30Z app_preinclude.h set-up on new PCB

Question asked by Lucian Firan on Feb 12, 2017
Latest reply on Apr 4, 2017 by Mario Ignacio Castaneda Lopez

IAR 7.50;  KW40Z_Connectivity_Software_1.0.1 (KSDK_1.3.0)

 

In Connectivity Framework, Reference Manual, Rev. 1, 09/2015

found following possible software switches:

 

/* OS Abstraction */
    /* Defines the maximum number of semaphores. It is set to 5 by default */
    #define osNumberOfSemaphores 5
    /* Defines the maximum number of mutexes. It is set to 5 by default */
    define osNumberOfMutexes 5
    /* Defines the maximum number of message queues. It is set to 5 by default */
    #define osNumberOfMessageQs 5
    /* Defines the total number of messages for all message queues. It is set to 40 by default */
    #define osNumberOfMessages 40
    /* The number of event objects. It is set to 5 by default */
    #define osNumberOfEvents 5
     /* The number of OS timer objects. It is set to 1 by default */
    #define osNumberOfTimers 1

 

/* Memory management */
        #define PoolsDetails_c \
        _block_size_  64 _number_of_blocks_ 8 _eol_ \
        _block_size_ 128 _number_of_blocks_ 4 _eol_ \
        _block_size_ 256 _number_of_blocks_ 6 _eol_

 

/* Timers Manager */
    /* Enables / disables the timer module, except for the RTC functionality. It is set to TRUE by default */
    #define gTMR_Enabled_d                    TRUE
    /* Enables / disables the timestamp functionality. It is set to TRUE by default */
    #define gTimestamp_Enabled_d              TRUE
    /* The default hardware used for timestamp is the RTC. If this define is set to TRUE, then the PIT HW is used for timestamp.
    * It is set to FALSE by default*/
    #define gTMR_PIT_Timestamp_Enabled_d      FALSE
    /* Enables / disables the timer synchronization after exiting the low-power mode. */
    #define gTMR_EnableLowPowerTimers_d       TRUE
    /* If set to TRUE, all timers of the gTmrLowPowerTimer_c type, will use the LPTMR HW. These timers also run in the low-power mode.
    * It is set to FALSE by default*/
    #define gTMR_EnableHWLowPowerTimers_d     FALSE
    /* Enables / disables the TMR_StartMinuteTimer and TMR_StartSecondTimer wrapper functions. It is set to TRUE by default */
    #define gTMR_EnableMinutesSecondsTimers_d TRUE
    /* Defines the number of software timers that can be used by the application. It is set to 0 by default */
    #define gTmrApplicationTimers_c           0
    /* Defines the number of stack timers that can to be used by the stack. It is set to 1 by default */
    #define gTmrStackTimers_c                 1
    /* Defines the priority of the timer task. It is set to 2 by default */
    #define gTmrTaskPriority_c                2
    /* Defines the stack size (in bytes) of the timer task. It is set to 500 by default */
    #define gTmrTaskStackSize_c               500
    
/* Flash management */
    /* If set to TRUE, it enables the whole functionality of the nonvolatile storage system. By default, it is set to FALSE (no code or data is generated for this module). */
    #define gNvStorageIncluded_d FALSE
    /* If set to TRUE, it enables the FlexNVM functionality of the nonvolatile storage system. By default, it is set to FALSE.
    * If FlexNVM is used, the standard nonvolatile storage system is disabled. */
    #define gNvUseFlexNVM_d  FALSE
    /* Macro used to enable / disable the fragmented saves / restores (a particular element from a table entry can be saved or restored). It is set to FALSE by default. */
    #define gNvFragmentation_Enabled_d  FALSE
    /* Macro used to enable / disable the extended feature set of the module: Remove existing NV table entries / Register new NV table entries / Table upgrade It is set to FALSE by default. */    
    #define gNvUseExtendedFeatureSet_d  FALSE
    /* Macro used to enable unmirrored datasets. It is set to 0 by default. */
    #define gUnmirroredFeatureSet_d 0
    /* This constant defines the maximum count of the table entries (datasets) that the application is going to use. It is set to 32 by default. */
    #define gNvTableEntriesCountMax_c 32
    /* This constant defines the size of the buffer used by the page copy function, when the copy operation performs defragmentation.
    * The chosen value must be a power of 2 and bigger than the maximum number of elements stored in any of the table entries.
    * It is set by default to 64. */
    #define gNvRecordsCopiedBufferSize_c 64
    /* This constant defines the size of the cache buffer used by the page copy function, when the copy operation does not perform defragmentation.
    * The chosen value must be a multiple of 4. It is set by default to 64. */
    #define gNvCacheBufferSize_c 64
    /* This constant defines the minimum timer ticks between dataset saves (in seconds). It is set to 4 by default. */
    #define gNvMinimumTicksBetweenSaves_c 4
    /* This constant defines the number of calls to ‘NvSaveOnCount’ between dataset saves. It is set to 256 by default. */
    #define gNvCountsBetweenSaves_c 256
    /* Macro used to mark a table entry as invalid in the NV table. Default value is 0xFFFFU. */
    #define gNvInvalidDataEntry_c 0xFFFFU
    /* Macro used to define the maximum retries count value for the format operation. It is set to 3 by default. */
    #define gNvFormatRetryCount_c
    /* Macro used to define the size of the pending saves queue. It is set to 32 by default. */
    #define gNvPendigSavesQueueSize_c 32
    /* Macro used to allow overwriting of older entries in the pending saves queue, if it is full. It is set to FALSE by default. */
    #define gFifoOverwriteEnabled_c FALSE
    /* Macro used to define the minimum free space at init. If the free space is smaller than this value, a page copy will be triggered. It is set by default to 128. */
    #define gNvMinimumFreeBytesCountStart_c 128
    /* Macro used to define the ID of the end-of-table entry. It is set to 0xFFFEU by default. No valid entry should use this ID. */
    #define gNvEndOfTableId_c 0xFFFEU
    /* Macro used to define the table marker value. The table marker is used to indicate the start and the end of the flash copy of the NV table.
    * It is set to 0x4254U by default. */
    #define gNvTableMarker_c 0x4254U
    /* Macro used to define the flash table version. It is used to determine if the RAM table was updated. It is
    set to 1 by default. The application should modify this every time the RAM table is updated and the data
    from NVM is still required.     */
    #define gNvFlashTableVersion_c 1
    
/* Random number generator */    
    /* This macro defines the default hardware support of the RNG module. gRNG_HWSupport_d, gRNG_RNGAHWSupport_d, gRNG_RNGBHWSupport_d, gRNG_TRNGHWSupport_d */
    #define gRNG_HWSupport_d gRNG_NoHWSupport_d
    /* Defines the status codes for the RNG. */
    #define gRngSuccess_d (0x00)
    #define gRngInternalError_d (0x01)
    #define gRngNullPointer_d (0x80)
    /* This macro defines the maximum number of requests permitted until a reseed is needed. */
    #define gRngMaxRequests_d (100000)
    
/*  System Panic */
/* System reset */

 

/* Serial manager  */    
    /* This define specifies the maximum number of interfaces to be used. */
    #define gSerialManagerMaxInterfaces_c 1
    /* Defines, which serial interface can be used by SerialManager. */
    #define gSerialMgrUseUart_c 1
    #define gSerialMgrUseUSB_c 0
    #define gSerialMgrUseIIC_c 0
    #define gSerialMgrUseSPI_c 0
    /* Enables / disables input parameter checking. */
    #define gSerialMgr_ParamValidation_d 1
    /* Enables / disables blocking the calling task when an asynchronous TX operation is triggered with the full queue. */
    #define gSerialMgr_BlockSenderOnQueueFull_c 1
    /* Defines the address to be used for I2C. */
    #define gSerialMgrIICAddress_c 0x76
    /* Defines the RX buffer size. */
    #define gSerialMgrRxBufSize_c 32
    /*  Defines the TX queue size. */
    #define gSerialMgrTxQueueSize_c 5
    /* Defines the serial manager task stack size. */
    #define gSerialTaskStackSize_c 1024
    /* Defines the serial manager task priority. Usually, this task is a low-priority task. */
    #define gSerialTaskPriority_c 3
    /* If you want to print a hex number, you can choose between BigEndian=1 / LittleEndian=0, newline, commas or spaces (between bytes). */
    #define gPrtHexNoFormat_c (0x00)
    #define gPrtHexBigEndian_c (1<<0)
    #define gPrtHexNewLine_c (1<<1)
    #define gPrtHexCommas_c (1<<2)
    #define gPrtHexSpaces_c (1<<3)
    
/* Freescale Serial Communication Interface (FSCI)  */
    /* Enable/Disable FSCI module */
    #define gFsciIncluded_c 0
    #define gFsciMaxOpGroups_c 8
    #define gFsciMaxInterfaces_c 1
    #define gFsciMaxVirtualInterfaces_c 2
    /* bytes */
    #define gFsciMaxPayloadLen_c 245
    /* bytes */
    #define gFsciTimestampSize_c 0
    /* boolean */
    #define gFsciLenHas2Bytes_c 0
    /* boolean */
    #define gFsciUseEscapeSeq_c 0
    /* boolean */
    #define gFsciUseFmtLog_c 0
    /* boolean */
    #define gFsciUseFileDataLog_c 0
    /* [0..gFsciMaxInterfaces_c) */
    #define gFsciLoggingInterface_c 1
    
/* Sec Lib */
    /* Defines the default hardware support option gSecLib_NoHWSupport_d, gSecLib_MMCAUSupport_d, gSecLib_LTCSupport_d */
    #define gSecLib_HWSupport_d gSecLib_NoHWSupport_d
/* Lists */
/* Function Lib */
/* Low-power Library */
    /* PWR_Configuration.h */
        /* Enables/Disables low power related code and variables. */
        #define cPWR_UsePowerDownMode TRUE
        /* Configures default deep sleep mode. */
        #define cPWR_DeepSleepMode 4
        /* Configures default deep sleep duration. It only has meaning for deep sleep modes 2 and 3. */
        #define cPWR_DeepSleepDurationMs 30000
        /* Enables/Disables low power code related with BLE Link Layer. */
        #define cPWR_BLE_LL_Enable TRUE
        /* Enables/Disables low power code related with Zigbee stack. */
        #define cPWR_Zigbee_Enable FALSE
        /* Number of slots (625us) when BLE Link Layer hardware needs to exit from deep sleep mode before BLE reference clock register reaches wake up instant register. */
        #define cPWR_BLE_LL_OffsetToWakeupInstant (8)
        /* Period that BLE Link Layer must wait after a system clock request to be sure the oscillator is running
        * and stable. This is in X.Y format where X is in terms of number of BT slots (625 us) and Y is in terms of
        * number of clock periods of 16 KHz clock input, required for RF oscillator to stabilize the clock output
        * after oscillator is turned ON. In this period the clock is assumed to be unstable, and so the controller
        * does not turn on the clock to internal logic until this period is over. This means, the wake up from deep
        * sleep mode must account for this delay before the wakeup instant.
        * Osc_startup_delay[7:5] is number of slots(625us)
        * Osc_startup_delay[4:0 ] is number of clock periods of 16KHz clock
        * (Warning: Max. value of Osc_startup_delay [4:0] supported is 9. Therefore do not program value greater than 9)  */
        #define cPWR_BLE_LL_OscStartupDelay (8)
        /* Set this define 1 if DCDC is in bypass mode or 0 otherwise. It will configure deep sleep mode 4 to put
        * the MCU in VLLS0 (when 1) or VLLS1 (when 0) since VLLS0 is only supported in bypass mode. */
        #define cPWR_DCDC_InBypass (1)
        /* If 1, this define disables POR circuit in VLLS0, reducing power consumption even more. This define
        * only has meaning if cPWR_DCDC_InBypass is TRUE. */
        #define cPWR_POR_DisabledInVLLS0 (1)
    /* PWR_Interface.h */
        /* Functions PWR_AllowDeviceToSleep/PWR_DisallowDeviceToSleep simply decrement / increment a
        * global variable. When variable value is 0, the system is allowed to enter low power. This define sets the
        * initial value of this variable. */
        #define gAllowDeviceToSleep_c 0
        
/* LED */
    /* Enables / disables the LED module. */
    #define gLEDSupported_d TRUE
    /* Configures the number of LEDs used (up to a maximum of four). */
    #define gLEDsOnTargetBoardCnt_c 4
    /* Enables / disables the blip feature. */
    #define gLEDBlipEnabled_d TRUE
    /* Configures the ON period of the flashing feature in milliseconds. */
    #define mLEDInterval_c 100
    
/* Keyboard */
    /* Enables / disables the keyboard module. */
    #define gKeyBoardSupported_d TRUE
    /* Configures the number of switches. */
    #define gKBD_KeysCount_c 4
    /* Selects the operation mode of the keyboard module. gKbdEventPressOnly_c, gKbdEventShortLongPressMode_c, gKbdEventPressHoldReleaseMode_c */
    #define gKeyEventNotificationMode_d gKbdEventShortLongPressMode_c
    /* The iterations required for key long press detection. The detection threshold is gKbdLongKeyIterations_c x gKeyScanInterval_c milliseconds. */
    #define gKbdLongKeyIterations_c 20
    /* The iterations required for key hold detection. 1 second, if gKeyScanInterval_c = 50ms */
    #define gKbdFirstHoldDetectIterations_c 20
    /* The iterations required for key hold detection (repetitive generation of event). May be the same value as gKbdFirstHoldDetectIterations_c. 1 second, if gKeyScanInterval_c = 50ms */
    #define gKbdHoldDetectIterations_c 20
    /* Constant for a key press. A short key will be returned after this number of milliseconds if pressed. Make sure this constant is long enough for debounce time. Default is 50 milliseconds */
    #define gKeyScanInterval_c 50
/* GPIO IRQ adapter */
    /* Configures the maximum number of entries in the GPIO ISR callback table. */
    #define gGpioMaxIsrEntries_c (5)


/* Kinetis MKW40Z DCDC Driver Reference */
    /* DCDC.h */
    /* Enables/Disables DCDC related code and variables for DCDC platform component. It is set to FALSE by default. */
    #define gDCDC_Enabled_d   FALSE

 

but not all appeared in app_preinclude.h, should they ?

 

A strange thing that in the timer set-up TimersManager.h is missed  osNumberOfTimers  count 

#ifndef gTmrTotalTimers_c
#define gTmrTotalTimers_c   ( gTmrApplicationTimers_c + gTmrStackTimers_c )
#endif

should become :

gTmrTotalTimers_c   ( gTmrApplicationTimers_c + gTmrStackTimers_c + osNumberOfTimers )  ?

 

I did not find any stack overflow check for total (should be ?) :

 

#define gTmrTaskStackSize_c               500
#define gSerialTaskStackSize_c            1024
#define gMainThreadStackSize_c          1024

#define gControllerTaskStackSize_c       900

#define gHost_TaskStackSize_c             1300

#define gAppIdleTaskStackSize_c         (400)
#define gFwkCommonStackSize_c

 

Why BOARD_LTC_INSTANCE is defined in board.h and not in app_preinclude.h ?

#define BOARD_LTC_INSTANCE              0

of predefined in SecLib.h; can take other values than 0 ?

 

#ifndef BOARD_LTC_INSTANCE
   #define BOARD_LTC_INSTANCE 0
#endif

 

Thank you,

Lucian.

Outcomes