Skip to content

Commit e9eb2c6

Browse files
committed
printk works
1 parent e592db7 commit e9eb2c6

File tree

28 files changed

+1107
-26
lines changed

28 files changed

+1107
-26
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ add_dependencies(
5555
circuitpython
5656
)
5757
set_target_properties(circuitpython_wrapper PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/libcircuitpython.a)
58-
59-
target_link_libraries(app PUBLIC circuitpython_wrapper)
58+
target_link_libraries(circuitpython_wrapper INTERFACE kernel)
59+
target_link_libraries(app PRIVATE circuitpython_wrapper)

ports/zephyr/background.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "background.h"
8+
9+
#include "py/runtime.h"
10+
#include "supervisor/port.h"
11+
12+
#if CIRCUITPY_DISPLAYIO
13+
#include "shared-module/displayio/__init__.h"
14+
#endif
15+
16+
#if CIRCUITPY_AUDIOBUSIO
17+
#include "common-hal/audiobusio/I2SOut.h"
18+
#endif
19+
20+
#if CIRCUITPY_AUDIOPWMIO
21+
#include "common-hal/audiopwmio/PWMAudioOut.h"
22+
#endif
23+
24+
void port_start_background_tick(void) {
25+
}
26+
27+
void port_finish_background_tick(void) {
28+
}
29+
30+
void port_background_tick(void) {
31+
#if CIRCUITPY_AUDIOPWMIO
32+
audiopwmout_background();
33+
#endif
34+
#if CIRCUITPY_AUDIOBUSIO
35+
i2s_background();
36+
#endif
37+
}
38+
39+
// Allow boards to override this.
40+
MP_WEAK void board_background_task(void) {
41+
}
42+
43+
void port_background_task(void) {
44+
board_background_task();
45+
}

ports/zephyr/background.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2019 Dan Halbert for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
void board_background_task(void);
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2019 Dan Halbert for Adafruit Industries
4+
// SPDX-FileCopyrightText: Copyright (c) 2018 Artur Pacholec
5+
// SPDX-FileCopyrightText: Copyright (c) 2017 hathach
6+
// SPDX-FileCopyrightText: Copyright (c) 2016 Sandeep Mistry All right reserved.
7+
//
8+
// SPDX-License-Identifier: MIT
9+
10+
#include "shared-bindings/busio/I2C.h"
11+
#include "shared-bindings/microcontroller/__init__.h"
12+
#include "shared-bindings/microcontroller/Pin.h"
13+
#include "supervisor/shared/tick.h"
14+
#include "py/mperrno.h"
15+
#include "py/runtime.h"
16+
17+
18+
void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {
19+
never_reset_pin_number(self->scl_pin_number);
20+
never_reset_pin_number(self->sda_pin_number);
21+
}
22+
23+
void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, uint32_t frequency, uint32_t timeout) {
24+
25+
}
26+
27+
bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self) {
28+
return self->sda_pin_number == NO_PIN;
29+
}
30+
31+
void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) {
32+
if (common_hal_busio_i2c_deinited(self)) {
33+
return;
34+
}
35+
36+
// nrfx_twim_uninit(&self->twim_peripheral->twim);
37+
38+
// reset_pin_number(self->sda_pin_number);
39+
// reset_pin_number(self->scl_pin_number);
40+
41+
// self->twim_peripheral->in_use = false;
42+
// common_hal_busio_i2c_mark_deinit(self);
43+
}
44+
45+
void common_hal_busio_i2c_mark_deinit(busio_i2c_obj_t *self) {
46+
self->sda_pin_number = NO_PIN;
47+
}
48+
49+
// nrfx_twim_tx doesn't support 0-length data so we fall back to the hal API
50+
bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) {
51+
bool found = true;
52+
53+
return found;
54+
}
55+
56+
bool common_hal_busio_i2c_try_lock(busio_i2c_obj_t *self) {
57+
if (common_hal_busio_i2c_deinited(self)) {
58+
return false;
59+
}
60+
bool grabbed_lock = false;
61+
return grabbed_lock;
62+
}
63+
64+
bool common_hal_busio_i2c_has_lock(busio_i2c_obj_t *self) {
65+
return self->has_lock;
66+
}
67+
68+
void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) {
69+
self->has_lock = false;
70+
}
71+
72+
uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len) {
73+
return 0;
74+
}
75+
76+
uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) {
77+
if (len == 0) {
78+
return 0;
79+
}
80+
81+
}
82+
83+
uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr,
84+
uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) {
85+
uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false);
86+
if (result != 0) {
87+
return result;
88+
}
89+
90+
return common_hal_busio_i2c_read(self, addr, in_data, in_len);
91+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2016 Scott Shawcroft
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
#include "py/obj.h"
10+
11+
typedef struct {
12+
mp_obj_base_t base;
13+
// twim_peripheral_t *twim_peripheral;
14+
bool has_lock;
15+
uint8_t scl_pin_number;
16+
uint8_t sda_pin_number;
17+
} busio_i2c_obj_t;
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2019 Dan Halbert for Adafruit Industries
4+
// SPDX-FileCopyrightText: Copyright (c) 2018 Artur Pacholec
5+
//
6+
// SPDX-License-Identifier: MIT
7+
8+
#include <string.h>
9+
10+
#include "shared-bindings/busio/SPI.h"
11+
#include "py/mperrno.h"
12+
#include "py/runtime.h"
13+
14+
void spi_reset(void) {
15+
}
16+
17+
void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) {
18+
}
19+
20+
void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, const mcu_pin_obj_t *miso, bool half_duplex) {
21+
22+
}
23+
24+
bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) {
25+
}
26+
27+
void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
28+
if (common_hal_busio_spi_deinited(self)) {
29+
return;
30+
}
31+
}
32+
33+
bool common_hal_busio_spi_configure(busio_spi_obj_t *self, uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t bits) {
34+
return true;
35+
}
36+
37+
bool common_hal_busio_spi_try_lock(busio_spi_obj_t *self) {
38+
if (common_hal_busio_spi_deinited(self)) {
39+
return false;
40+
}
41+
bool grabbed_lock = false;
42+
return grabbed_lock;
43+
}
44+
45+
bool common_hal_busio_spi_has_lock(busio_spi_obj_t *self) {
46+
return self->has_lock;
47+
}
48+
49+
void common_hal_busio_spi_unlock(busio_spi_obj_t *self) {
50+
self->has_lock = false;
51+
}
52+
53+
bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *data, size_t len) {
54+
return true;
55+
}
56+
57+
bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value) {
58+
return true;
59+
}
60+
61+
bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_out, uint8_t *data_in, size_t len) {
62+
return true;
63+
}
64+
65+
uint32_t common_hal_busio_spi_get_frequency(busio_spi_obj_t *self) {
66+
}
67+
68+
uint8_t common_hal_busio_spi_get_phase(busio_spi_obj_t *self) {
69+
return 0;
70+
}
71+
72+
uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t *self) {
73+
return 0;
74+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2016 Scott Shawcroft
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
#include "py/obj.h"
10+
11+
typedef struct {
12+
mp_obj_base_t base;
13+
// const spim_peripheral_t *spim_peripheral;
14+
bool has_lock;
15+
uint8_t clock_pin_number;
16+
uint8_t MOSI_pin_number;
17+
uint8_t MISO_pin_number;
18+
} busio_spi_obj_t;
19+
20+
void spi_reset(void);

0 commit comments

Comments
 (0)