circuitpython/ports/stm32f4/common-hal/busio/UART.h

68 lines
2.1 KiB
C
Raw Normal View History

2019-07-31 14:58:55 -04:00
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Scott Shawcroft
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_BUSIO_UART_H
#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_BUSIO_UART_H
#include "common-hal/microcontroller/Pin.h"
2019-10-04 14:37:18 -04:00
#include "stm32f4/periph.h"
2019-10-11 15:47:55 -04:00
#include "stm32f4xx_hal.h"
2019-07-31 14:58:55 -04:00
#include "py/obj.h"
2019-10-11 15:47:55 -04:00
#include "py/ringbuf.h"
2019-07-31 14:58:55 -04:00
#ifndef UART_IRQPRI
#define UART_IRQPRI 1
#endif
#ifndef UART_IRQSUB_PRI
#define UART_IRQSUB_PRI 0
#endif
2019-07-31 14:58:55 -04:00
typedef struct {
mp_obj_base_t base;
2019-10-04 14:37:18 -04:00
UART_HandleTypeDef handle;
2019-10-21 16:24:32 -04:00
IRQn_Type irq;
2019-10-04 11:42:38 -04:00
const mcu_uart_tx_obj_t *tx;
const mcu_uart_rx_obj_t *rx;
2019-10-11 15:47:55 -04:00
ringbuf_t rbuf;
uint8_t rx_char;
2019-07-31 14:58:55 -04:00
uint32_t baudrate;
uint32_t timeout_ms;
} busio_uart_obj_t;
2019-10-04 14:37:18 -04:00
void uart_reset(void);
2019-10-16 11:33:55 -04:00
void USART1_IRQHandler(void);
2019-10-11 15:47:55 -04:00
void USART2_IRQHandler(void);
2019-10-16 11:33:55 -04:00
void USART3_IRQHandler(void);
2019-10-21 16:24:32 -04:00
void UART4_IRQHandler(void);
void UART5_IRQHandler(void);
void USART6_IRQHandler(void);
// void UART_IRQHandler(void);
2019-07-31 14:58:55 -04:00
#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_BUSIO_UART_H