Boen_Shi 8be2866433 feat(base): 初始化 MSPM0 开发环境
- 添加头文件和配置文件支持
- 更新.gitignore忽略编译和IDE相关文件
- 添加基础的bsp代码
2026-07-16 14:45:26 +08:00

46 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "Key.h"
#include <../2025_include_user/Host.h>
Key::KeyData Key::keys[] = {
{KEY1, Key_Key1_PORT, Key_Key1_PIN, 0},
{KEY2, Key_Key2_PORT, Key_Key2_PIN, 0},
{KEY3, Key_Key3_PORT, Key_Key3_PIN, 0},
{KEY4, Key_Key4_PORT, Key_Key4_PIN, 0},
};
// extern "C" {
// void vKeyTask(void *pvParameters) {
// while (true) {
// for (uint8_t i = 0; i < (sizeof(Key::keys) / sizeof(Key::keys[0])); i++) {
// if (DL_GPIO_readPins(Key::keys[i].port, Key::keys[i].pin) == 0) {
// // print("Key%d: %d\r\n", i, 1);
// Key::keys[i].state = 1;
// } else {
// // print("Key%d: %d\r\n", i, 0);
// Key::keys[i].state = 0;
// }
// }
//
// vTaskDelay(pdMS_TO_TICKS(1)); // 每10ms检测一次按键释放CPU
// }
// }
// }
void Key::init() {
// xTaskCreate(vKeyTask, "vKeyTask", 32, nullptr, 1, nullptr);
NVIC_EnableIRQ(Key_GPIOA_INT_IRQN);
NVIC_EnableIRQ(GPIO_MULTIPLE_GPIOB_INT_IRQN);
}
uint8_t Key::getState(const uint8_t id) {
const uint8_t state = keys[id].state;
keys[id].state = 0;
return state;
}
void Key::setState(const uint8_t id, const uint8_t state) {
keys[id].state = state;
}