This section describes the programming interface of the CMT HAL driver.
|
enum | cmt_status_t |
| Error codes for the CMT driver.
|
|
enum | cmt_mode_t {
kCMTDirectIROCtl = 0x00U,
kCMTTimeMode = 0x01U,
kCMTFSKMode = 0x05U,
kCMTBasebandMode = 0x09U
} |
| The modes of CMT. More...
|
|
enum | cmt_int_t {
kCMTModeBitMask = 0x0DU,
kCMTModulCountMask = 0xFFFF
} |
| The CMT macro definition for a specific value. More...
|
|
enum | cmt_primary_clkdiv_t {
kCMTPriClkDiv1 = 0U,
kCMTPriClkDiv2 = 1U,
kCMTPriClkDiv3 = 2U,
kCMTPriClkDiv4 = 3U,
kCMTPriClkDiv5 = 4U,
kCMTPriClkDiv6 = 5U,
kCMTPriClkDiv7 = 6U,
kCMTPriClkDiv8 = 7U,
kCMTPriClkDiv9 = 8U,
kCMTPriClkDiv10 = 9U,
kCMTPriClkDiv11 = 10U,
kCMTPriClkDiv12 = 11U,
kCMTPriClkDiv13 = 12U,
kCMTPriClkDiv14 = 13U,
kCMTPriClkDiv15 = 14U,
kCMTPriClkDiv16 = 15U
} |
| The CMT clock divide primary prescaler. More...
|
|
enum | cmt_second_clkdiv_t {
kCMTSecClkDiv1 = 0U,
kCMTSecClkDiv2 = 1U,
kCMTSecClkDiv4 = 2U,
kCMTSecClkDiv8 = 3U
} |
| The CMT clock divide secondary prescaler. More...
|
|
enum | cmt_iro_polarity_t {
kCMTIROActiveLow = 0U,
kCMTIROActiveHigh = 1U
} |
| The CMT output polarity. More...
|
|
enum | cmt_iro_ctl_t {
kCMTIROCtlLow = 0U,
kCMTIROCtlHigh = 1U
} |
| The CMT IRO latch control. More...
|
|
|
static void | CMT_HAL_SetCGCountOne (CMT_Type *base, uint32_t highCount, uint32_t lowCount) |
| Sets the primary data set for the CMT carrier generator counter. More...
|
|
static void | CMT_HAL_SetCGCountTwo (CMT_Type *base, uint32_t highCount, uint32_t lowCount) |
| Sets the secondary data set for the CMT carrier generator counter. More...
|
|
static void | CMT_HAL_SetModulateMarkCount (CMT_Type *base, uint32_t markCount) |
| Sets the modulation mark time period for the CMT modulator counter. More...
|
|
static void | CMT_HAL_SetModulateSpaceCount (CMT_Type *base, uint32_t spaceCount) |
| Sets the modulation space time period for the CMT modulator counter. More...
|
|
Enumerator |
---|
kCMTDirectIROCtl |
Carrier modulator is disabled and the IRO signal is directly in software control.
|
kCMTTimeMode |
Carrier modulator is enabled in time mode.
|
kCMTFSKMode |
Carrier modulator is enabled in FSK mode.
|
kCMTBasebandMode |
Carrier modulator is enabled in baseband mode.
|
Enumerator |
---|
kCMTModeBitMask |
CMT mode bit mask.
|
kCMTModulCountMask |
CMT modulator count mask.
|
Enumerator |
---|
kCMTPriClkDiv1 |
The intermediate frequency is the bus clock divided by 1.
|
kCMTPriClkDiv2 |
The intermediate frequency is the bus clock divided by 2.
|
kCMTPriClkDiv3 |
The intermediate frequency is the bus clock divided by 3.
|
kCMTPriClkDiv4 |
The intermediate frequency is the bus clock divided by 4.
|
kCMTPriClkDiv5 |
The intermediate frequency is the bus clock divided by 5.
|
kCMTPriClkDiv6 |
The intermediate frequency is the bus clock divided by 6.
|
kCMTPriClkDiv7 |
The intermediate frequency is the bus clock divided by 7.
|
kCMTPriClkDiv8 |
The intermediate frequency is the bus clock divided by 8.
|
kCMTPriClkDiv9 |
The intermediate frequency is the bus clock divided by 9.
|
kCMTPriClkDiv10 |
The intermediate frequency is the bus clock divided by 10.
|
kCMTPriClkDiv11 |
The intermediate frequency is the bus clock divided by 11.
|
kCMTPriClkDiv12 |
The intermediate frequency is the bus clock divided by 12.
|
kCMTPriClkDiv13 |
The intermediate frequency is the bus clock divided by 13.
|
kCMTPriClkDiv14 |
The intermediate frequency is the bus clock divided by 14.
|
kCMTPriClkDiv15 |
The intermediate frequency is the bus clock divided by 15.
|
kCMTPriClkDiv16 |
The intermediate frequency is the bus clock divided by 16.
|
Enumerator |
---|
kCMTSecClkDiv1 |
The CMT clock is the intermediate frequency frequency divided by 1.
|
kCMTSecClkDiv2 |
The CMT clock is the intermediate frequency frequency divided by 2.
|
kCMTSecClkDiv4 |
The CMT clock is the intermediate frequency frequency divided by 4.
|
kCMTSecClkDiv8 |
The CMT clock is the intermediate frequency frequency divided by 8.
|
Enumerator |
---|
kCMTIROActiveLow |
The CMT IRO signal is active-low.
|
kCMTIROActiveHigh |
The CMT IRO signal is active-high.
|
Enumerator |
---|
kCMTIROCtlLow |
The CMT IRO signal is controlled to low.
|
kCMTIROCtlHigh |
The CMT IRO signal is controlled to high.
|
void CMT_HAL_Init |
( |
CMT_Type * |
base | ) |
|
This function initializes the CMT module. All control and data settings are cleared after initialization.
- Parameters
-
base | Base address for current CMT instance. |
static void CMT_HAL_SetMode |
( |
CMT_Type * |
base, |
|
|
cmt_mode_t |
mode |
|
) |
| |
|
inlinestatic |
This function selects the mode for CMT. The function is called during CMT initialization.
- Parameters
-
base | Base address for current CMT instance. |
mode | Selection of CMT feature mode enumeration. See to "cmt_mode_t". |
This function gets the mode of the CMT module .
- Parameters
-
base | Base address for current CMT instance. |
- Returns
- The mode of CMT module, See to "cmt_mode_t".
static void CMT_HAL_EnableExtendSpace |
( |
CMT_Type * |
base | ) |
|
|
inlinestatic |
This function enables the extended space operation for the CMT modulator. It enlarges the space period for CMT and causes subsequent modulator cycles to be spaces for the duration of the modulator. It should be used in the CMT time, baseband, or FSK mode. This means it's valid when the CMT carrier generator and modulator is enabled.
- Parameters
-
base | Base address for current CMT instance. |
static void CMT_HAL_DisableExtendSpace |
( |
CMT_Type * |
base | ) |
|
|
inlinestatic |
This function disables the extended space operation for the CMT modulator. It can be used to return the modulator to a standard operation when the extended space operation has been enabled.
- Parameters
-
base | Base address for current CMT instance. |
static bool CMT_HAL_IsExtendSpace |
( |
CMT_Type * |
base | ) |
|
|
inlinestatic |
This function finds out whether the extended space is enabled for the CMT modulator. When the carrier generator and modulator is enabled, this function can be used to check whether the extended space feature is opened or not.
- Parameters
-
base | Base address for the current CMT instance. |
- Returns
- Current status of the extended space feature.
- true: the extended space feature is enabled.
- false: the extended space feature is disabled.
static void CMT_HAL_SetCGCountOne |
( |
CMT_Type * |
base, |
|
|
uint32_t |
highCount, |
|
|
uint32_t |
lowCount |
|
) |
| |
|
inlinestatic |
This function sets the high time and low time of the primary data set for the CMT carrier generator counter to control the period and the duty cycle of the output carrier signal. If the CMT clock period is Tcmt, The period of the carrier generator signal equals (highCount + lowCount) * Tcmt. The duty cycle equals highCount / (highCount + lowCount).
- Parameters
-
base | Base address for current CMT instance. |
highCount | The number of CMT clocks for carrier generator signal high time, integer in the range of 0 ~ 0xFF. |
lowCount | The number of CMT clocks for carrier generator signal low time, integer in the range of 0 ~ 0xFF. |
static void CMT_HAL_SetCGCountTwo |
( |
CMT_Type * |
base, |
|
|
uint32_t |
highCount, |
|
|
uint32_t |
lowCount |
|
) |
| |
|
inlinestatic |
This function sets the high time and low time of the secondary data set CMT carrier generator counter to control the period and the duty cycle of the output carrier signal. If the CMT clock period is Tcmt, The period of the carrier generator signal equals (highCount + lowCount) * Tcmt. The duty cycle equals highCount / (highCount + lowCount). This data set is mainly used for FSK mode.
- Parameters
-
base | Base address for current CMT instance. |
highCount | The number of CMT clocks for carrier generator signal high time, integer in the range of 0 ~ 0xFF. |
lowCount | The number of CMT clocks for carrier generator signal low time, integer in the range of 0 ~ 0xFF. |
static void CMT_HAL_SetModulateMarkCount |
( |
CMT_Type * |
base, |
|
|
uint32_t |
markCount |
|
) |
| |
|
inlinestatic |
This function sets the mark time period of the CMT modulator counter to control the mark time of the output modulated signal from the carrier generator output signal. If the CMT clock frequency is Fcmt and the carrier out signal frequency is fcg:
- In Time and Baseband mode: The mark period of the generated signal equals (markCount + 1) / (Fcmt/8).
- In FSK mode:The mark period of the generated signal equals (markCount + 1)/fcg.
- Parameters
-
base | Base address for current CMT instance. |
markCount | The number of clock period for CMT modulator signal mark period, in the range of 0 ~ 0xFFFF. |
static void CMT_HAL_SetModulateSpaceCount |
( |
CMT_Type * |
base, |
|
|
uint32_t |
spaceCount |
|
) |
| |
|
inlinestatic |
This function sets the mark time period of the CMT modulator counter to control the space time of the output modulated signal from the carrier generator output signal. If the CMT clock frequency is Fcmt and the carrier out signal frequency is fcg:
- In Time and Baseband mode: The space period of the generated signal equals spaceCount / (Fcmt/8).
- In FSK mode:The space period of the generated signal equals spaceCount/fcg.
- Parameters
-
base | Base address for current CMT instance. |
spaceCount | The number of clock period for CMT modulator signal space period, in the range of 0 ~ 0xFFFF. |
There are two prescalers with 8 MHz or higher frequency in the clock divider block for the CMT flexible clock frequency generation from the bus clock.
- Parameters
-
base | Base address for current CMT instance. |
ppsDiv | The primary prescaler divider. ppsDiv should be a integer range between 0 ~ 15 representing the divisor 1 ~ 16 (See "cmt_primary_clkdiv_t"). It divides the bus clock to generate the Intermediate Frequency clock. The Intermediate frequency (IF) clock should be approximately 8 MHz. For example, if the bus clock is 50 MHz, ppsDiv should be set to kCMTPriClkDivSix, then IF = 50 MHz/6 = 8.333.333... . if the bus clock is 8 MHz, ppsDiv should be set to kCMTPriClkDivOne. |
spsDiv | The secondary prescaler divider. The CMT carrier generator resolution is 8Mhz/(2 ^ spsDiv) . spsDiv should be a integer range between 0 ~ 3 representing the divisor 1,2,4 and 8 (See "cmt_second_clkdiv_t"). |
- Parameters
-
base | Base address for current CMT instance. |
- Returns
- The CMT primary clock divider.
- Parameters
-
base | Base address for current CMT instance. |
- Returns
- The CMT secondary clock divider.
static void CMT_HAL_SetIntCmd |
( |
CMT_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
If enabled, an interrupt occurs at the end of the modulator cycle or when the CMT_HAL_IsEndofCycle returns true. (Note: NVIC should be called to enable the CMT interrupt on the system level).
- Parameters
-
base | Base address for current CMT instance. |
enable | Enable or disable interrupt.
- true: CPU interrupt is enabled.
- false: CPU interrupt is disabled.
|
static bool CMT_HAL_GetIntCmd |
( |
CMT_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | Base address for current CMT instance. |
- Returns
- Status of enabled or disabled interrupt
- true: Interrupt is enabled.
- false: Interrupt is disabled.
static bool CMT_HAL_IsEndofCycle |
( |
CMT_Type * |
base | ) |
|
|
inlinestatic |
The flag is set:
- When the modulator is not currently active and carrier and modulator is set to start the initial CMT transmission.
- At the end of each modulation cycle when the counter is reloaded and the carrier and modulator are enabled.
- Parameters
-
base | Base address for current CMT instance. |
- Returns
- Current status of the end of cycle status flag
true: End-of-cycle has occurred.
- false: End-of-cycle has not yet occurred since the flag last cleared.
static void CMT_HAL_SetDMACmd |
( |
CMT_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
If enabled, a DMA transfer request occurs at the end of the modulator cycle when the end-of-cycle interrupt is enabled.
- Parameters
-
base | Base address for current CMT instance. |
enable | Enable or disable DMA.
- true: DMA transfer request and done are enabled.
- false: DMA transfer request and done are disabled.
|
static bool CMT_HAL_GetDMACmd |
( |
CMT_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | Base address for current CMT instance. |
- Returns
- Status of enabled or disabled DMA
- true: DMA is enabled.
- false: DMA is disabled.
- Parameters
-
base | Base address for current CMT instance. |
polarVal | The polarity of the IRO signal. See "cmt_iro_polarity_t" |
static void CMT_HAL_SetIroCmd |
( |
CMT_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
This function enables and disables the IRO signal. When the IRO signal is enabled, it is an output that drives out either the CMT transmitter output or the state of IRO latch control depending on whether the carrier modulator is enabled.
- Parameters
-
base | Base address for current CMT instance. |
enable | Enable or disable IRO signal.
- true: The IRO signal is enabled.
- false: The IRO signal is disabled.
|
static void CMT_HAL_SetIroCtl |
( |
CMT_Type * |
base, |
|
|
cmt_iro_ctl_t |
ctlVal |
|
) |
| |
|
inlinestatic |
This function changes the states of the IRO signal when the kCMTDirectIROMode mode is set and the IRO signal is enabled.
- Parameters
-
base | Base address for current CMT instance. |
ctlVal | The control of the IRO signal. See "cmt_iro_ctl_t" |
static bool CMT_HAL_GetIrolatchState |
( |
CMT_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | Base address for current CMT instance. |
- Returns
- The states of the IRO latch