Skip to content

Commit

Permalink
Integrates driver framework (#246)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
ikskuh and Felix (xq) Queißner authored Nov 14, 2024
1 parent d6a97c9 commit 2c17eb8
Show file tree
Hide file tree
Showing 23 changed files with 3,338 additions and 132 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
zig-out/
zig-cache/
.zig-cache/
microzig-deploy/
__pycache__/
.direnv/
.DS_Store
.gdbinit
.lldbinit
.direnv/
__pycache__/
.venv
.zig-cache/
boxzer-out
microzig-deploy/
zig-cache/
zig-out/
7 changes: 7 additions & 0 deletions build/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
host_build: *Build,
self: *Build.Dependency,
microzig_core: *Build.Dependency,
drivers_dep: *Build.Dependency,
generate_linkerscript: *Build.Step.Compile,

const std = @import("std");
Expand Down Expand Up @@ -48,12 +49,14 @@ pub fn init(b: *Build, opts: struct {
}) *MicroZig {
const mz_dep = b.dependency(opts.dependency_name, .{});
const core_dep = mz_dep.builder.dependency("microzig/core", .{});
const drivers_dep = mz_dep.builder.dependency("microzig/drivers", .{});
const ret = b.allocator.create(MicroZig) catch @panic("OOM");
ret.* =
MicroZig{
.host_build = b,
.self = mz_dep,
.microzig_core = core_dep,
.drivers_dep = drivers_dep,
.generate_linkerscript = mz_dep.builder.addExecutable(.{
.name = "generate-linkerscript",
.root_source_file = .{ .cwd_relative = comptime root() ++ "/src/generate_linkerscript.zig" },
Expand Down Expand Up @@ -146,6 +149,10 @@ pub fn add_firmware(
.name = "config",
.module = micro_build.createModule(.{ .root_source_file = config.getSource() }),
},
.{
.name = "drivers",
.module = mz.drivers_dep.module("drivers"),
},
},
}),
.cpu = undefined,
Expand Down
3 changes: 3 additions & 0 deletions build/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
.@"microzig/build/definitions" = .{
.path = "definitions",
},
.@"microzig/drivers" = .{
.path = "../drivers",
},
},

.paths = .{
Expand Down
1 change: 0 additions & 1 deletion core/src/drivers.zig

This file was deleted.

7 changes: 0 additions & 7 deletions core/src/drivers/experimental.zig

This file was deleted.

67 changes: 0 additions & 67 deletions core/src/drivers/experimental/button.zig

This file was deleted.

50 changes: 0 additions & 50 deletions core/src/drivers/experimental/quadrature.zig

This file was deleted.

4 changes: 3 additions & 1 deletion core/src/microzig.zig
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ pub const hal = if (config.has_hal) @import("hal") else void;
/// Provides access to board features or is `void` when no board is present.
pub const board = if (config.has_board) @import("board") else void;

/// Contains device-independent drivers for peripherial devices.
pub const drivers = @import("drivers");

pub const mmio = @import("mmio.zig");
pub const interrupt = @import("interrupt.zig");
pub const core = @import("core.zig");
pub const drivers = @import("drivers.zig");
pub const utilities = @import("utilities.zig");

/// The microzig default panic handler. Will disable interrupts and loop endlessly.
Expand Down
20 changes: 20 additions & 0 deletions drivers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# microzig-driver-framework

A collection of device drivers for the use with MicroZig.

## Drivers

> Drivers with a checkmark are already implemented, drivers without are missing
- Input
- [x] Keyboard Matrix
- [x] Rotary Encoder
- [x] Debounced Button
- Touch
- [ ] [XPT2046](https://github.com/ZigEmbeddedGroup/microzig/issues/247)
- Display
- [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)
- [ ] [ST7735](https://github.com/ZigEmbeddedGroup/microzig/issues/250) (WIP)
- [ ] [ILI9488](https://github.com/ZigEmbeddedGroup/microzig/issues/249)
- Wireless
- [ ] [SX1276, SX1278](https://github.com/ZigEmbeddedGroup/microzig/issues/248)
Loading

0 comments on commit 2c17eb8

Please sign in to comment.