RTEMS: bsps/arm/stm32f4/include/bsp/i2c.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
i2c.h
Go to the documentation of this file.
1
7/*
8 * Copyright (c) 2013 Christian Mauderer. All rights reserved.
9 *
10 * embedded brains GmbH
11 * Obere Lagerstr. 30
12 * 82178 Puchheim
13 * Germany
14 * <rtems@embedded-brains.de>
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 */
20
21/* The I2C-module can not run with libi2c. The reason for this is, that libi2c
22 * needs a possibility to generate a stop condition separately. This controller
23 * wants to generate the condition automatically when sending or receiving data.
24 */
25
26#ifndef LIBBSP_ARM_STM32F4_I2C_H
27#define LIBBSP_ARM_STM32F4_I2C_H
28
29#include <rtems.h>
30
31#include <bsp/io.h>
32#include <bsp/stm32f4.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif /* __cplusplus */
37
45 typedef struct {
50 uint16_t addr;
52 bool read;
54 size_t len;
56 uint8_t *buf;
57} stm32f4_i2c_message;
58
59 typedef struct {
60 volatile stm32f4_i2c *regs;
61 size_t index;
62 rtems_vector_number vector;
63 rtems_id mutex;
64 rtems_id task_id;
65 uint8_t *data;
66 uint8_t *last;
67 size_t len;
68 bool read;
69 uint8_t addr_with_rw;
70} stm32f4_i2c_bus_entry;
71
73 rtems_status_code stm32f4_i2c_init(stm32f4_i2c_bus_entry *e);
74
76 rtems_status_code stm32f4_i2c_process_message(
77 stm32f4_i2c_bus_entry *e,
78 stm32f4_i2c_message *msg
79);
80
82 rtems_status_code stm32f4_i2c_set_bitrate(
83 stm32f4_i2c_bus_entry *e,
84 uint32_t br
85);
86
87extern stm32f4_i2c_bus_entry *const stm32f4_i2c1;
88extern stm32f4_i2c_bus_entry *const stm32f4_i2c2;
89
92#ifdef __cplusplus
93}
94#endif /* __cplusplus */
95
96#endif /* LIBBSP_ARM_STM32F4_I2C_H */
rtems_vector_number
ISR_Vector_number rtems_vector_number
Control block type used to manage the vectors.
Definition: intr.h:47
rtems_status_code
rtems_status_code
Classic API Status.
Definition: status.h:43
rtems_id
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:83
stm32f4_i2c_process_message
rtems_status_code stm32f4_i2c_process_message(stm32f4_i2c_bus_entry *e, stm32f4_i2c_message *msg)
Process a i2c message.
Definition: i2c.c:269
stm32f4_i2c_init
rtems_status_code stm32f4_i2c_init(stm32f4_i2c_bus_entry *e)
Initialise the i2c module.
Definition: i2c.c:216
stm32f4_i2c_set_bitrate
rtems_status_code stm32f4_i2c_set_bitrate(stm32f4_i2c_bus_entry *e, uint32_t br)
Set another baud rate than the default one.
Definition: i2c.c:50
read
ssize_t read(int fd, void *buffer, size_t count)
Definition: read.c:27
rtems.h
stm32f4.h
Register definitions.
msg
Definition: b1553brm.c:75
mutex
Definition: mutex.h:4
stm32f4_i2c_bus_entry
Definition: i2c.h:59
stm32f4_i2c_message
Definition: i2c.h:45
stm32f4_i2c_message::addr
uint16_t addr
The address of the slave without the read write bit. A 7-Bit address should be placed in the bits [6....
Definition: i2c.h:50
stm32f4_i2c_message::buf
uint8_t * buf
Buffer for data.
Definition: i2c.h:56
stm32f4_i2c_message::len
size_t len
Size of data to read or write.
Definition: i2c.h:54
stm32f4_i2c_message::read
bool read
Read (true) or write (false) data.
Definition: i2c.h:52
stm32f4_i2c
Definition: stm32_i2c.h:33
e
unsigned e
Definition: tlb.h:13