M051 SysCtl Peripheral Driver. More...
|
Modules | |
| SysCtl_Peripheral_ID | |
Values that can be passed to the xSysCtlPeripheralPresent(), xSysCtlPeripheralEnable(), xSysCtlPeripheralDisable(), and xSysCtlPeripheralReset() APIs as the ulPeripheral parameter. | |
| M051 SysCtl Peripheral clock source | |
The following are values that can be passed to the SysCtlPeripheralClockSourceSet() API as the ulPeripheralsrc parameter. | |
| M051 SysCtl Hclk source | |
The following are values that can be passed to the SysCtlHClockSourceSet()\ SysCtlHClockSet API as the ulhclkSrcSel parameter. | |
| M051 SysCtl Stick Source | |
The following are values that can be passed to the SysCtlSysTickSourceSet() API as the ulstclkSrcSel parameter. | |
| M051 SysCtl Reset source | |
The following are values that can be returned in the bit mask by the SysCtlResetSrcGet() API. | |
| M051 SysCtl Bod level | |
The following are values that can be passed to the SysCtlSelectBODVolt() API as the ulVoltage parameter. | |
| M051 SysCtl Peripheral clock | |
The following are values that can be passed to the SysCtlIPClockDividerSet() API as the ulConfig parameter. | |
| M051 SysCtl Clock configure | |
The following are values that can be passed to the SysCtlClockSet() API as the ulConfig parameter. | |
| M051 SysCtl Exported APIS | |
The whole SysCtl Exported APIS. | |
M051 SysCtl Peripheral Driver.
The CoX Peripheral Library also provide APIs for function full functions of Nuvoton M051 SysCtl.This module supports the whole M051 Series.
The system control block has the following functions:
The SysCtl API is broken into three groups of functions:
The SysCtl clock control are dealed with :
The SysCtl clock control are dealed with :
The SysCtl power control are dealed with :
The following example shows how to use the SysCtl API to configure the system clock,enable the relative peripheral,put the processor into sleep mode,and then wake up by Extern Interrupt 0;
#include "xhw_types.h" #include "xhw_memmap.h" #include "xcore.h" #include "xhw_sysctl.h" #include "xsysctl.h" #include "xhw_ints.h" #include "xgpio.h" #include "xhw_nvic.h" #include "xhw_gpio.h" //***************************************************************************** // // Enter Sleep Mode function. // This function will force the processor enter sleep mode. // //***************************************************************************** void PWRCtl_Standby(void) { // // Enter Puts the processor into deep-sleep mode. // SysCtlDeepSleep(); } //***************************************************************************** // // brief Init uart to print. // // details uart config as (115200, 8 data bit, 1 stop bit , no partiy) // //***************************************************************************** void TestIOInit(void) { // // Set system clock // xSysCtlClockSet(50000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_12MHZ); xSPinTypeUART(UART0RX,PD0); xSPinTypeUART(UART0TX,PD1); xSysCtlPeripheralReset(xSYSCTL_PERIPH_UART0); xSysCtlPeripheralEnable(xSYSCTL_PERIPH_UART0); xSysCtlPeripheralClockSourceSet(xSYSCTL_PERIPH_UART_S_EXT12M,1); xUARTConfigSet(UART0_BASE,115200,xUART_CONFIG_WLEN_8 | xUART_CONFIG_STOP_1 | xUART_CONFIG_PAR_NONE)); xSysCtlDelay(10000); } //***************************************************************************** // // brief print a char. // // param A char // // return None. // //***************************************************************************** void TestIOPut(char ch) { uint8_t c; c = ch; while((xHWREG(UART_BASE + UART_FSR) & (0x400000))!=0x400000); // // Write this character to the transmit FIFO. // xHWREG(UART_BASE + UART_THR) = c; } //***************************************************************************** // // Wake up mcu from sleep mode function using extern interrupt. // // This function use extern interrupt to wake up mcu from sleep mode // // return None //***************************************************************************** void PWR_WKUP_Init(void) { xIntEnable(INT_EINT1); xIntPrioritySet(INT_EINT1, 1); GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_15,GPIO_DIR_MODE_IN); GPIOPinIntEnable(GPIO_PORTB_BASE, GPIO_PIN_15,GPIO_FALLING_EDGE); } //***************************************************************************** // // The main function of the PWR_WKUP // //***************************************************************************** int main(void) { // //UART initialize // TestIOInit(); PWR_WKUP_Init(); while(1) { PWRCtl_Standby(); TestIOPut('O'); TestIOPut('K'); } }