AHI-Compatible Functions
Some of the AHI functions are implemented for source-level compatibility.
- This library is implemented using the TWENETmwf library, which aggregates procedures from the FSL drivers.
- This implementation is not intended to maintain complete compatibility.
- Functions with proprietary extensions have
_MW
appended to their names. - Notes and considerations known at the time of writing are documented here.
- Internal implementations may change without notice.
- For parameters mentioned in the explanations, only items requiring attention are described; for omitted parts, refer to the original AHI library manual.
- For topics specific to TWELITE GOLD, the FSL library, and MCU core behavior, refer to NXP’s JN5189 reference manual and the TWENETmcu library implementation.
The following describes the AHI-compatible functions. Some items such as SPI and I2C are documented in separate files.
General Functions
u32AHI_Init()
uint32 u32AHI_Init();
Performs initialization for the AHI library in principle, but in this library, only a subset of variables is initialized.
bAHI_SetClockRate(), u8AHI_GetSystemClkRate()
bool_t bAHI_SetClockRate(uint8 u8clk_code);
uint8 u8AHI_GetSystemClkRate();
Sets or retrieves the CPU clock speed.
The configured clock values differ significantly from those of TWELITE BLUE/RED, so caution is required.
u8clk_code | TWELITE BLUE/RED | TWELITE GOLD |
---|---|---|
0 | 4Mhz | 12Mhz |
1 | 8Mhz | 12Mhz |
2 | 16Mhz | 32Mhz |
3 | 32Mhz | 48Mhz |
4.. | Configurable | Ignored |
- Although clocks such as
kFROM1M_to_MAIN_CLK
can be configured in the fsl library, they are disabled here due to severe operational issues. - Using a debugger may interfere with clock changes.
- The default value is 2, corresponding to 32Mhz (TWELITE GOLD). (Reference: 16MHz on TWELITE BLUE/RED)
bAHI_Set32KhzClockMode()
bool_t bAHI_Set32KhzClockMode(uint8 u8mode);
Does nothing.
vAHI_CpuDoze()
static inline void vAHI_CpuDoze() { __WFI(); }
Enters the low-power DOZE state while waiting for interrupts. On TWELITE-GOLD, it issues WFI (Wait For Interrupt).
vAHI_SwReset()
static inline void vAHI_SwReset() { NVIC_SystemReset(); }
Performs a reset.
Power-Related Functions
u16AHI_PowerStatus()
uint16 u16AHI_PowerStatus();
This function reports the following bitmaps:
Bit | Description |
---|---|
bit0 | 1 when waking up from sleep |
bit1 | 1 when RAM was retained |
At POR, the value is 0
, and for normal wake-up from RAM-retention sleep, the value is 3
.
vAHI_BrownOutConfigure()
static inline void vAHI_BrownOutConfigure(
uint8 const u8VboSelect,
bool_t const bVboRstEn,
bool_t const bVboEn,
bool_t const bVboIntEnFalling,
bool_t const bVboIntEnRising) { ; } // DUMMY FUNC
This definition exists only to avoid compilation errors. The function itself does nothing.
About Sleep
void ToCoNet_vSleep(uint8 u8Device, uint32 u32Periodms, bool_t bPeriodic, bool_t bRamOff)
Sleep in the TWENET C library uses the ToCoNet_vSleep()
function.
Note: In the mwx library, use the_twelite.sleep()
.
- If
bRamOff
is set to TRUE, the system enters sleep mode without retaining any RAM segments. Even in this case,PM_POWER_DOWN
from the JN518x FSL library definitions is used, notPM_DEEP_DOWN
.
About Sleep Failures (TWELITE GOLD)
On TWELITE GOLD, the procedure for sleep transition (POWER_EnterPowerMode()
) in the semiconductor library occasionally fails, resulting in the device not entering sleep mode. To address this, the following measures are taken:
- When the semiconductor library procedure fails, the function exits immediately, but after a delay loop equivalent to 100 µsec (
DelayLoopN(100)
), the sleep procedure is retried. - If the above retry fails 3 times,
ToCoNet_vSleep()
enters an infinite loop, and a watchdog timer reset normally occurs. In our experience, 2 or 3 retries have not been observed, but we allow up to 3 retries as a precaution. - After executing the above sleep procedure, if the value of
extern uint8 g_twenet_power_down_fails;
is non-zero upon waking up from sleep, it indicates that retries were performed. However, this variable is reset when a watchdog timer reset occurs.
For internal processing
u32AppApiInit()
uint32
u32AppApiInit(PR_GET_BUFFER prMlmeGetBuffer,
PR_POST_CALLBACK prMlmeCallback,
void *pvMlmeParam,
PR_GET_BUFFER prMcpsGetBuffer,
PR_POST_CALLBACK prMcpsCallback,
void *pvMcpsParam);
Performs the initialization process for AppQAPI.
vAHI_RegEvMgr_MW()
void vAHI_RegEvMgr_MW();
Constructs the management object (mwf::the_sys_ev_manager
) for managing class objects in the TWENETmwf library.
vAHI_OnWakeup_MW(), vAHI_OnWakeupRamOff_MW()
void vAHI_OnWakeup_MW(bool_t b_init_2nd);
void vAHI_OnWakeupRamOff_MW(bool_t b_init_2nd);
This procedure is executed upon wake-up. Refer to the processing in twenet_main.c
of TWENETmcu.
- Executes the wake-up processing of class objects in the TWENETmwf library:
mwf::the_sys_ev_manager->on_wakeup()
. - Calls
vAHI_DioOnWakeup_MW()
to store the pins that triggered the wake-up. - If
b_init_2nd
is FALSE, it is called in the early stage of startup; if TRUE, it is called after a certain amount of initialization has been completed (beforecbAppWarmStart(TRUE)
is called).
vAHI_OnWakeupRamOff_MW()
is called when waking up from RAM non-retentive sleep.
- If
b_init_2nd
is FALSE, it is called in the early stage of startup; if TRUE, it is called after a certain amount of initialization has been completed (aftercbAppWarmStart(TRUE)
is called).
vAHI_OnSleep_MW()
vAHI_OnSleep_MW();
This procedure is executed before entering sleep.
- Executes the pre-sleep processing of class objects in the TWENETmwf library:
mwf::the_sys_ev_manager->on_sleep()
. - Calls
vAHI_DioOnSleep_MW()
to configure the DIO wake-up pins.
vAHI_DMAEnable_MW(), vAHI_DMADisable_MW()
void vAHI_DMAEnable_MW();
void vAHI_DMADisable_MW();
Enables or disables the DMA feature.
vAHI_DMADisable_MW()
does not perform any operation.