论坛元老
 
- 积分
- 3515
- 金钱
- 3515
- 注册时间
- 2016-3-19
- 在线时间
- 847 小时
|
发表于 2022-4-2 11:10:03
|
显示全部楼层
以STM32F103xxx为例
临时编写一个程序 没有硬件 所以没有进行实物验证
/*
说明:
0x40010810, 0x0012000C
寄存器地址, 管脚电平
管脚电平分为高十六位和低十六位
高十六位对应位为 1 代表输出高电平
低十六位对应位为 1 代表输出低电平
*/
uint32_t CommandList[96][2] = {
0x40010810, 0x0012000C, // 接收指令“1”,执行动作PA1,2,3,4设置为HLLH
0x40010810, 0x000C0012, // 接收指令“2”,执行动作PA1,2,3,4设置为LHHL
// ...... // 根据项目需求,编写命令列表
};
/*
说明:
CommandIndex 0 -- 95
返回 0 命令执行成功
返回 1 命令执行失败
*/
uint8_t ExecuteCommand(uint8_t CommandIndex)
{
if (CommandIndex >= 96)
{
return (1);
}
* (volatile uint32_t *)(CommandList[CommandIndex][0] + 0) = (uint16_t)(CommandList[CommandIndex][1] >> 0x0010);
* (volatile uint32_t *)(CommandList[CommandIndex][0] + 4) = (uint16_t)(CommandList[CommandIndex][1] & 0xffff);
return (0);
} |
|