Article: NuttX RTOS for PinePhone: Feature Phone UI in LVGL, Zig and WebAssembly
#40
I think I got some kind of CPU thermal value, counting backwards Smile just need to work out what value to use for CPU temperature shutdown, not that I am stressing the device too much yet Wink

PS being able to do this in Zig is really nice, I get type safety on the poke() (saved me twice) and errors every time I miscount the bit flags in the registers, which saves me at least 3 times a day Wink




Code:
pub const THS_FILT_CTRL_ADDR = Reg32(THS_FILT_CTRL_REG, THS_BASE_ADDR + THS_FILTER);
pub const THS_FILT_CTRL_REG = packed struct(u32) {
    FILTER_TYPE: Filter = Filter.TYPE4,
    FILTER_EN: bool = false,
    _3: u29 = 0,

    pub const Filter = enum(u2) {
        TYPE2 = 0b00,
        TYPE4 = 0b01,
        TYPE8 = 0b10,
        TYPE16 = 0b11,
    };
};


I am still not sure on the naming scheme still, since the ADDR and REG are pretty much the same thing, but the usage below reads okay I think, and I want to be easily searchable for the register names in the 'User Manual'.  Although probably I change the _ADDR to be _REG, and the _REG to be _VAL or _TYPE, not sure yet, will do some more work on the audio side and see what reads best Smile  It is not very linux like, but I am still trying to get my head around linux abstractions, device trees, file based drivers, etc etc.  Just having some fun for now! Smile  Will also probably break down the CCU chapter into smaller manageable units, it's huge as I am sure you noticed!

Code:
    var fltr = thermals.THS_FILT_CTRL_ADDR.peek();
    fltr.FILTER_TYPE = thermals.THS_FILT_CTRL_REG.Filter.TYPE8;
    fltr.FILTER_EN = true;
    thermals.THS_FILT_CTRL_ADDR.poke(fltr);
  Reply


Messages In This Thread
RE: Article: NuttX RTOS for PinePhone: Feature Phone UI in LVGL, Zig and WebAssembly - by WhiteHexagon - 07-27-2023, 05:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using Signal on PinePhone in mid-2023? dante404 47 14,754 05-03-2024, 02:19 AM
Last Post: dragonhospital
  Slarm64 on PinePhone [Unofficial Slackware ARM - 64 bit] acid andy 38 25,861 04-23-2024, 10:29 AM
Last Post: donchurch
  PinePhone app development WhiteHexagon 15 4,412 04-23-2024, 05:19 AM
Last Post: Jonnyc
Wink PINEPHONE not booting Touchwood 2 577 02-23-2024, 07:27 AM
Last Post: Touchwood
  Slack on PinePhone Adam Seline 5 5,574 12-20-2023, 07:20 AM
Last Post: nickolas
  Struggle to install LibreOffice on the PinePhone Peter Gamma 48 25,390 11-24-2023, 07:02 AM
Last Post: Peter Gamma
  Which word processor to choose for the Pinephone? Peter Gamma 8 2,251 11-23-2023, 01:06 AM
Last Post: Peter Gamma
  openSUSE for Pinephone Alefnode 75 103,719 11-17-2023, 08:37 AM
Last Post: Uturn
  Genode- Sculpt OS for the PinePhone (non Linux) Surehand53 1 1,101 11-04-2023, 07:23 PM
Last Post: tllim
  Abiword as a office mobile word processor for the Pinephone? Peter Gamma 11 2,571 10-24-2023, 08:57 AM
Last Post: Peter Gamma

Forum Jump:


Users browsing this thread: 1 Guest(s)