在下面的函数声明中,对于mcu上的uart write,我可以传递十六进制命令吗?
uart_write(const uart_t uart, const uint8_t data);
uart_write(uart_1, 0x56);
答案 0 :(得分:1)
pass a hex command
,而是说pass the value using hex representation
更为正确。
反正
uart_write(uart_1, 0x56);
与
相同uart_write(uart_1, 86); // 86 == 5 * 16 + 6
可以以多种格式/表示形式给出整数 - 编译器只是将值转换为适合编译器的表示形式。也许这对你来说很有意思:http://www.cplusplus.com/doc/hex/
答案 1 :(得分:1)
如果您的意思是十六进制数字,那么您可以。要写入十六进制数字,请务必在其前面加0x
。您还可以在前面加上0
0x56
Hexadecimal 56 011
Octal 11