There's no reason a 'const char[]' needs to contain ascii characters. For instance:
Code: Select all
const char myData[4]={0, 0xFF, 0xAA, 0x55};
int uart_write_bytes(my_uart_num, myData, 4);
will happily do what you want. Wrt writing one character, you can use the trick that a pointer to a variable is the same as a pointer to the first item in an array containing a single item. (Sorry, can't explain it any easier.). As such, this will work:
Code: Select all
char mySingleCharacter;
mySingleCharacter='A'; //note single quotes
int uart_write_bytes(my_uart_num, mySingleCharacter, 1);
mySingleCharacter=0xA5; //non-ascii will also work
int uart_write_bytes(my_uart_num, mySingleCharacter, 1);