init
This commit is contained in:
commit
a1cbf4a3c3
11 files changed
+460
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* LED Blink - MSPM0G3507
|
||||
* LED on PB9, active low (低电平点亮)
|
||||
*/
|
||||
|
||||
#include "ti_msp_dl_config.h"
|
||||
|
||||
/**
|
||||
* @brief 毫秒级延时函数 (基于 CPU 忙等)
|
||||
* @param ms 要延时的毫秒数
|
||||
*
|
||||
* 假设 CPUCLK_FREQ = 32 MHz, 1 ms ≈ 32000 cycles
|
||||
*/
|
||||
void delay(uint32_t ms)
|
||||
{
|
||||
uint32_t cycles_per_ms = CPUCLK_FREQ / 1000;
|
||||
while (ms--) {
|
||||
delay_cycles(cycles_per_ms);
|
||||
}
|
||||
}
|
||||
|
||||
int cycle = 0;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* Initialize GPIO and clocks via SysConfig-generated code */
|
||||
SYSCFG_DL_init();
|
||||
|
||||
|
||||
while (1) {
|
||||
/* LED ON: PB9 = LOW (active low) */
|
||||
DL_GPIO_clearPins(GPIO_LED_PORT, GPIO_LED_LED_PIN);
|
||||
delay(100);
|
||||
|
||||
/* LED OFF: PB9 = HIGH */
|
||||
DL_GPIO_setPins(GPIO_LED_PORT, GPIO_LED_LED_PIN);
|
||||
delay(100);
|
||||
cycle++;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user