Last change
on this file since 0074c9ec was
0074c9ec,
checked in by Christian Mauderer <christian.mauderer@…>, on 02/03/22 at 08:38:40
|
bsp/atsam/i2c: Add error return and fix edge cases
The driver didn't return with an error on (for example) a NACK on the
bus. This adds the expected error return. Due to the new case that a
transfer can be interrupted on an error, there were some new edge cases.
This patch therefore also fixes these edge cases by removing the
transfer_state that more or less duplicated the interrupt states.
Fixes #4592
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | /* |
---|
2 | * Copyright (c) 2016 embedded brains GmbH. All rights reserved. |
---|
3 | * |
---|
4 | * embedded brains GmbH |
---|
5 | * Dornierstr. 4 |
---|
6 | * 82178 Puchheim |
---|
7 | * Germany |
---|
8 | * <info@embedded-brains.de> |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.org/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #ifndef LIBBSP_ARM_ATSAM_ATSAM_I2C_H |
---|
16 | #define LIBBSP_ARM_ATSAM_ATSAM_I2C_H |
---|
17 | |
---|
18 | #include <libchip/chip.h> |
---|
19 | #include <libchip/include/pio.h> |
---|
20 | |
---|
21 | #include <bsp.h> |
---|
22 | #include <rtems/thread.h> |
---|
23 | #include <dev/i2c/i2c.h> |
---|
24 | |
---|
25 | #ifdef __cplusplus |
---|
26 | extern "C" { |
---|
27 | #endif /* __cplusplus */ |
---|
28 | |
---|
29 | #define TWI_AMOUNT_PINS 2 |
---|
30 | |
---|
31 | typedef struct { |
---|
32 | i2c_bus base; |
---|
33 | Twihs *regs; |
---|
34 | |
---|
35 | /* First message and number of messages that have to be processed. */ |
---|
36 | i2c_msg *msgs; |
---|
37 | uint32_t msg_todo; |
---|
38 | |
---|
39 | /* Information about the current transfer. */ |
---|
40 | bool stop_request; |
---|
41 | uint32_t current_msg_todo; |
---|
42 | uint8_t *current_msg_byte; |
---|
43 | |
---|
44 | /* Error information that can be returned to the task */ |
---|
45 | uint32_t err; |
---|
46 | |
---|
47 | uint32_t output_clock; |
---|
48 | rtems_binary_semaphore sem; |
---|
49 | rtems_vector_number irq; |
---|
50 | } atsam_i2c_bus; |
---|
51 | |
---|
52 | int i2c_bus_register_atsam( |
---|
53 | const char *bus_path, |
---|
54 | Twihs *register_base, |
---|
55 | rtems_vector_number irq, |
---|
56 | const Pin pins[TWI_AMOUNT_PINS] |
---|
57 | ); |
---|
58 | |
---|
59 | #ifdef __cplusplus |
---|
60 | } |
---|
61 | #endif /* __cplusplus */ |
---|
62 | |
---|
63 | #endif /* LIBBSP_ARM_ATSAM_ATSAM_I2C_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.