Browse Source

added uart transmit timestamp (not working properly)

alice
Gregor Wüst 3 years ago
parent
commit
9e4072b3cb
1 changed files with 22 additions and 9 deletions
  1. 22
    9
      RTC/Core/Src/main.c

+ 22
- 9
RTC/Core/Src/main.c View File

@@ -84,12 +84,13 @@ typedef struct {
} timeAndDate;

typedef struct {
char *hours;
char *minutes;
char *seconds;
} timeAndDateChar;
char hours[10];
char minutes[10];
char seconds[10];
char *fullTimeStamp;
} timeStamp;

timeAndDateChar time;
timeStamp time;

/* USER CODE END PV */

@@ -393,7 +394,9 @@ void set_alarm(int h, int min, int weekDay, char* alarm, RTC_AlarmTypeDef* alarm

}

/*timeAndDateChar get_time(timeAndDateChar *time){
void get_time(timeStamp *time){

char str[200];

if (HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BIN) == HAL_OK)
{
@@ -402,12 +405,22 @@ void set_alarm(int h, int min, int weekDay, char* alarm, RTC_AlarmTypeDef* alarm
sprintf(time->seconds, "%d", sTime.Seconds);
}

strcpy(str, time->hours);
strcat(str, ":");
strcat(str, time->minutes);
strcat(str, ":");
strcat(str, time->seconds);
strcat(str, " | ");

time->fullTimeStamp = str;
}
*/
// sending to UART
void transmit_uart(char *string){
//char divider[] = ":";
//get_time(time);
//char str[200];
//get_time(&time);
//strcat(time.fullTimeStamp, string);
//strcpy(str, time.fullTimeStamp);
uint8_t len = strlen(string);
HAL_UART_Transmit(&huart2, (uint8_t*) string, len, 200);
}

Loading…
Cancel
Save