|
cursada_mc2
Base de control de temperatura para EDU-CIAA-NXP
|
Driver UART por interrupciones basado en ring buffers de LPCOpen. More...
#include <chip.h>#include <stdbool.h>#include <stdint.h>
Include dependency graph for uart_driver_irq.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Macros | |
| #define | UART_IRQ_CHANNEL_0 0U |
| Identificador del canal UART0. | |
| #define | UART_IRQ_CHANNEL_2 2U |
| Identificador del canal UART2. | |
| #define | UART_IRQ_CHANNEL_3 3U |
| Identificador del canal UART3. | |
| #define | UART_IRQ_RX_BUFFER_SIZE 128U |
| Tamano del buffer circular de recepcion. | |
| #define | UART_IRQ_TX_BUFFER_SIZE 128U |
| Tamano del buffer circular de transmision. | |
Functions | |
| bool | driver_uart_irq_init (uint8_t channel, uint32_t baudrate) |
| Inicializa un canal UART para operar por interrupciones. | |
| void | driver_uart_irq_deinit (void) |
| Desinicializa la UART configurada y deshabilita sus interrupciones. | |
| int | driver_uart_irq_write (const void *data, uint16_t num_bytes) |
| Encola datos para transmision por UART. | |
| int | driver_uart_irq_read (void *data, uint16_t num_bytes) |
| Lee datos disponibles desde el buffer de recepcion. | |
| int | driver_uart_irq_available (void) |
| Informa cuantos bytes hay disponibles para leer. | |
| int | driver_uart_irq_tx_free (void) |
| Informa cuanto espacio libre queda en el buffer de transmision. | |
| void | driver_uart_irq_flush (void) |
| Vacia los buffers de recepcion y transmision. | |
| bool | driver_uart_irq_is_initialized (void) |
| Informa si el driver ya fue inicializado. | |
| void | driver_uart_irq_handler (void) |
| Handler generico del driver para ser invocado desde la IRQ activa. | |
| #define UART_IRQ_CHANNEL_0 0U |
Definition at line 14 of file uart_driver_irq.h.
| #define UART_IRQ_CHANNEL_2 2U |
Definition at line 16 of file uart_driver_irq.h.
| #define UART_IRQ_CHANNEL_3 3U |
Definition at line 18 of file uart_driver_irq.h.
| #define UART_IRQ_RX_BUFFER_SIZE 128U |
Definition at line 21 of file uart_driver_irq.h.
| #define UART_IRQ_TX_BUFFER_SIZE 128U |
Definition at line 23 of file uart_driver_irq.h.
| int driver_uart_irq_available | ( | void | ) |
Definition at line 139 of file uart_driver_irq.c.
References driver_uart_irq_state_, driver_uart_irq_state_t::initialized, and driver_uart_irq_state_t::rx_ring.
| void driver_uart_irq_deinit | ( | void | ) |
Definition at line 102 of file uart_driver_irq.c.
References driver_uart_irq_state_, driver_uart_irq_state_t::initialized, driver_uart_irq_state_t::irq, and driver_uart_irq_state_t::peripheral.
| void driver_uart_irq_flush | ( | void | ) |
Definition at line 157 of file uart_driver_irq.c.
References driver_uart_irq_state_, driver_uart_irq_state_t::initialized, driver_uart_irq_state_t::rx_ring, and driver_uart_irq_state_t::tx_ring.
| void driver_uart_irq_handler | ( | void | ) |
Normalmente no se llama desde la aplicacion. Se expone para permitir redireccionar handlers si fuera necesario.
LPCOpen mueve bytes entre la UART y los ring buffers.
Segun la fuente de interrupcion, la libreria deposita bytes recibidos en rx_ring o drena tx_ring hacia la FIFO de transmision.
Definition at line 172 of file uart_driver_irq.c.
References driver_uart_irq_state_, driver_uart_irq_state_t::initialized, driver_uart_irq_state_t::peripheral, driver_uart_irq_state_t::rx_ring, and driver_uart_irq_state_t::tx_ring.
Referenced by UART0_IRQHandler(), UART2_IRQHandler(), and UART3_IRQHandler().
| bool driver_uart_irq_init | ( | uint8_t | channel, |
| uint32_t | baudrate | ||
| ) |
Configura el pinmux, la UART seleccionada, los buffers circulares y la IRQ correspondiente al canal.
| channel | Canal UART a utilizar. |
| baudrate | Velocidad de comunicacion en baudios. |
| true | Si la inicializacion fue correcta. |
| false | Si el canal solicitado no es valido. |
RX y TX quedan desacopladas mediante buffers circulares.
La aplicacion trabaja contra estos buffers mientras la rutina de interrupcion atiende la FIFO fisica del periferico.
Definition at line 64 of file uart_driver_irq.c.
References driver_uart_irq_select_channel(), driver_uart_irq_state_, driver_uart_irq_state_t::initialized, driver_uart_irq_state_t::irq, driver_uart_irq_state_t::peripheral, driver_uart_irq_state_t::rx_data, driver_uart_irq_state_t::rx_ring, driver_uart_irq_state_t::tx_data, driver_uart_irq_state_t::tx_ring, UART_IRQ_RX_BUFFER_SIZE, and UART_IRQ_TX_BUFFER_SIZE.
| bool driver_uart_irq_is_initialized | ( | void | ) |
| true | Si el driver se encuentra operativo. |
| false | Si el driver aun no fue inicializado. |
Definition at line 167 of file uart_driver_irq.c.
References driver_uart_irq_state_, and driver_uart_irq_state_t::initialized.
| int driver_uart_irq_read | ( | void * | data, |
| uint16_t | num_bytes | ||
| ) |
| data | Puntero al buffer destino. |
| num_bytes | Cantidad maxima de bytes a leer. |
Definition at line 127 of file uart_driver_irq.c.
References driver_uart_irq_state_, driver_uart_irq_state_t::initialized, driver_uart_irq_state_t::peripheral, and driver_uart_irq_state_t::rx_ring.
| int driver_uart_irq_tx_free | ( | void | ) |
Definition at line 148 of file uart_driver_irq.c.
References driver_uart_irq_state_, driver_uart_irq_state_t::initialized, and driver_uart_irq_state_t::tx_ring.
| int driver_uart_irq_write | ( | const void * | data, |
| uint16_t | num_bytes | ||
| ) |
| data | Puntero al buffer de datos a transmitir. |
| num_bytes | Cantidad de bytes a transmitir. |
Definition at line 115 of file uart_driver_irq.c.
References driver_uart_irq_state_, driver_uart_irq_state_t::initialized, driver_uart_irq_state_t::peripheral, and driver_uart_irq_state_t::tx_ring.