我在尝试使用来自 Atmel 的新 SAMC21 Xplained Pro 时遇到问题。我目前正在尝试了解 Cortex M0+ 的基础知识,但我卡住了。我在 Atmel Studio 中使用 ASF。我从基础开始,学习如何用开关切换 LED。这是 Atmel 的代码,完美无瑕:
void configure_port_pins(void)
{
struct port_config config_port_pin;
port_get_config_defaults(&config_port_pin);
config_port_pin.direction = PORT_PIN_DIR_INPUT;
config_port_pin.input_pull = PORT_PIN_PULL_UP;
port_pin_set_config(BUTTON_0_PIN, &config_port_pin);
config_port_pin.direction = PORT_PIN_DIR_OUTPUT;
port_pin_set_config(LED_0_PIN, &config_port_pin);
}
int main (void)
{
system_init();
configure_port_pins();
while (true) {
bool pin_state = port_pin_get_input_level(BUTTON_0_PIN);
port_pin_set_output_level(LED_0_PIN, !pin_state);
}
然后我想尝试一些更简单的东西,比如:
int main (void)
{
system_init();
configure_port_pins();
port_pin_set_output_level(LED_0_PIN,0);
while (1)
{
port_pin_set_output_level(LED_0_PIN,0);
delay_ms(500);
port_pin_set_output_level(LED_0_PIN,1);
}
}
但它不起作用。就像它不识别 bool 数据类型一样。也许我错过了一些东西。感谢您的回答。