Skip to content

Commit 2c17eb8

Browse files
ikskuhFelix (xq) Queißner
and
Felix (xq) Queißner
authored
Integrates driver framework (#246)
* Initial commit * Initial commit: Keyboard and SSD1306 driver and some basic project structure. * Introduces StreamDevice and DatagramDevice for the framework as a reference type * Introduces DigitalIO as a base driver and ports KeyboardMatrix to it. * Starts implementing the ST77xx driver * Adjusts to ZEG coding guidelines * Updates README.md * Adds some minor fixes. * Update to 0.13.0 * Updates DigitalIO to make .read() may error (think: port expanders!), fixes some details in rotary-encoder and debounced-button * Adds a framebuffer type for the SSD1306 * Fixes some bugs in the SSD1306 driver, enables quicker image transfer. * Removes pre-merge cruft * Adds missing build.zig * Applies style guides more thoroughly * Deletes empty driver files * Refactors Keyboard_Matrix * Refactors Debounced_Button * Refactors Rotary_Encoder * Renames ./driver to ./drivers, adds the drivers package to '@import(microzig).drivers' so it's exposed in the framework by default. * Adds README to ./drivers * Adds missing build.zig.zon to driver framework. * Renames project to work around bug in boxzer * Ports SSD1306 and Datagram_Device to use/provide writev/readv functions * Prepares SSD1306 to be used with 4-wire SPI * Updates Stream_Device to provide writev/readv * Adds a unit test for the Datagram_Device.Test_Device * Implements Stream_Device.Test_Device with a unit test to ensure proper function. * Enables SSD1306 with 4-wire SPI mode. * Starts to implement device drivers for RP2 HAL * Adds rp2.hal.GPIO_Device as a Digital_IO driver * Introduces the SSD1306 dynamic mode support, which can serve all other modes at runtime * Drops accidential file clone * Attempts to fix boxzer CI failure --------- Co-authored-by: Felix (xq) Queißner <git@random-projects.net>
1 parent d6a97c9 commit 2c17eb8

23 files changed

+3338
-132
lines changed

.gitignore

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
zig-out/
2-
zig-cache/
3-
.zig-cache/
4-
microzig-deploy/
1+
__pycache__/
2+
.direnv/
53
.DS_Store
64
.gdbinit
75
.lldbinit
8-
.direnv/
9-
__pycache__/
106
.venv
7+
.zig-cache/
118
boxzer-out
9+
microzig-deploy/
10+
zig-cache/
11+
zig-out/

build/build.zig

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
host_build: *Build,
33
self: *Build.Dependency,
44
microzig_core: *Build.Dependency,
5+
drivers_dep: *Build.Dependency,
56
generate_linkerscript: *Build.Step.Compile,
67

78
const std = @import("std");
@@ -48,12 +49,14 @@ pub fn init(b: *Build, opts: struct {
4849
}) *MicroZig {
4950
const mz_dep = b.dependency(opts.dependency_name, .{});
5051
const core_dep = mz_dep.builder.dependency("microzig/core", .{});
52+
const drivers_dep = mz_dep.builder.dependency("microzig/drivers", .{});
5153
const ret = b.allocator.create(MicroZig) catch @panic("OOM");
5254
ret.* =
5355
MicroZig{
5456
.host_build = b,
5557
.self = mz_dep,
5658
.microzig_core = core_dep,
59+
.drivers_dep = drivers_dep,
5760
.generate_linkerscript = mz_dep.builder.addExecutable(.{
5861
.name = "generate-linkerscript",
5962
.root_source_file = .{ .cwd_relative = comptime root() ++ "/src/generate_linkerscript.zig" },
@@ -146,6 +149,10 @@ pub fn add_firmware(
146149
.name = "config",
147150
.module = micro_build.createModule(.{ .root_source_file = config.getSource() }),
148151
},
152+
.{
153+
.name = "drivers",
154+
.module = mz.drivers_dep.module("drivers"),
155+
},
149156
},
150157
}),
151158
.cpu = undefined,

build/build.zig.zon

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
.@"microzig/build/definitions" = .{
1515
.path = "definitions",
1616
},
17+
.@"microzig/drivers" = .{
18+
.path = "../drivers",
19+
},
1720
},
1821

1922
.paths = .{

core/src/drivers.zig

-1
This file was deleted.

core/src/drivers/experimental.zig

-7
This file was deleted.

core/src/drivers/experimental/button.zig

-67
This file was deleted.

core/src/drivers/experimental/quadrature.zig

-50
This file was deleted.

core/src/microzig.zig

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ pub const hal = if (config.has_hal) @import("hal") else void;
3131
/// Provides access to board features or is `void` when no board is present.
3232
pub const board = if (config.has_board) @import("board") else void;
3333

34+
/// Contains device-independent drivers for peripherial devices.
35+
pub const drivers = @import("drivers");
36+
3437
pub const mmio = @import("mmio.zig");
3538
pub const interrupt = @import("interrupt.zig");
3639
pub const core = @import("core.zig");
37-
pub const drivers = @import("drivers.zig");
3840
pub const utilities = @import("utilities.zig");
3941

4042
/// The microzig default panic handler. Will disable interrupts and loop endlessly.

drivers/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# microzig-driver-framework
2+
3+
A collection of device drivers for the use with MicroZig.
4+
5+
## Drivers
6+
7+
> Drivers with a checkmark are already implemented, drivers without are missing
8+
9+
- Input
10+
- [x] Keyboard Matrix
11+
- [x] Rotary Encoder
12+
- [x] Debounced Button
13+
- Touch
14+
- [ ] [XPT2046](https://github.com/ZigEmbeddedGroup/microzig/issues/247)
15+
- Display
16+
- [x] SSD1306 (I²C works, [3-wire SPI](https://github.com/ZigEmbeddedGroup/microzig/issues/251) and [4-wire SPI](https://github.com/ZigEmbeddedGroup/microzig/issues/252) are missing)
17+
- [ ] [ST7735](https://github.com/ZigEmbeddedGroup/microzig/issues/250) (WIP)
18+
- [ ] [ILI9488](https://github.com/ZigEmbeddedGroup/microzig/issues/249)
19+
- Wireless
20+
- [ ] [SX1276, SX1278](https://github.com/ZigEmbeddedGroup/microzig/issues/248)

0 commit comments

Comments
 (0)