Welcome to mirror list, hosted at ThFree Co, Russian Federation.

furi-hal-uart.h « furi-hal « f6 « targets « firmware - github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 53a45f1ec729a3101984da9453262db363afcdcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
 * @file furi-hal-uart.h
 * @version 1.0
 * @date 2021-11-19
 * 
 * UART HAL api interface
 */
#pragma once

#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * UART channels
 */
typedef enum {
    FuriHalUartIdUSART1,
    FuriHalUartIdLPUART1,
} FuriHalUartId;

/**
 * UART events
 */
typedef enum {
    UartIrqEventRXNE,
    UartIrqEventIDLE,
    //TODO: more events
} UartIrqEvent;

/**
 * Init UART
 * Configures GPIO to UART function, сonfigures UART hardware, enables UART hardware
 * @param channel UART channel
 * @param baud baudrate
 */
void furi_hal_uart_init(FuriHalUartId channel, uint32_t baud);

/**
 * Deinit UART
 * Configures GPIO to analog, clears callback and callback context, disables UART hardware
 * @param channel UART channel
 */
void furi_hal_uart_deinit(FuriHalUartId channel);

/**
 * Changes UART baudrate
 * @param channel UART channel
 * @param baud baudrate
 */
void furi_hal_uart_set_br(FuriHalUartId channel, uint32_t baud);

/**
 * Transmits data
 * @param channel UART channel
 * @param buffer data
 * @param buffer_size data size (in bytes)
 */
void furi_hal_uart_tx(FuriHalUartId channel, uint8_t* buffer, size_t buffer_size);

/**
 * Sets UART event callback
 * @param channel UART channel
 * @param callback callback pointer
 * @param context callback context
 */
void furi_hal_uart_set_irq_cb(
    FuriHalUartId channel,
    void (*callback)(UartIrqEvent event, uint8_t data, void* context),
    void* context);

#ifdef __cplusplus
}
#endif