資源簡介
基于IAR7.8的針對S32K144的裸機DEMO
基于S32K144 EVB開發板

代碼片段和文件信息
#include?“S32K144.h“
#include?“S32K144_features.h“
#define?RED?????15
#define?GREEN???16
#define?BLUE????0
#define?BTN0????12
#define?BTN1????13
#define?BIT(n)??(1?<(n))
typedef?unsigned?char???u8;
typedef?unsigned?short??u16;
typedef?unsigned?long???u32;
typedef?enum
{
????????false?=?0
????????true
}?bool;
typedef?enum
{
????????CLK_SRC_OFF???=?0x00U?????????????/*?Clock?is?off?*/
????????CLK_SRC_SOSC??=?0x01U?????????????/*?OSCCLK?-?System?Oscillator?Bus?Clock?*/
????????CLK_SRC_SIRC??=?0x02U?????????????/*?SCGIRCLK?-?Slow?IRC?Clock?*/
????????CLK_SRC_FIRC??=?0x03U?????????????/*?SCGFIRCLK?-?Fast?IRC?Clock?*/
????????CLK_SRC_SPLL??=?0x06U??????????????/*?SCGPCLK?System?PLL?clock?*/
????????
}?peripheral_clock_source_t;
const?u16?clockNameMappings[]?=?PCC_CLOCK_NAME_MAPPINGS;
static?inline?void?PCC_HAL_SetClockMode(PCC_Type*?const?base?const?clock_names_t?clockName?const?bool?isClockEnabled)
{
????u32?regValue?=?(u32)base->PCCn[clockNameMappings[clockName]];
????regValue?&=?(u32)(~(PCC_PCCn_CGC_MASK));
????regValue?|=?PCC_PCCn_CGC((isClockEnabled?==?true)???1UL?:?0UL);
????base->PCCn[clockNameMappings[clockName]]?=?(u32)regValue;
}
static?inline?void?PCC_HAL_SetClockSourceSel(PCC_Type*?const?base?const?clock_names_t?clockName?const?peripheral_clock_source_t?clockSource)
{
????u32?clkSource?regValue;
????
????switch(clockSource)
????{
????????case?CLK_SRC_SPLL:
????????????clkSource?=?6U;
????????????break;
????????case?CLK_SRC_FIRC:
????????????clkSource?=?3U;
????????????break;
????????case?CLK_SRC_SIRC:
????????????clkSource?=?2U;
????????????break;
????????case?CLK_SRC_SOSC:
????????????clkSource?=?1U;
????????????break;
????????case?CLK_SRC_OFF:
????????/*?Pass-thourgh?*/
????????default:
????????????clkSource?=?0U;
????????????break;
????}
????
????regValue?=?base->PCCn[clockNameMappings[clockName]];
????regValue?&=?~(PCC_PCCn_PCS_MASK);
????regValue?|=?PCC_PCCn_PCS(clkSource);
????base->PCCn[clockNameMappings[clockName]]?=?regValue;????
}
/**
?*?PTD15->?RGB_RED
?*?PTD16->?RGB_GREEN
?*?PTD0?->?RGB_BLUE
?*?BTN0?->?PTC12
?*?BTN1?->?PTC13
?*/
#define?LED_PORT_PCC????PCC_PORTD_CLOCK
#define?BTN_PORT_PCC????PCC_PORTC_CLOCK
static?void?Gpio_Config(void)
{
????????//config?clock?source
????????PCC_HAL_SetClockMode(PCC?LED_PORT_PCC?false);
????????PCC_HAL_SetClockSourceSel(PCC?LED_PORT_PCC?CLK_SRC_FIRC);
????????PCC_HAL_SetClockMode(PCC?LED_PORT_PCC?true);
????????PCC_HAL_SetClockMode(PCC?BTN_PORT_PCC?false);
????????PCC_HAL_SetClockSourceSel(PCC?BTN_PORT_PCC?CLK_SRC_FIRC);
????????PCC_HAL_SetClockMode(PCC?BTN_PORT_PCC?true);
????????/*
?????????*?ISF??Interrupt?Status?Flag
?????????*?IRQC?Interrupt?Configuration
?????????*?LK???Lock?Register
?????????*?MUX??Pin?Mux?Control
?????????*?DSE??Drive?Strength?Enable
?????????*?PFE??Passive?Filter?Enable
?????????*?PE???Pull?Enable
?????????*?PS???Pull?Select
???????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-10-25?15:44??app\
?????文件????????4873??2017-10-25?15:44??app\main.c
?????目錄???????????0??2017-10-25?11:55??li
?????文件????????6515??2016-11-02?23:15??li
?????文件????????4711??2016-11-02?23:15??li
?????目錄???????????0??2017-10-25?10:43??project\
?????目錄???????????0??2017-10-25?10:42??project\Debug\
?????目錄???????????0??2017-10-25?15:44??project\Debug\Exe\
?????文件???????35852??2017-10-25?15:44??project\Debug\Exe\test.out
?????文件????????2243??2017-10-25?15:44??project\Debug\Exe\test.sim
?????目錄???????????0??2017-10-25?15:44??project\Debug\List\
?????文件????????9677??2017-10-25?15:44??project\Debug\List\test.map
?????目錄???????????0??2017-10-25?16:02??project\Debug\Obj\
?????文件???????20469??2017-10-25?15:44??project\Debug\Obj\main.o
?????文件???????10535??2017-10-25?11:50??project\Debug\Obj\main.pbi.xcl
?????文件????????6849??2017-10-25?15:44??project\Debug\Obj\startup.o
?????文件???????10538??2017-10-25?11:47??project\Debug\Obj\startup.pbi.xcl
?????文件???????17159??2017-10-25?15:44??project\Debug\Obj\startup_S32K144.o
?????文件???????11017??2017-10-25?15:44??project\Debug\Obj\system_S32K144.o
?????文件???????10545??2017-10-25?11:47??project\Debug\Obj\system_S32K144.pbi.xcl
?????文件??????????23??2017-10-25?16:02??project\Debug\Obj\test.pbd
?????文件??????????23??2017-10-25?16:02??project\Debug\Obj\test.pbd.browse
?????文件?????????274??2017-10-25?16:02??project\Debug\Obj\test.pbd.linf
?????目錄???????????0??2017-10-25?11:00??project\settings\
?????文件?????????351??2017-10-25?11:56??project\settings\test.crun
?????文件????????5609??2017-10-25?10:56??project\settings\test.dbgdt
?????文件????????1638??2017-10-25?15:44??project\settings\test.Debug.cspy.bat
?????文件?????????462??2017-10-25?15:44??project\settings\test.Debug.driver.xcl
?????文件?????????576??2017-10-25?15:44??project\settings\test.Debug.general.xcl
?????文件????????2374??2017-10-25?15:44??project\settings\test.dni
?????文件????????3163??2017-10-25?15:44??project\settings\test.wsdt
............此處省略18個文件信息
評論
共有 條評論