Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
- var param args removed
- heap_tracking works on vportAlloc
- more touchpad struct and enums
- temperature sensors added
kassane committed Mar 21, 2024
1 parent aee04bc commit 6f3617c
Showing 5 changed files with 173 additions and 212 deletions.
22 changes: 6 additions & 16 deletions imports/bootloader.zig
Original file line number Diff line number Diff line change
@@ -394,9 +394,7 @@ pub inline fn efuse_ll_get_pgm_cmd() bool {
pub inline fn efuse_ll_set_read_cmd() void {
EFUSE.cmd.unnamed_0.read_cmd = 1;
}
pub inline fn efuse_ll_set_pgm_cmd(arg_block: u32) void {
var block = arg_block;
_ = █
pub inline fn efuse_ll_set_pgm_cmd(block: u32) void {
EFUSE.cmd.val = @as(u32, @bitCast(@as(c_uint, @truncate(@as(c_ulong, @bitCast(@as(c_ulong, (block << @intCast(2)) & (@as(c_uint, 15) << @intCast(2))))) | (@as(c_ulong, 1) << @intCast(@as(c_int, 1)))))));
}
pub inline fn efuse_ll_set_conf_read_op_code() void {
@@ -405,24 +403,16 @@ pub inline fn efuse_ll_set_conf_read_op_code() void {
pub inline fn efuse_ll_set_conf_write_op_code() void {
EFUSE.conf.unnamed_0.op_code = @as(u32, @bitCast(@as(c_int, 23130)));
}
pub inline fn efuse_ll_set_dac_num(arg_val: u8) void {
var val = arg_val;
_ = &val;
pub inline fn efuse_ll_set_dac_num(val: u8) void {
EFUSE.dac_conf.unnamed_0.dac_num = @as(u32, @bitCast(@as(c_uint, val)));
}
pub inline fn efuse_ll_set_dac_clk_div(arg_val: u8) void {
var val = arg_val;
_ = &val;
pub inline fn efuse_ll_set_dac_clk_div(val: u8) void {
EFUSE.dac_conf.unnamed_0.dac_clk_div = @as(u32, @bitCast(@as(c_uint, val)));
}
pub inline fn efuse_ll_set_pwr_on_num(arg_val: u16) void {
var val = arg_val;
_ = &val;
pub inline fn efuse_ll_set_pwr_on_num(val: u16) void {
EFUSE.wr_tim_conf1.unnamed_0.pwr_on_num = @as(u32, @bitCast(@as(c_uint, val)));
}
pub inline fn efuse_ll_set_pwr_off_num(arg_value: u16) void {
var value = arg_value;
_ = &value;
pub inline fn efuse_ll_set_pwr_off_num(value: u16) void {
EFUSE.wr_tim_conf2.unnamed_0.pwr_off_num = @as(u32, @bitCast(@as(c_uint, value)));
}
pub const ETS_STATUS = enum(c_uint) {
@@ -442,7 +432,7 @@ pub const ETSEventTag = extern struct {
pub const ETSEvent = ETSEventTag;
pub const ETSTask = ?*const fn ([*c]ETSEvent) callconv(.C) void;
pub const ets_idle_cb_t = ?*const fn (?*anyopaque) callconv(.C) void;
pub extern const exc_cause_table: [40][*c]const u8;
pub extern const exc_cause_table: [40][*:0]const u8;
pub extern fn ets_set_user_start(start: u32) void;
pub extern fn ets_printf(fmt: [*:0]const u8, ...) c_int;
pub extern fn ets_get_printf_channel() u8;
341 changes: 147 additions & 194 deletions imports/idf-sys.zig

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions imports/led-strip.zig
Original file line number Diff line number Diff line change
@@ -96,6 +96,7 @@ pub const soc_periph_temperature_sensor_clk_src_t = enum(c_uint) {
TEMPERATURE_SENSOR_CLK_SRC_RC_FAST = 8,
TEMPERATURE_SENSOR_CLK_SRC_DEFAULT = 10,
};
pub const temperature_sensor_clk_src_t = soc_periph_temperature_sensor_clk_src_t;
pub const soc_periph_uart_clk_src_legacy_t = enum(c_uint) {
UART_SCLK_APB = 4,
UART_SCLK_RTC = 8,
@@ -330,3 +331,15 @@ pub extern fn led_strip_set_pixel_hsv(strip: led_strip_handle_t, index: u32, hue
pub extern fn led_strip_refresh(strip: led_strip_handle_t) idf.esp_err_t;
pub extern fn led_strip_clear(strip: led_strip_handle_t) idf.esp_err_t;
pub extern fn led_strip_del(strip: led_strip_handle_t) idf.esp_err_t;
pub const temperature_sensor_obj_t = opaque {};
pub const temperature_sensor_handle_t = ?*temperature_sensor_obj_t;
pub const temperature_sensor_config_t = extern struct {
range_min: c_int = std.mem.zeroes(c_int),
range_max: c_int = std.mem.zeroes(c_int),
clk_src: temperature_sensor_clk_src_t = std.mem.zeroes(temperature_sensor_clk_src_t),
};
pub extern fn temperature_sensor_install(tsens_config: [*c]const temperature_sensor_config_t, ret_tsens: [*c]temperature_sensor_handle_t) idf.esp_err_t;
pub extern fn temperature_sensor_uninstall(tsens: temperature_sensor_handle_t) idf.esp_err_t;
pub extern fn temperature_sensor_enable(tsens: temperature_sensor_handle_t) idf.esp_err_t;
pub extern fn temperature_sensor_disable(tsens: temperature_sensor_handle_t) idf.esp_err_t;
pub extern fn temperature_sensor_get_celsius(tsens: temperature_sensor_handle_t, out_celsius: [*c]f32) idf.esp_err_t;
1 change: 1 addition & 0 deletions main/lib.zig
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ export fn app_main() callconv(.C) void {
// custom allocators (based on raw_c_allocator)
// idf.HeapCapsAllocator
// idf.MultiHeapAllocator
// idf.vPortAllocator

var heap = idf.HeapCapsAllocator.init(.MALLOC_CAP_8BIT);
var arena = std.heap.ArenaAllocator.init(heap.allocator());
8 changes: 6 additions & 2 deletions sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -5,5 +5,9 @@ CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS=y
CONFIG_COMPILER_STACK_CHECK_MODE_STRONG=y
CONFIG_COMPILER_STACK_CHECK=y

# not working using `HeapCapsAllocator`, but std `raw_c_allocator` works
# CONFIG_HEAP_TASK_TRACKING=y
# This allows to use 1 ms granuality for thread sleeps (10 ms by default).
# CONFIG_FREERTOS_HZ=1000

# not working using `HeapCapsAllocator`,
# but std `raw_c_allocator` or `vPortAllocator` works
# CONFIG_HEAP_TASK_TRACKING=y

0 comments on commit 6f3617c

Please sign in to comment.