IP400/code/IP400/Inc/usart.h

63 lines
1.9 KiB
C
Raw Normal View History

2025-02-06 02:44:31 +02:00
/*---------------------------------------------------------------------------
Project: WL33_NUCLEO_UART
File Name: usart.h
Author: MartinA
Creation Date: Jan 12, 2025
Description: <decription here?
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version, provided this copyright notice
is included.
Copyright (c) 2024-25 Alberta Digital Radio Communications Society
Revision History:
---------------------------------------------------------------------------*/
#ifndef INC_USART_H_
#define INC_USART_H_
#include "types.h"
#include "main.h"
// definitions
typedef uint32_t UART_TIMEOUT_T; // uart timer type
typedef uint16_t BUFFER_SIZE_T; // buffer size type
typedef uint8_t DATA_ELEMENT; // buffer data element
// uart HAL handle
2025-02-07 22:49:26 +02:00
extern UART_HandleTypeDef huart1; // console UART
extern UART_HandleTypeDef hlpuart1 ; // GPS UART
2025-02-06 02:44:31 +02:00
// logger defines
#define LOG_NOTICE 0 // notice
#define LOG_ERROR 1 // error
#define LOG_SEVERE 2 // severe error
2025-02-07 22:49:26 +02:00
// logger
2025-02-06 02:44:31 +02:00
void logger(int severity, char *format, ...);
// API calls
void USART_RxBuffer_reset(void);
size_t databuffer_bytesInBuffer(void);
DATA_ELEMENT databuffer_get(UART_TIMEOUT_T timeout);
BOOL databuffer_contains(const char *tag, UART_TIMEOUT_T rx_timeout, BOOL saveData, char *SaveBuffer);
BOOL USART_Send_String(const char *string, size_t len);
BOOL USART_Send_Char(const char c);
void USART_Print_string(char *format, ...);
2025-02-07 22:49:26 +02:00
// same as USART but for LPUART: no Tx functions
void LPUART_RxBuffer_reset(void);
size_t gpsbuffer_bytesInBuffer(void);
DATA_ELEMENT gpsbuffer_get(UART_TIMEOUT_T timeout);
2025-02-10 22:04:21 +02:00
void LPUART_Send_String(char *str, uint16_t len);
2025-02-07 22:49:26 +02:00
2025-02-06 02:44:31 +02:00
#endif /* INC_USART_H_ */