#include "inc/hw_types.h"
#include "driverlib/5xx_6xx/cs_a.h"
#include "deprecated/CCS/msp430xgeneric.h"
#include "driverlib/5xx_6xx/debug.h"
#include "inc/sfr_sys_baseAddress.h"
Functions | |
void | CSA_setExternalClockSource (unsigned int baseAddress, unsigned long LFXTCLK_frequency, unsigned long HFXTCLK_frequency) |
void | CSA_clockSignalInit (unsigned int baseAddress, unsigned char selectedClockSignal, unsigned int clockSource, unsigned int clockSourceDivider) |
void | CSA_LFXTStart (unsigned int baseAddress, unsigned int lfxtdrive) |
void | CSA_bypassLFXT (unsigned int baseAddress) |
unsigned short | CSA_LFXTStartWithTimeout (unsigned int baseAddress, unsigned int lfxtdrive, unsigned long timeout) |
unsigned short | CSA_bypassLFXTWithTimeout (unsigned int baseAddress, unsigned long timeout) |
void | CSA_LFXTOff (unsigned int baseAddress) |
void | CSA_HFXTStart (unsigned int baseAddress, unsigned int hfxtdrive) |
void | CSA_bypassHFXT (unsigned int baseAddress) |
unsigned short | CSA_HFXTStartWithTimeout (unsigned int baseAddress, unsigned int hfxtdrive, unsigned long timeout) |
unsigned short | CSA_bypassHFXTWithTimeout (unsigned int baseAddress, unsigned long timeout) |
void | CSA_HFXTOff (unsigned int baseAddress) |
void | CSA_enableClockRequest (unsigned int baseAddress, unsigned char selectClock) |
void | CSA_disableClockRequest (unsigned int baseAddress, unsigned char selectClock) |
unsigned char | CSA_faultFlagStatus (unsigned int baseAddress, unsigned char mask) |
void | CSA_clearFaultFlag (unsigned int baseAddress, unsigned char mask) |
unsigned long | privateCSASourceClockFromDCO (unsigned int baseAddress, unsigned char clockdivider) |
unsigned long | privateCSAComputeCLKFrequency (unsigned int baseAddress, unsigned int CLKSource, unsigned int CLKSourceDivider) |
unsigned long | CSA_getACLK (unsigned int baseAddress) |
unsigned long | CSA_getSMCLK (unsigned int baseAddress) |
unsigned long | CSA_getMCLK (unsigned int baseAddress) |
void | CSA_VLOoff (unsigned int baseAddress) |
unsigned int | CSA_clearAllOscFlagsWithTimeout (unsigned int baseAddress, unsigned long timeout) |
void | CSA_setDCOFreq (unsigned int baseAddress, unsigned int dcorsel, unsigned int dcofsel) |
Variables | |
unsigned long | CSA_LFXTClockFrequency = 0 |
unsigned long | CSA_HFXTClockFrequency = 0 |
void CSA_setExternalClockSource | ( | unsigned int | baseAddress, |
unsigned long | LFXTCLK_frequency, | ||
unsigned long | HFXTCLK_frequency | ||
) |
This function sets the external clock sources LFXT and HFXT crystal oscillator frequency values. This function must be called if an external crystal LFXT or HFXT is used and the user intends to call CSA_getMCLK, CSA_getSMCLK, CSA_getACLK and CSA_LFXTStart, CSA_LFXTByPass, CSA_LFXTStartWithTimeout, CSA_LFXTByPassWithTimeout, CSA_HFXTStart, CSA_HFXTByPass, CSA_HFXTStartWithTimeout, CSA_HFXTByPassWithTimeout.
baseAddress | is the base address of the CSA module. |
LFXTCLK_frequency | is the LFXT crystal frequencies in Hz |
HFXTCLK_frequency | is the HFXT crystal frequencies in Hz |
References CSA_HFXTClockFrequency, and CSA_LFXTClockFrequency.
void CSA_clockSignalInit | ( | unsigned int | baseAddress, |
unsigned char | selectedClockSignal, | ||
unsigned int | clockSource, | ||
unsigned int | clockSourceDivider | ||
) |
This function initializes each of the clock signals. The user must ensure that this function is called for each clock signal. If not, the default state is assumed for the particular clock signal. Refer MSP430ware documentation for CSA module or Device Family User's Guide for details of default clock signal states.
baseAddress | is the base address of the CSA module. |
selectedClockSignal | - Valid values are CSA_ACLK, CSA_MCLK, CSA_SMCLK, |
clockSource | is Clock source for the selectedClock Signal CSA_LFXTCLK_SELECT, CSA_VLOCLK_SELECT, CSA_DCOCLK_SELECT, [Not available for ACLK] CSA_HFXTCLK_SELECT, [Not available for ACLK] CSA_LFMODOSC_SELECT, CSA_MODOSC_SELECT [Not available for ACLK] |
clockSourceDivider | - selected the clock divider to calculate clock signal from clock source. Valid values are CSA_CLOCK_DIVIDER_1, [Default for ACLK] CSA_CLOCK_DIVIDER_2, CSA_CLOCK_DIVIDER_4, CSA_CLOCK_DIVIDER_8, [Default for SMCLK and MCLK] CSA_CLOCK_DIVIDER_16, CSA_CLOCK_DIVIDER_32 |
Modified registers are CSCTL0, CSCTL2, CSCTL3
References ASSERT, CSA_ACLK, CSA_CLOCK_DIVIDER_1, CSA_CLOCK_DIVIDER_16, CSA_CLOCK_DIVIDER_2, CSA_CLOCK_DIVIDER_32, CSA_CLOCK_DIVIDER_4, CSA_CLOCK_DIVIDER_8, CSA_DCOCLK_SELECT, CSA_HFXTCLK_SELECT, CSA_LFMODOSC_SELECT, CSA_LFXTCLK_SELECT, CSA_MCLK, CSA_MODOSC_SELECT, CSA_SMCLK, CSA_VLOCLK_SELECT, and HWREG.
void CSA_LFXTStart | ( | unsigned int | baseAddress, |
unsigned int | lfxtdrive | ||
) |
Initializes the LFXT crystal oscillator in low frequency mode. Loops until all oscillator fault flags are cleared, with no timeout. See the device-specific data sheet for appropriate drive settings. IMPORTANT: User must call CSA_setExternalClockSource function to set frequency of external clocks this function is call.
baseAddress | is the base address of the CS module. |
lfxtdrive | is the target drive strength for the LFXT crystal oscillator. Valid values: CSA_LFXT_DRIVE0, CSA_LFXT_DRIVE1, CSA_LFXT_DRIVE2, CSA_LFXT_DRIVE3. [Default] Modified registers are CSCTL0, CSCTL4, CSCTL5 and SFRIFG1 |
References ASSERT, CSA_LFXT_DRIVE0, CSA_LFXT_DRIVE1, CSA_LFXT_DRIVE2, CSA_LFXT_DRIVE3, CSA_LFXTClockFrequency, HWREG, HWREGB, and SFR_BASEADDRESS.
void CSA_bypassLFXT | ( | unsigned int | baseAddress | ) |
Bypasses the LFXT crystal oscillator. Loops until all oscillator fault flags are cleared, with no timeout. IMPORTANT: User must call CSA_setExternalClockSource function to set frequency of external clocks this function is call.
baseAddress | is the base address of the CS module. |
Modified registers are CSCTL0, CSCTL4, CSCTL5, SFRIFG1
References ASSERT, CSA_LFXTClockFrequency, HWREG, HWREGB, LFXT_FREQUENCY_THRESHOLD, and SFR_BASEADDRESS.
unsigned short CSA_LFXTStartWithTimeout | ( | unsigned int | baseAddress, |
unsigned int | lfxtdrive, | ||
unsigned long | timeout | ||
) |
Initializes the LFXT crystal oscillator in low frequency mode with timeout. Loops until all oscillator fault flags are cleared or until a timeout counter is decremented and equals to zero. See the device-specific datasheet for appropriate drive settings. IMPORTANT: User must call CSA_setExternalClockSource to set frequency of external clocks before calling this function
baseAddress | is the base address of the CS module. |
lfxtdrive | is the target drive strength for the LFXT crystal oscillator. Valid values are CSA_LFXTDRIVE0, CSA_LFXTDRIVE1, CSA_LFXTDRIVE2, CSA_LFXTDRIVE3. [Default] |
timeout | is the count value that gets decremented every time the loop that clears oscillator fault flags gets executed. |
Modified registers are CSCTL0, CSCTL4, CSCTL5 and SFRIFG1
References ASSERT, CSA_LFXT_DRIVE0, CSA_LFXT_DRIVE1, CSA_LFXT_DRIVE2, CSA_LFXT_DRIVE3, CSA_LFXTClockFrequency, HWREG, HWREGB, SFR_BASEADDRESS, STATUS_FAIL, and STATUS_SUCCESS.
unsigned short CSA_bypassLFXTWithTimeout | ( | unsigned int | baseAddress, |
unsigned long | timeout | ||
) |
Bypasses the LFXT crystal oscillator with time out. Loops until all oscillator fault flags are cleared or until a timeout counter is decremented and equals to zero. NOTE: User must call CSA_setExternalClockSource to set frequency of external clocks before calling this function
baseAddress | is the base address of the CS module. |
timeout | is the count value that gets decremented every time the loop that clears oscillator fault flags gets executed. |
Modified registers are CSCTL0, CSCTL4, CSCTL5, SFRIFG1
References ASSERT, CSA_LFXTClockFrequency, HWREG, HWREGB, LFXT_FREQUENCY_THRESHOLD, SFR_BASEADDRESS, STATUS_FAIL, and STATUS_SUCCESS.
void CSA_LFXTOff | ( | unsigned int | baseAddress | ) |
Stops the LFXT oscillator using the LFXTOFF bit.
baseAddress | is the base address of the CS module. |
Modified registers are CSCTL4
References HWREG.
void CSA_HFXTStart | ( | unsigned int | baseAddress, |
unsigned int | hfxtdrive | ||
) |
Initializes the HFXT crystal oscillator, which supports crystal frequencies between 0 MHz and 24 MHz, depending on the selected drive strength. Loops until all oscillator fault flags are cleared, with no timeout. See the device-specific data sheet for appropriate drive settings. NOTE: User must call CSA_setExternalClockSource to set frequency of external clocks before calling this function.
baseAddress | is the base address of the CS module. |
hfxtdrive | is the target drive strength for the HFXT crystal oscillator. Valid values are CSA_HFXTDRIVE_0, CSA_HFXTDRIVE_1, CSA_HFXTDRIVE_2, CSA_HFXTDRIVE_3 [Default] |
Modified registers are CSCTL4, CSCTL5, SFRIFG1
References ASSERT, CSA_HFXTClockFrequency, CSA_HFXTDRIVE_16MHZ_24MHZ, CSA_HFXTDRIVE_24MHZ_32MHZ, CSA_HFXTDRIVE_4MHZ_8MHZ, CSA_HFXTDRIVE_8MHZ_16MHZ, HWREG, HWREGB, and SFR_BASEADDRESS.
void CSA_bypassHFXT | ( | unsigned int | baseAddress | ) |
Bypasses the HFXT crystal oscillator, which supports crystal frequencies between 0 MHz and 24 MHz. Loops until all oscillator fault flags are cleared, with no timeout.NOTE: User must call CSA_setExternalClockSource to set frequency of external clocks before calling this function.
baseAddress | is the base address of the CS module. |
Modified registers are CSCTL4, CSCTL5, SFRIFG1
References ASSERT, CSA_HFXTClockFrequency, HWREG, HWREGB, and SFR_BASEADDRESS.
unsigned short CSA_HFXTStartWithTimeout | ( | unsigned int | baseAddress, |
unsigned int | hfxtdrive, | ||
unsigned long | timeout | ||
) |
Initializes the HFXT crystal oscillator, which supports crystal frequencies between 0 MHz and 24 MHz, depending on the selected drive strength. Loops until all oscillator fault flags are cleared or until a timeout counter is decremented and equals to zero. See the device-specific data sheet for appropriate drive settings. NOTE: User must call CSA_setExternalClockSource to set frequency of external clocks before calling this function.
baseAddress | is the base address of the CS module. |
hfxtdrive | is the target drive strength for the HFXT crystal oscillator. Valid values are CSA_HFXTDRIVE_0, CSA_HFXTDRIVE_1, CSA_HFXTDRIVE_2, CSA_HFXTDRIVE_3 [Default] |
timeout | is the count value that gets decremented every time the loop that clears oscillator fault flags gets executed. |
Modified registers are CSCTL4, CSCTL5, SFRIFG1
References ASSERT, CSA_HFXTClockFrequency, CSA_HFXTDRIVE_24MHZ_32MHZ, HWREG, HWREGB, SFR_BASEADDRESS, STATUS_FAIL, and STATUS_SUCCESS.
unsigned short CSA_bypassHFXTWithTimeout | ( | unsigned int | baseAddress, |
unsigned long | timeout | ||
) |
Bypasses the HFXT crystal oscillator, which supports crystal frequencies between 0 MHz and 24 MHz. Loops until all oscillator fault flags are cleared or until a timeout counter is decremented and equals to zero. NOTE: User must call CSA_setExternalClockSource to set frequency of external clocks before calling this function.
baseAddress | is the base address of the CS module. |
timeout | is the count value that gets decremented every time the loop that clears oscillator fault flags gets executed. |
Modified registers are CSCTL4, CSCTL5, SFRIFG1G
References ASSERT, CSA_HFXTClockFrequency, HWREG, HWREGB, SFR_BASEADDRESS, STATUS_FAIL, and STATUS_SUCCESS.
void CSA_HFXTOff | ( | unsigned int | baseAddress | ) |
Stops the HFXT oscillator using the HFXTOFF bit.
baseAddress | is the base address of the CS module. |
Modified registers are CSCTL4
References CSA_HFXTOff().
Referenced by CSA_HFXTOff().
void CSA_enableClockRequest | ( | unsigned int | baseAddress, |
unsigned char | selectClock | ||
) |
Enables conditional module requests
baseAddress | is the base address of the CS module. |
selectClock | selects specific request enables. Valid values are CSA_ACLK, CSA_SMCLK, CSA_MCLK, CSA_MODOSC |
Modified registers are CSCTL6
References ASSERT, CSA_ACLK, CSA_MCLK, CSA_MODOSC, CSA_SMCLK, and HWREGB.
void CSA_disableClockRequest | ( | unsigned int | baseAddress, |
unsigned char | selectClock | ||
) |
Disables conditional module requests
baseAddress | is the base address of the CS module. |
selectClock | selects specific request enables. Valid values are CSA_ACLK, CSA_SMCLK, CSA_MCLK, CSA_MODOSC |
Modified registers are CSCTL6
References ASSERT, CSA_ACLK, CSA_MCLK, CSA_MODOSC, CSA_SMCLK, and HWREGB.
unsigned char CSA_faultFlagStatus | ( | unsigned int | baseAddress, |
unsigned char | mask | ||
) |
Gets the current CS fault flag status.
baseAddress | is the base address of the CS module. |
mask | is the masked interrupt flag status to be returned. Mask parameter can be either any of the following selection.
|
References ASSERT, CSA_HFXTOFFG, CSA_LFXTOFFG, and HWREGB.
void CSA_clearFaultFlag | ( | unsigned int | baseAddress, |
unsigned char | mask | ||
) |
Clears the current CS fault flag status for the masked bit.
baseAddress | is the base address of the CS module. |
mask | is the masked interrupt flag status to be returned. mask parameter can be any one of the following
|
References ASSERT, CSA_HFXTOFFG, CSA_LFXTOFFG, and HWREGB.
unsigned long privateCSASourceClockFromDCO | ( | unsigned int | baseAddress, |
unsigned char | clockdivider | ||
) |
References CSA_DCO_FREQ_1, CSA_DCO_FREQ_2, CSA_DCO_FREQ_3, CSA_DCO_FREQ_4, CSA_DCO_FREQ_5, CSA_DCO_FREQ_6, CSA_DCO_FREQ_7, CSA_DCO_FREQ_8, and HWREG.
Referenced by privateCSAComputeCLKFrequency().
unsigned long privateCSAComputeCLKFrequency | ( | unsigned int | baseAddress, |
unsigned int | CLKSource, | ||
unsigned int | CLKSourceDivider | ||
) |
References CSA_HFXTClockFrequency, CSA_LFMODCLK_FREQUENCY, CSA_LFXTClockFrequency, CSA_MODCLK_FREQUENCY, CSA_VLOCLK_FREQUENCY, HWREGB, privateCSASourceClockFromDCO(), and SFR_BASEADDRESS.
Referenced by CSA_getACLK(), CSA_getMCLK(), and CSA_getSMCLK().
unsigned long CSA_getACLK | ( | unsigned int | baseAddress | ) |
Get the current ACLK frequency.
If a oscillator fault is set, the frequency returned will be based on the fail safe mechanism of CS module. The user of this API must ensure that CSA_externalClockSourceInit API was invoked before in case LFXT or HFXT is being used. User must call CSA_init before calling this function.
baseAddress | is the base address of the CS module. |
References HWREG, and privateCSAComputeCLKFrequency().
unsigned long CSA_getSMCLK | ( | unsigned int | baseAddress | ) |
Get the current SMCLK frequency.
If a oscillator fault is set, the frequency returned will be based on the fail safe mechanism of CS module. The user of this API must ensure that CSA_externalClockSourceInit API was invoked before in case LFXT or HFXT is being used. User must call CSA_init before calling this function.
baseAddress | is the base address of the CS module. |
References HWREG, HWREGB, and privateCSAComputeCLKFrequency().
unsigned long CSA_getMCLK | ( | unsigned int | baseAddress | ) |
Get the current MCLK frequency.
If a oscillator fault is set, the frequency returned will be based on the fail safe mechanism of CS module. The user of this API must ensure that CSA_externalClockSourceInit API was invoked before in case LFXT or HFXT is being used. User must call CSA_init before calling this function.
baseAddress | is the base address of the CS module. |
References HWREG, and privateCSAComputeCLKFrequency().
void CSA_VLOoff | ( | unsigned int | baseAddress | ) |
Turns off VLO
USer must call CSA_init function before invoking this function. Modified registers are CSCTL4
References HWREG.
unsigned int CSA_clearAllOscFlagsWithTimeout | ( | unsigned int | baseAddress, |
unsigned long | timeout | ||
) |
Clears all the Oscillator Flags
baseAddress | is the base address of the CS module. |
timeout | is the count value that gets decremented every time the loop that clears oscillator fault flags gets executed. |
Modified registers are CSCTL5, SFRIFG1G
References HWREGB, and SFR_BASEADDRESS.
void CSA_setDCOFreq | ( | unsigned int | baseAddress, |
unsigned int | dcorsel, | ||
unsigned int | dcofsel | ||
) |
Set DCO frequency
Before invoking the this function, the user must call CSA_init.
baseAddress | is the base address of the CS module. |
dcofsel | selects valid frequency options based on dco frequency range selection (dcorsel). Valid options are: For FR58xx/FR59xx devices: CSA_DCOFSEL_0 - Low frequency option 1 MHZ. High frequency option 1 MHz. CSA_DCOFSEL_1 - Low frequency option 2.67 MHZ. High frequency option 5.33 MHz. CSA_DCOFSEL_2 Low frequency option 3.33 MHZ. High frequency option 6.67 MHz. CSA_DCOFSEL_3 Low frequency option 4 MHZ. High frequency option 8 MHz. CSA_DCOFSEL_4 Low frequency option 5.33 MHZ. High frequency option 16 MHz. CSA_DCOFSEL_5 Low frequency option 6.67 MHZ. High frequency option 20 MHz. CSA_DCOFSEL_6 Low frequency option 8 MHZ. High frequency option 24 MHz. |
dcorsel | selects frequency range option. Valid options are: CSA_DCORSEL_0 [Default - Low Frequency Option] CSA_DCORSEL_1 [High Frequency Option] |
References ASSERT, CSA_DCOFSEL_0, CSA_DCOFSEL_1, CSA_DCOFSEL_2, CSA_DCOFSEL_3, CSA_DCOFSEL_4, CSA_DCOFSEL_5, CSA_DCOFSEL_6, CSA_DCORSEL_0, CSA_DCORSEL_1, and HWREG.
unsigned long CSA_LFXTClockFrequency = 0 |
unsigned long CSA_HFXTClockFrequency = 0 |