裸机开发,点亮LED灯
#include "iocc2530.h" void led_init(void) { P1DIR |= 0x1 << 0; P1DIR |= 0x1 << 1; P1DIR |= 0x1 << 4; } void led_on(void) { P1_0 = 1; P1_1 = 1; P1_4 = 1; } void led_off(void) { P1_0 = 0; P1_1 = 0; P1_4 = 0; } void delay(unsigned int n) { int i; for(;n>0;n--) for(i=1000;i>0;i--){} } void led_turn(void) { P1_1 ^= 1; } int main(void) { led_init(); while(1) { led_on(); delay(1000); led_off(); delay(1000); } return 0; }