• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

blues / note-arduino / 15443225790

04 Jun 2025 01:11PM UTC coverage: 88.119% (-1.3%) from 89.431%
15443225790

Pull #143

github

web-flow
Merge 7d0a26526 into 40acff306
Pull Request #143: chore: Wait for serial to be ready

111 of 165 branches covered (67.27%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

334 of 340 relevant lines covered (98.24%)

14.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/NoteI2c.hpp
1
#ifndef NOTE_I2C_HPP
2
#define NOTE_I2C_HPP
3

4
#include <stddef.h>
5
#include <stdint.h>
6

7
class NoteI2c
8
{
9
public:
10

11
    virtual ~NoteI2c(void) {}
38✔
12

13
    /**************************************************************************/
14
    /*!
15
        @brief  Receives an amount of data from the Notecard in blocking mode.
16
        @param[in]  device_address
17
                The I2C address.
18
        @param[out] buffer
19
                A buffer to hold the data read from the I2C controller.
20
        @param[in]  requested_byte_count
21
                The number of bytes requested.
22
        @param[out] available
23
                The number of bytes available for subsequent calls to receive().
24
        @returns A string with an error, or `nullptr` if the receive was
25
        successful.
26
    */
27
    /**************************************************************************/
28
    virtual const char * receive(uint16_t device_address, uint8_t * buffer, uint16_t size, uint32_t * available) = 0;
29

30
    /**************************************************************************/
31
    /*!
32
        @brief  Resets the I2C port. Required by note-c.
33
        @return `true`.
34
    */
35
    /**************************************************************************/
36
    virtual bool reset(uint16_t device_address) = 0;
37

38
    /**************************************************************************/
39
    /*!
40
        @brief  Transmits an amount of data from the host in blocking mode.
41
        @param[in] device_address
42
                The I2C address.
43
        @param[in] buffer
44
                The data to transmit over I2C. The caller should have shifted
45
                it right so that the low bit is NOT the read/write bit.
46
        @param[in] size
47
                The number of bytes to transmit.
48
        @returns A string with an error, or `nullptr` if the transmission was
49
                successful.
50
    */
51
    /**************************************************************************/
52
    virtual const char * transmit(uint16_t device_address, uint8_t * buffer, uint16_t size) = 0;
53

54
    /**************************************************************************/
55
    /*!
56
        @brief  Size of the header for Serial-Over-I2C requests.
57

58
        @details The request made to the low-level I2C controller should be
59
                 for REQUEST_HEADER_SIZE + the `size` parameter supplied to the
60
                 `receive` method.
61

62
        @see NoteI2c::receive
63
    */
64
    /**************************************************************************/
65
    static const size_t REQUEST_HEADER_SIZE = 2;
66

67
    /**************************************************************************/
68
    /*!
69
        @brief  Maximum size of a Serial-Over-I2C request.
70

71
        @details The requests made to and responses received from the low-level
72
                 I2C controller can be no larger than (REQUEST_MAX_SIZE
73
                 - REQUEST_HEADER_SIZE).
74

75
        @see NoteI2c::receive
76
    */
77
    /**************************************************************************/
78
    static const size_t REQUEST_MAX_SIZE = 255;
79
};
80

81
/******************************************************************************/
82
/*!
83
    @brief  Helper function to abstract, create and maintain a single instance
84
    of the NoteI2c interface implementation, as required by the underlying
85
    `note-c` library.
86
    @param[in] i2c_parameters
87
               Pointer to the parameters required to instantiate
88
               the platform specific I2C implementation.
89
*/
90
/******************************************************************************/
91
template <typename T> NoteI2c * make_note_i2c (T & i2c_parameters);
92
NoteI2c * make_note_i2c (nullptr_t);
93

94
#endif // NOTE_I2C_HPP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc