Skip to content

Commit f380e2b

Browse files
committed
Merge branch 'release/v1.1.0'
2 parents 2dc5c99 + 8518630 commit f380e2b

57 files changed

Lines changed: 10165 additions & 950 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ctest.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ jobs:
2222
matrix:
2323
os: [ubuntu-latest, windows-latest]
2424
build: [Release, Debug]
25+
target: [x64, win32]
2526
compiler: [gcc, clang, msvc]
2627
exclude:
2728
- {os: ubuntu-latest, compiler: msvc}
29+
- {os: ubuntu-latest, target: win32}
2830
- {os: windows-latest, compiler: gcc}
2931
- {os: windows-latest, compiler: clang}
3032

@@ -58,19 +60,25 @@ jobs:
5860

5961
# Configuration for MSVC
6062
- name: Configuration for and build msvc
61-
if: matrix.compiler == 'msvc'
63+
if: matrix.compiler == 'msvc'
6264
uses: threeal/cmake-action@v2.0.0
6365
with:
6466
c-compiler: cl
6567
cxx-compiler: cl
68+
args : -A ${{ matrix.target }}
6669
build-args: --config ${{ matrix.build }}
6770

6871
- name: Test
6972
uses: threeal/ctest-action@v1.1.0
7073

7174
- name: Check Test Coverage
72-
if: ${{matrix.compiler == 'gcc' && matrix.build == 'Debug'}}
75+
if: matrix.compiler == 'gcc' && matrix.build == 'Debug'
7376
uses: threeal/gcovr-action@v1.1.0
7477
with:
7578
coveralls-send: true
76-
excludes: build/* test/*
79+
excludes: |
80+
build/*
81+
test/*
82+
src/sdk/mocksdkwrapper.hpp
83+
src/sdk/pico_sdk_apistub.cpp
84+

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,34 @@ History of the project development
1010
### Security
1111
### Known Issue
1212

13+
## [v1.1.0] 2024-10-21
14+
Update to the v1.0.0. The major change is the SdkWrapper class. This class is now generated by script instead of manual programming.
15+
16+
- The issue #16 changes its public member function. But it is referred internally from ::rpp_driver::Adau1361 class. Not called by user program. Then, the major version number is not needed to change.
17+
- The issue #12 removed public class I2cMasterInterface. But it is referred internal only for Unit test. So, the major version number is not needed to change.
18+
19+
### Added
20+
- [Issue #13](https://github.com/suikan4github/rpp_driver/issues/13) Exclude Mock definition from the GCov coverage.
21+
### Changed
22+
- [Issue #10](https://github.com/suikan4github/rpp_driver/issues/10) Cover APIs of the Raspberry Pi Pico SDK.
23+
- [Issue #15](https://github.com/suikan4github/rpp_driver/issues/15) Remove the redundant parameter check code from ConfigureSRC()
24+
- [Issue #16](https://github.com/suikan4github/rpp_driver/issues/16) Change the member function name from ConfigureSRC() to ConfigureSrc().
25+
- [Issue #21](https://github.com/suikan4github/rpp_driver/issues/21) Add usege of the mock for each class description.
26+
- [Issue #22](https://github.com/suikan4github/rpp_driver/issues/22) Refactor the test_i2cmaster.cpp to use the fixture.
27+
### Deprecated
28+
- [Issue #12](https://github.com/suikan4github/rpp_driver/issues/12) Is I2cMasterInterface needed?
29+
### Removed
30+
### Fixed
31+
- [Issue #11](https://github.com/suikan4github/rpp_driver/issues/11) Fails to compile in MSVC.
32+
- [Issue #14](https://github.com/suikan4github/rpp_driver/issues/14) Clean up Internal include directive.
33+
- [Issue #17](https://github.com/suikan4github/rpp_driver/issues/17) The mock of the GpioBasic has the wrong definition.
34+
- [Issue #18](https://github.com/suikan4github/rpp_driver/issues/18) The constructor of the MockI2sSlaveDuplex.hpp is missing.
35+
- [Issue #19](https://github.com/suikan4github/rpp_driver/issues/19) The Mock of the rpp_driver::Adau1361 is missing.
36+
- [Issue #20](https://github.com/suikan4github/rpp_driver/issues/20) Redundant section in README.md
37+
- [Issue #23](https://github.com/suikan4github/rpp_driver/issues/23) Make SdkWrapper member functions and SDK API Stub conditional.
38+
### Security
39+
### Known Issue
40+
1341
## [v1.0.0] 2024-10-03
1442
### Release note.
1543
First official release of the rpp_driver ( Raspberry Pi Pico Driver) class library. This release contains :

Doxyfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,10 @@ RECURSIVE = YES
10371037
# Note that relative paths are relative to the directory from which doxygen is
10381038
# run.
10391039

1040-
EXCLUDE =
1040+
EXCLUDE = src/sdk/scripts \
1041+
src/sdk/mocksdkwrapper.hpp \
1042+
src/sdk/pico_sdk_headers.h \
1043+
src/sdk/pico_api_alternate_defs.hpp
10411044

10421045
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
10431046
# directories that are symbolic links (a Unix file system feature) are excluded

README.md

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# Raspberry Pi Pico Driver class collection
1+
# Raspberry Pi Pico driver class collection
22
A Collection of the Raspberry Pi [Pico](https://www.raspberrypi.com/products/raspberry-pi-pico/)/[Pico2](https://www.raspberrypi.com/products/raspberry-pi-pico-2/) classes. Also, a [SDK API](https://www.raspberrypi.com/documentation/pico-sdk/hardware.html#group_sm_config_1gaed7a6e7dc4f1979c7c62e4773df8c79b) wrapper class is provided.
33

4-
An online [HTML documentation](https://suikan4github.github.io/rpp_driver/) is available for the details.
4+
An online [HTML documentation](https://suikan4github.github.io/rpp_driver/) is available for the details of the APIs.
55

66
# Details
7-
This class collection ( or class library ) encapsule the certain data inside class. And it also allows you to use the dependency-injection inside your project. So, you can test your code with [Google Test](https://github.com/google/googletest) before testing on the target hardware.
7+
This class collection ( or class library ) encapsules the certain data structure of Pico SDK behind the classes. And it also allows programmers to use the dependency-injection in their projects. So, programmers can test their code with [Google Test](https://github.com/google/googletest) before testing on the target hardware.
88

9-
These classes are provided in this version.
9+
The following classes are provided in this version.
1010

11-
| Class | Header file | Description |
12-
|---------------------------------|---- |----------------------------- |
13-
| ::rpp_driver::SdkWrapper | sdkwrapper.hpp | Wrapper class of Pico SDK |
14-
| ::rpp_driver::GpioBasic | gpiobasic.hpp | Basic GPIO controller |
15-
| ::rpp_driver::I2cMaster | i2cmaster.hpp | I2C Master controller |
16-
| ::rpp_driver::I2sSlaveDuplex | i2sslaveduplex.hpp | Polling based PIO I2S driver |
17-
| ::rpp_driver::Adau1361 | adau1361.hpp | Audio CODEC driver |
18-
| ::rpp_driver::UmbAdau1361Lower | umbadau1361lower.hpp | CODEC lower driver dedicated to UMB-ADAU1361-A board |
11+
| Class | Header file | Description |
12+
|---------------------------------|---- |----------------------------- |
13+
| ::rpp_driver::SdkWrapper | sdk/sdkwrapper.hpp | Wrapper class of Pico SDK |
14+
| ::rpp_driver::GpioBasic | gpio/gpiobasic.hpp | Basic GPIO controller |
15+
| ::rpp_driver::I2cMaster | i2c/i2cmaster.hpp | I2C Master controller |
16+
| ::rpp_driver::I2sSlaveDuplex | i2s/i2sslaveduplex.hpp | Polling based PIO I2S driver |
17+
| ::rpp_driver::Adau1361 | codec/adau1361.hpp | Audio CODEC driver |
18+
| ::rpp_driver::UmbAdau1361Lower | codec/umbadau1361lower.hpp | CODEC lower driver dedicated to UMB-ADAU1361-A board |
1919

2020

2121
## How to obtain this project
@@ -29,30 +29,27 @@ git clone --recursive https://github.com/suikan4github/rpp_driver.git
2929

3030
## How to obtain the sample programs
3131

32-
The newest copy of the sample program project is found in the [GitHub repository](https://github.com/suikan4github/rpp_driver-sample).
32+
The newest copy of the sample programs are found in the [GitHub repository](https://github.com/suikan4github/rpp_driver-sample).
3333

3434
Run the following command to obtain the sample from CLI:
3535
```sh
3636
git clone --recursive https://github.com/suikan4github/rpp_driver-sample.git
3737
```
3838

39-
## Sample codes
40-
You can obtain sample applications from [rpp-driver_sample](https://github.com/suikan4github/rpp_driver-sample) repository.
41-
4239

4340
# Tools and building
44-
## Installing tool
45-
To build the samples or test, you need to install the build tools.
46-
The installation of Ubuntu is :
41+
## How to install the tools
42+
To build the sample program and/or test program, you need to install the build tools.
43+
The followings are the command to install these tools on Ubuntu.
4744

4845
```sh
4946
apt-get -y update
50-
apt-get -y install build-essential cmake ninja-build git doxygen
47+
apt-get -y install build-essential cmake ninja-build git
5148
apt-get -y install gcc-arm-none-eabi libnewlib-arm-none-eabi
5249
apt-get -y install doxygen graphviz
5350
```
5451

55-
## Building the tests
52+
## How to build the tests
5653
The driver classes are tested by GoogleTest and fff. Follow the procedure to build the tests.
5754

5855
From the repository root ( where this README.md stays), run the following commands.
@@ -62,7 +59,7 @@ cmake -B build -S . -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
6259
cmake --build build --config Debug --target all
6360
```
6461

65-
## Building document
62+
## How to build the document
6663
An API document is provided as HTML files.
6764
To obtain it, run doxygen at the project root ( where the README.md exists).
6865

@@ -81,14 +78,12 @@ add_subdirectory(rpp_driver)
8178

8279
```
8380
target_link_libraries(${PROJECT_NAME} pico_stdlib
84-
hardware_i2c
85-
hardware_pio
8681
rpp_driver)
8782
```
8883

89-
Note : Whichever you use PIO/I2C or not, you need to link these libraries.
84+
Note : Beside of rpp_driver, link the Raspberry Pi Pico SDK libraries as needed.
9085

91-
By linking library, the include path for the include files are set automatically.
86+
By linking rpp_driver library, the include path for the source code are set automatically.
9287

9388
# License
9489
This project is provided under [MIT License](LICENSE).

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ cmake_minimum_required(VERSION 3.13)
44
# These declaration works for both UNIX/Win and bare metal.
55

66
add_library(rpp_driver INTERFACE)
7+
target_include_directories(rpp_driver INTERFACE .)
8+
79

810
# Win/Unix specific option.
911
if((${WIN32}) OR (${UNIX}))

src/codec/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ target_sources(rpp_driver INTERFACE
55
adau1361.cpp
66
adau1361lower.cpp
77
umbadau1361lower.cpp)
8-
target_include_directories(rpp_driver INTERFACE .)

src/codec/adau1361.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Created on: 2018/05/11
55
* Author: Seiichi "Suikan" Horie
66
*/
7+
#if __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
78

89
// GCC/Clang : Promote the switch-enum warning to error.
910
// MSVC : ignored.
@@ -13,7 +14,7 @@
1314

1415
#include <assert.h>
1516

16-
#include "i2cmasterinterface.hpp"
17+
#include "i2c/i2cmaster.hpp"
1718

1819
// Macro for easy-to-read
1920
#define CODEC_SYSLOG(fmt, ...) \
@@ -55,7 +56,7 @@ void ::rpp_driver::Adau1361::Start(void) {
5556
// Enable core to start operation.
5657
adau1361_lower_.EnableCore();
5758
// Set SRC for the right FS.
58-
adau1361_lower_.ConfigureSRC(fs_);
59+
adau1361_lower_.ConfigureSrc(fs_);
5960
// Board independent register initialization.
6061
adau1361_lower_.InitializeRegisters();
6162
// Board dependent register initialization.
@@ -134,3 +135,5 @@ void ::rpp_driver::Adau1361::Mute(CodecChannel channel, bool mute) {
134135
}
135136
CODEC_SYSLOG("Leave.")
136137
}
138+
139+
#endif // __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)

src/codec/adau1361.hpp

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
#ifndef PICO_DRIVER_SRC_CODEC_ADAU1361_HPP_
1111
#define PICO_DRIVER_SRC_CODEC_ADAU1361_HPP_
12+
#if __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
1213

13-
#include <i2cmasterinterface.hpp>
14+
#include <i2c/i2cmaster.hpp>
1415

1516
#include "adau1361lower.hpp"
1617
namespace rpp_driver {
@@ -40,6 +41,44 @@ namespace rpp_driver {
4041
kMClock, // Master clock of UMB-ADAU1361-A[Hz].
4142
codec_lower); // Inject Codec lower part dependency.
4243
* ```
44+
* ### Usage of mock
45+
* In the case of the testing of the user program which uses this class,
46+
* a programmer can use the pre-defined mock class ::rpp_driver::MockAdau1361
47+
* inside adau1361.hpp.
48+
*
49+
* ```cpp
50+
#include <gmock/gmock.h>
51+
#include <gtest/gtest.h>
52+
53+
#include "codec/adau1361.hpp"
54+
#include "codec/umbadau1361lower.hpp"
55+
#include "i2c/i2cmaster.hpp"
56+
57+
58+
class UserCodeTest : public ::testing::Test {
59+
protected:
60+
virtual void SetUp() {
61+
mock_i2c_ = new ::rpp_driver::MockI2cMaster(mock_sdk_);
62+
mock_codec_lower_ = new ::rpp_driver::MockAdau1361Lower(*mock_i2c_);
63+
mock_codec_ = new ::rpp_driver::MockAdau1361(*mock_codec_lower_);
64+
}
65+
66+
virtual void TearDown() {
67+
delete mock_codec_;
68+
delete mock_codec_lower_;
69+
delete mock_i2c_;
70+
}
71+
72+
::rpp_driver::SdkWrapper mock_sdk_;
73+
::rpp_driver::MockI2cMaster *mock_i2c_;
74+
::rpp_driver::MockAdau1361Lower *mock_codec_lower_;
75+
::rpp_driver::MockAdau1361 *mock_codec_;
76+
};
77+
78+
TEST_F(UserCodeTest, foo) {
79+
// Write Test code here.
80+
}
81+
* ```
4382
*/
4483
class Adau1361 {
4584
public:
@@ -159,6 +198,26 @@ class Adau1361 {
159198
bool line_output_mute_;
160199
bool hp_output_mute_; // headphone
161200
};
201+
202+
#if __has_include(<gmock/gmock.h>)
203+
// GCOVR_EXCL_START
204+
class MockAdau1361 : public Adau1361 {
205+
public:
206+
MockAdau1361(Adau1361Lower& adau1361_lower)
207+
: Adau1361(48'000, 12'000'000, adau1361_lower) {
208+
} // with dummy fs and dummy mclock
209+
210+
MOCK_METHOD0(Start, void(void));
211+
MOCK_METHOD3(SetGain,
212+
void(CodecChannel channel, float left_gain, float right_gain));
213+
MOCK_METHOD2(Mute, void(CodecChannel channel, bool mute));
214+
MOCK_METHOD1(Mute, void(CodecChannel channel));
215+
};
216+
// GCOVR_EXCL_STOP
217+
#endif // __has_include(<gmock/gmock.h>)
218+
162219
} // namespace rpp_driver
163220

221+
#endif // __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
222+
164223
#endif /* PICO_DRIVER_SRC_CODEC_ADAU1361_HPP_ */

src/codec/adau1361lower.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
#if __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
2+
13
#include "adau1361lower.hpp"
24

35
#include <assert.h>
46

57
#include <algorithm>
68

7-
rpp_driver::Adau1361Lower::Adau1361Lower(
8-
::rpp_driver::I2cMasterInterface& controller, unsigned int i2c_device_addr)
9+
rpp_driver::Adau1361Lower::Adau1361Lower(::rpp_driver::I2cMaster& controller,
10+
unsigned int i2c_device_addr)
911
: i2c_(controller), device_addr_(i2c_device_addr) {
1012
assert((0x3C > device_addr_) &&
1113
"ADAU1361 I2C Address must be lower than 0x3C.");
@@ -511,11 +513,7 @@ void ::rpp_driver::Adau1361Lower::InitializeRegisters() {
511513
}
512514

513515
// Set the converter clock.
514-
void ::rpp_driver::Adau1361Lower::ConfigureSRC(unsigned int fs) {
515-
assert((fs == 24000 || fs == 32000 || fs == 48000 || fs == 96000 ||
516-
fs == 22050 || fs == 44100 || fs == 88200) &&
517-
"Bad Fs");
518-
516+
void ::rpp_driver::Adau1361Lower::ConfigureSrc(unsigned int fs) {
519517
switch (fs) {
520518
case 22050:
521519
case 24000: {
@@ -549,7 +547,7 @@ void ::rpp_driver::Adau1361Lower::ConfigureSRC(unsigned int fs) {
549547
break;
550548
}
551549
default:
552-
assert(false);
550+
assert(false && "Bad Fs");
553551
}
554552
}
555553

@@ -769,3 +767,5 @@ void ::rpp_driver::Adau1361Lower::SetHpOutputGain(float left_gain,
769767
// SET RHPVOL : R30
770768
SendCommand(txbuf, 3);
771769
}
770+
771+
#endif // __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)

0 commit comments

Comments
 (0)