Skip to content

Commit a7ea2b4

Browse files
committed
TEST(PicoWrapper, i2c_read_blocking) is under programming.
1 parent 2bb2f79 commit a7ea2b4

8 files changed

Lines changed: 326 additions & 97 deletions

File tree

samples/interrupt_sample/pico_driver/pico_wrapper.cpp

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#ifndef EXPECT_EQ // If not build for GTest, include followings.
2+
3+
#include "picowrapper.hpp"
4+
5+
#include "hardware/i2c.h"
6+
#include "pico/stdlib.h"
7+
8+
#endif
9+
10+
void PicoWrapper::gpio_init(uint gpio) { ::gpio_init(gpio); }
11+
12+
void PicoWrapper::gpio_set_dir(uint gpio, bool out) {
13+
::gpio_set_dir(gpio, out);
14+
}
15+
16+
void PicoWrapper::gpio_put(uint gpio, bool value) { ::gpio_put(gpio, value); }
17+
18+
bool PicoWrapper::gpio_get(uint gpio) { return ::gpio_get(gpio); }
19+
20+
void PicoWrapper::gpio_pull_up(uint gpio) { ::gpio_pull_up(gpio); }
21+
22+
uint PicoWrapper::i2c_init(i2c_inst_t* i2c, uint baudrate) {
23+
return ::i2c_init(i2c, baudrate);
24+
}
25+
26+
int PicoWrapper::i2c_read_blocking(i2c_inst_t* i2c, uint8_t addr, uint8_t* dst,
27+
size_t len, bool nostop) {
28+
return ::i2c_read_blocking(i2c, addr, dst, len, nostop);
29+
}
30+
31+
int PicoWrapper::i2c_write_blocking(i2c_inst_t* i2c, uint8_t addr,
32+
const uint8_t* src, size_t len,
33+
bool nostop) {
34+
return ::i2c_write_blocking(i2c, addr, src, len, nostop);
35+
}

samples/interrupt_sample/pico_driver/pico_wrapper.hpp renamed to samples/interrupt_sample/pico_driver/picowrapper.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef __DRIVER_PICO_WRAPPER_HPP__
2-
#define __DRIVER_PICO_WRAPPER_HPP__
1+
#ifndef __DRIVER_PICOWRAPPER_HPP__
2+
#define __DRIVER_PICOWRAPPER_HPP__
33

44
#ifndef EXPECT_EQ // If not build for GTest, include followings.
55

@@ -16,9 +16,9 @@
1616
* target_link_libraries(${PROJECT_NAME} pico_stdlib hardware_i2c)
1717
* @endcode
1818
*/
19-
class pico_wrapper {
19+
class PicoWrapper {
2020
public:
21-
virtual ~pico_wrapper() {}
21+
virtual ~PicoWrapper() {}
2222
virtual void gpio_init(uint gpio);
2323
/**
2424
* @brief Set a single GPIO direction.
@@ -85,4 +85,4 @@ class pico_wrapper {
8585
virtual int i2c_write_blocking(i2c_inst_t *i2c, uint8_t addr,
8686
const uint8_t *src, size_t len, bool nostop);
8787
};
88-
#endif // __DRIVER_PICO_WRAPPER_HPP__
88+
#endif // __DRIVER_PICOWRAPPER_HPP__

test/.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"files.associations": {
3+
"array": "cpp",
4+
"string_view": "cpp",
5+
"initializer_list": "cpp",
6+
"ranges": "cpp",
7+
"utility": "cpp"
8+
}
9+
}

test/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ cmake_minimum_required(VERSION 3.14)
44
# Redefine project for testing.
55
project(test_i2s)
66

7+
# Enable test to let the VS code find the test.
8+
include(CTest)
9+
enable_testing()
10+
11+
712
# GoogleTest requires at least C++14
813
set(CMAKE_CXX_STANDARD 14)
914
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -18,14 +23,12 @@ FetchContent_MakeAvailable(googletest)
1823

1924

2025
# Add the executable for the testcase which is using googletest
21-
add_executable(${PROJECT_NAME} test_pico_wrapper.cpp)
26+
add_executable(${PROJECT_NAME} test_picowrapper.cpp)
2227

2328
# Add the library under test.
2429
target_link_libraries(${PROJECT_NAME}
2530
GTest::gtest_main
2631
)
27-
target_include_directories(${PROJECT_NAME} PUBLIC
28-
${PROJECT_SOURCE_DIR}/../src/)
2932

3033
include(GoogleTest)
3134
gtest_discover_tests(${PROJECT_NAME})

test/test_pico_wrapper.cpp

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)