#include "uart_commands.h" static uint8_t data[1024]; char OK[5] = "OK\r\n"; char ERR[6] = "ERR\r\n"; void digit_to_str(char* str, uint32_t number, int base){ itoa(number,str,16); } /* void digit_to_str(char* str, uint32_t number, int base){ char tmp_char[32]; uint32_t tmp = number; int tmp_counter = 0; for(int i = 0; i<32; i++); switch (tmp & 15) { case 0: tmp_char[tmp_counter] = '0'; tmp_counter++; tmp=tmp/base; break; case 1: tmp_char[tmp_counter] = '1'; tmp_counter++; tmp=tmp/base; break; case 2: tmp_char[tmp_counter] = '2'; tmp_counter++; tmp=tmp/base; break; case 3: tmp_char[tmp_counter] = '3'; tmp_counter++; tmp=tmp/base; break; case 4: tmp_char[tmp_counter] = '4'; tmp_counter++; tmp=tmp/base; break; case 5: tmp_char[tmp_counter] = '5'; tmp_counter++; tmp=tmp/base; break; case 6: tmp_char[tmp_counter] = '6'; tmp_counter++; tmp=tmp/base; break; case 7: tmp_char[tmp_counter] = '7'; tmp_counter++; tmp=tmp/base; break; case 8: tmp_char[tmp_counter] = '8'; tmp_counter++; tmp=tmp/base; break; case 9: tmp_char[tmp_counter] = '9'; tmp_counter++; tmp=tmp/base; break; case 10: tmp_char[tmp_counter] = 'a'; tmp_counter++; tmp=tmp/base; break; case 11: tmp_char[tmp_counter] = 'b'; tmp_counter++; tmp=tmp/base; break; case 12: tmp_char[tmp_counter] = 'c'; tmp_counter++; tmp=tmp/base; break; case 13: tmp_char[tmp_counter] = 'd'; tmp_counter++; tmp=tmp/base; break; case 14: tmp_char[tmp_counter] = 'e'; tmp_counter++; tmp=tmp/base; break; case 15: tmp_char[tmp_counter] = 'f'; tmp_counter++; tmp=tmp/base; break; } for(int i = 0; iargv[0] = NULL; cmd->argv[1] = NULL; cmd->argv[2] = NULL; cmd->argc = -1; //Separate string in different token (i.e. command name + params + &) do { //A new element will be added cmd->argc += 1; //Get the adress of the next token (could be NULL to indicate end of argv) cmd->argv[cmd->argc] = strtok(user_input, DELIMIERS); user_input = NULL; //Useless to execute it each time but easier than having two different strtok calls } while (cmd->argv[cmd->argc] != NULL); // while there are still tokens return 0; } uint32_t uart_string_to_int(const char *str) { //char* tmp; //unsigned long long int hex = strtoull(str, &tmp, 16); unsigned long int hex = strtoul(str, NULL, 16); return hex; } void uart_send_ok(){ uart_send(OK, 4); } void uart_send_err(){ uart_send(ERR, 6); }