├── sensors ├── psp │ ├── generic │ │ ├── psp.mk │ │ └── psp.c │ ├── armv7a9-zynq7000 │ │ └── psp.mk │ └── psp.h ├── gps │ ├── sensors.mk │ └── gps_sim.c ├── common │ ├── bus │ │ └── bus.c │ └── sim │ │ ├── simsensor_reader.h │ │ └── event_queue.h ├── imu │ ├── sensors.mk │ └── imu_sim.c ├── baro │ ├── sensors.mk │ └── baro_sim.c ├── mag │ ├── sensors.mk │ └── mag_sim.c ├── server-include │ └── libsensors │ │ ├── sim │ │ └── simsensor.h │ │ └── local │ │ └── sensors.h ├── locsensor.c └── Makefile ├── _targets ├── Makefile.armv7m7-imxrt105x ├── Makefile.armv7m7-imxrt117x ├── Makefile.armv7r5f-tda4vm ├── Makefile.host-generic ├── Makefile.armv7m4-stm32l4x6 ├── Makefile.armv7r5f-zynqmp ├── Makefile.armv8r52-mps3an536 ├── Makefile.riscv64-grfpga ├── Makefile.sparcv8leon-generic ├── Makefile.armv8m33-mcxn94x ├── Makefile.armv8m55-stm32n6 ├── Makefile.riscv64-gr765 ├── Makefile.riscv64-generic ├── Makefile.sparcv8leon-gr712rc ├── Makefile.sparcv8leon-gr740 ├── Makefile.sparcv8leon-gr716 ├── Makefile.ia32-generic ├── Makefile.aarch64a53-zynqmp ├── Makefile.armv7a9-zynq7000 ├── Makefile.armv7a7-imx6ull └── Makefile.armv7m7-imxrt106x ├── .gitignore ├── tty ├── pc-tty │ ├── _test.sh │ ├── README.md │ ├── Makefile │ ├── ttypc_fbcon.h │ ├── ttypc_bioskbd.h │ ├── ttypc_mouse.h │ ├── ttypc_kbd.h │ ├── ttypc_ps2.h │ └── event_queue.h ├── uart16550 │ ├── README.md │ ├── Makefile │ ├── uarthw.h │ ├── uart16550.h │ └── uarthw-pc.c ├── libtty │ ├── README.md │ ├── Makefile │ └── libtty_disc.h ├── _pl2303 │ └── if.h ├── spike-tty │ ├── README.md │ └── Makefile ├── zynq-uart │ └── Makefile ├── grlib-uart │ └── Makefile ├── imx6ull-uart │ ├── Makefile │ └── README.md ├── cmsdk-apbuart │ └── Makefile └── usbacm │ ├── Makefile │ └── srv.c ├── otp ├── imx6ull-otp │ ├── README.md │ └── Makefile ├── imxrt117x-otp │ ├── Makefile │ └── README.md └── README.md ├── storage ├── pc-ata │ ├── README.md │ ├── Makefile │ ├── mbr.c │ └── mbr.h ├── zynq-flash │ ├── tests │ │ ├── test.yaml │ │ └── Makefile │ ├── Makefile │ ├── flashdrv.h │ └── qspi.h ├── flashdrv │ ├── drv │ │ ├── grlib-ftmctrl │ │ │ ├── Makefile │ │ │ ├── flashdrv.h │ │ │ ├── ftmctrl.h │ │ │ └── cmds.h │ │ └── grlib-spimctrl │ │ │ ├── Makefile │ │ │ ├── flashdrv.h │ │ │ └── spimctrl.h │ ├── Makefile │ ├── include │ │ └── flashdrv │ │ │ ├── flash_interface.h │ │ │ ├── common.h │ │ │ ├── flashsrv.h │ │ │ └── cfi.h │ └── common.c ├── virtio-blk │ ├── Makefile │ └── vblk.h ├── host-flash │ ├── Makefile │ ├── host-flashsrv.h │ └── host-flash.h ├── gr716-flash │ ├── tests │ │ ├── Makefile │ │ └── utils.h │ ├── Makefile │ ├── gr716-flashsrv.h │ ├── nor │ │ └── nor.h │ └── flashdrv.h ├── imxrt-flash │ ├── tests │ │ ├── Makefile │ │ └── utils.h │ ├── Makefile │ ├── imxrt-flashsrv.h │ └── flashdrv.h ├── imx6ull-flashnor │ ├── imx6ull-flashnor-qspi.h │ ├── imx6ull-flashnor-ecspi.h │ ├── Makefile │ └── imx6ull-flashnor-drv.h ├── zynq7000-sdcard │ ├── Makefile │ ├── sdstorage_dev.h │ └── zynq7000-sdio.h ├── umass │ ├── umass.h │ ├── Makefile │ ├── scsi.h │ └── srv.c └── imx6ull-flash │ ├── Makefile │ └── imx6ull-flashdev.h ├── gpio ├── rcpwm │ ├── README.md │ ├── Makefile │ ├── include │ │ └── rcpwm │ │ │ ├── api.h │ │ │ └── msg.h │ └── rcpwm.c ├── zynq7000-xgpio │ ├── Makefile │ └── README.md ├── zynq-pwm │ ├── Makefile │ ├── README.md │ └── ip │ │ └── README.md ├── imx6ull-gpio │ ├── Makefile │ └── imx6ull-gpio.h └── zynq7000-gpio │ ├── Makefile │ ├── gpio.h │ └── zynq7000-gpio-msg.h ├── spi ├── imx6ull-qspi │ ├── Makefile │ └── include │ │ └── imx6ull-qspi.h ├── imx6ull-ecspi │ └── Makefile ├── zynq-spi │ └── Makefile ├── zynq7000-xspi │ ├── Makefile │ └── libzynq7000-xspi.h └── common │ ├── Makefile │ ├── spi.h │ └── spi-msg.h ├── libklog ├── Makefile └── libklog.h ├── usb ├── cdc-demo │ └── Makefile ├── ehci │ └── Makefile └── libusbclient │ ├── Makefile │ ├── imx-usbc │ └── phy.h │ └── imx6ull-usbc │ └── phy.c ├── librtt └── Makefile ├── dma ├── grdmac2 │ └── Makefile ├── imxrt-edma │ └── Makefile └── imx6ull-sdma │ ├── Makefile │ └── sdma.h ├── sdio ├── imx6ull │ └── Makefile └── common │ ├── Makefile │ └── sdio.h ├── multi ├── imxrt-multi │ ├── tests │ │ └── Makefile │ ├── common.c │ ├── imxrt1050.h │ ├── cm4.h │ ├── cm4 │ │ ├── example │ │ │ ├── blinky.sh │ │ │ └── blinky.c │ │ └── lib │ │ │ ├── string.h │ │ │ ├── interrupt.h │ │ │ ├── mu.h │ │ │ ├── string.c │ │ │ ├── _startc.c │ │ │ ├── gpio.h │ │ │ ├── interrupt.c │ │ │ └── Makefile.ext │ ├── trng.h │ ├── spi.h │ ├── pct2075.h │ ├── uart.h │ ├── rtt.h │ ├── trace.h │ ├── Makefile │ ├── gpio.h │ ├── i2c.h │ ├── common.h │ ├── posixsrv.c │ └── helpers.h ├── grlib-multi │ ├── Makefile │ ├── adc.h │ ├── spi.h │ ├── gpio.h │ └── uart.h ├── mcxn94x-multi │ ├── Makefile │ ├── uart.h │ ├── cpu.h │ ├── dev.h │ ├── common.c │ └── common.h └── stm32l4-multi │ ├── adc.h │ ├── rng.h │ ├── libmulti │ ├── Makefile │ └── include │ │ └── libmulti │ │ ├── libaes.h │ │ ├── libi2c.h │ │ ├── libhash.h │ │ └── libspi.h │ ├── tty.h │ ├── exti.h │ ├── gpio.h │ ├── uart.h │ ├── spi.h │ ├── rtc.h │ ├── Makefile │ ├── i2c.h │ ├── rcc.h │ ├── posixsrv.c │ ├── rcc_l4.c │ ├── common.h │ └── stm32l4x6_base.h ├── spacewire ├── grspw2 │ └── Makefile ├── grspwrtr │ ├── Makefile │ └── grspwrtr.h └── libgrspw │ └── Makefile ├── watchdog └── imx6ull │ ├── Makefile │ └── watchdog.h ├── libpseudodev ├── Makefile └── pseudodev.h ├── pcie ├── pcie-xilinx-axi │ ├── Makefile │ └── pcie-xilinx-axi.h ├── pcie-xilinx-nwl │ ├── Makefile │ └── pcie-xilinx-nwl.h ├── tebf0808 │ ├── Makefile │ ├── tebf0808-pcie-refclk.h │ └── tebf0808-ps-gtr-phy.h ├── server │ ├── Makefile │ └── pcie.h └── README.md ├── .github └── workflows │ ├── lint.yml │ └── ci.yml ├── display └── oled-128O064B0 │ ├── fonts │ ├── font.c │ └── font.h │ ├── Makefile │ ├── oled-phy.h │ ├── oled-api.h │ └── oled-graphic.h ├── i2c ├── common │ ├── Makefile │ ├── i2c-msg.h │ └── i2c.h ├── zynq │ └── Makefile └── imx6ull │ └── Makefile ├── temp └── Makefile ├── mag └── Makefile ├── README.md ├── rtc ├── Makefile └── rtc.h ├── adc ├── ade7913 │ ├── Makefile │ ├── gpio.h │ ├── adc-api-ade7913.h │ ├── gpio.c │ ├── flexpwm.h │ └── ade7913.h └── ad7779 │ ├── imx6ull │ └── spi.c │ ├── Makefile │ ├── ad7779-low.h │ └── imxrt │ └── spi.c ├── can └── zynqmp-can │ ├── Makefile │ ├── README.md │ └── zynqmp-can-priv.h ├── Makefile ├── .clang-format └── LICENSE /sensors/psp/generic/psp.mk: -------------------------------------------------------------------------------- 1 | PSP_DEP_LIBS := -------------------------------------------------------------------------------- /_targets/Makefile.armv7m7-imxrt105x: -------------------------------------------------------------------------------- 1 | Makefile.armv7m7-imxrt106x -------------------------------------------------------------------------------- /_targets/Makefile.armv7m7-imxrt117x: -------------------------------------------------------------------------------- 1 | Makefile.armv7m7-imxrt106x -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .DS_Store 3 | .idea/ 4 | build/ 5 | .vscode/* 6 | -------------------------------------------------------------------------------- /sensors/psp/armv7a9-zynq7000/psp.mk: -------------------------------------------------------------------------------- 1 | PSP_DEP_LIBS := libzynq7000-gpio-msg libspi-msg -------------------------------------------------------------------------------- /tty/pc-tty/_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #This file is used for performing driver tests -------------------------------------------------------------------------------- /tty/uart16550/README.md: -------------------------------------------------------------------------------- 1 | # uart16550 2 | 3 | This server provides TTY functionality for 16550 UART. 4 | -------------------------------------------------------------------------------- /otp/imx6ull-otp/README.md: -------------------------------------------------------------------------------- 1 | This tool blows OTP fuses to prepare i.MX 6ULL to boot from the NAND memory. 2 | -------------------------------------------------------------------------------- /tty/libtty/README.md: -------------------------------------------------------------------------------- 1 | # libtty 2 | 3 | This library provides standard TTY functionality for console servers. 4 | -------------------------------------------------------------------------------- /tty/_pl2303/if.h: -------------------------------------------------------------------------------- 1 | #ifndef _USB_SERIAL_H_ 2 | #define _USB_SERIAL_H_ 3 | 4 | extern int usb_serialInit(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /storage/pc-ata/README.md: -------------------------------------------------------------------------------- 1 | # pc-ata 2 | 3 | This library gives abstraction layer for IBM PC compatible ATA hard disc controller. 4 | -------------------------------------------------------------------------------- /tty/pc-tty/README.md: -------------------------------------------------------------------------------- 1 | # pc-tty 2 | 3 | This server provides TTY functionality for IBM PC compatible VGA and keyboard terminal. 4 | -------------------------------------------------------------------------------- /tty/spike-tty/README.md: -------------------------------------------------------------------------------- 1 | # spike-tty 2 | 3 | This server implements TTY functionality for HTIF console emulated by RISCV Spike emulator. 4 | -------------------------------------------------------------------------------- /storage/zynq-flash/tests/test.yaml: -------------------------------------------------------------------------------- 1 | test: 2 | type: unit 3 | targets: 4 | value: [armv7a9-zynq7000] 5 | tests: 6 | - name: test_flashdrv 7 | exec: test_flashdrv 8 | 9 | -------------------------------------------------------------------------------- /gpio/rcpwm/README.md: -------------------------------------------------------------------------------- 1 | # rcpwm 2 | Generic remotr-control pwm library. Holds two headers: 3 | - rcpwm/api.h: messaging interface for the client side, 4 | - rcpwm/msg.h: message structures for the server side. 5 | -------------------------------------------------------------------------------- /_targets/Makefile.armv7r5f-tda4vm: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # TDA4VM drivers 5 | # 6 | # Copyright 2025 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := uart16550 10 | -------------------------------------------------------------------------------- /_targets/Makefile.host-generic: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # host-generic drivers 5 | # 6 | # Copyright 2021 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := host-flash 10 | -------------------------------------------------------------------------------- /_targets/Makefile.armv7m4-stm32l4x6: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # STM32 drivers 5 | # 6 | # Copyright 2019, 2020 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := stm32l4-multi 10 | -------------------------------------------------------------------------------- /_targets/Makefile.armv7r5f-zynqmp: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # ZynqMP drivers 5 | # 6 | # Copyright 2021 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := zynq-uart zynq-flash 10 | -------------------------------------------------------------------------------- /_targets/Makefile.armv8r52-mps3an536: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 devices 3 | # 4 | # armv8r52-mps3an536 drivers 5 | # 6 | # Copyright 2024 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := cmsdk-apbuart 10 | -------------------------------------------------------------------------------- /otp/imx6ull-otp/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imx6ull-otp 3 | # 4 | # Copyright 2018, 2019 Phoenix Systems 5 | # 6 | 7 | NAME := imx6ull-otp 8 | LOCAL_SRCS := imx6ull-otp.c 9 | include $(binary.mk) 10 | -------------------------------------------------------------------------------- /otp/imxrt117x-otp/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imxrt117x-otp 3 | # 4 | # Copyright 2020 Phoenix Systems 5 | # 6 | 7 | NAME := imxrt117x-otp 8 | LOCAL_SRCS := imxrt117x-otp.c 9 | include $(binary.mk) 10 | -------------------------------------------------------------------------------- /_targets/Makefile.riscv64-grfpga: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # riscv64-grfpga drivers 5 | # 6 | # Copyright 2024 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := grlib-uart flashdrv 10 | -------------------------------------------------------------------------------- /_targets/Makefile.sparcv8leon-generic: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # sparcv8leon-generic drivers 5 | # 6 | # Copyright 2024 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := grlib-uart 10 | -------------------------------------------------------------------------------- /spi/imx6ull-qspi/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imx6ull-qspi driver 3 | # 4 | # Copyright 2023 Phoenix Systems 5 | # 6 | 7 | NAME := libimx6ull-qspi 8 | LOCAL_SRCS := qspi.c 9 | include $(static-lib.mk) 10 | -------------------------------------------------------------------------------- /_targets/Makefile.armv8m33-mcxn94x: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # MCX N94x drivers 5 | # 6 | # Copyright 2019, 2020, 2024 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := mcxn94x-multi 10 | -------------------------------------------------------------------------------- /_targets/Makefile.armv8m55-stm32n6: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # STM32 drivers 5 | # 6 | # Copyright 2019, 2020 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := stm32l4-multi libspi-msg 10 | -------------------------------------------------------------------------------- /_targets/Makefile.riscv64-gr765: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # riscv64-gr765 drivers 5 | # 6 | # Copyright 2025 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := grlib-uart grspw2 grspwrtr 10 | -------------------------------------------------------------------------------- /gpio/zynq7000-xgpio/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS zynq7000-gpio driver 3 | # 4 | # Copyright 2022 Phoenix Systems 5 | # 6 | 7 | NAME := zynq7000-xgpio 8 | LOCAL_SRCS := xgpio.c 9 | 10 | include $(binary.mk) 11 | -------------------------------------------------------------------------------- /_targets/Makefile.riscv64-generic: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # ia32/QEMU drivers 5 | # 6 | # Copyright 2019 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := spike-tty uart16550 virtio-blk 10 | -------------------------------------------------------------------------------- /_targets/Makefile.sparcv8leon-gr712rc: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # sparcv8leon-gr712rc drivers 5 | # 6 | # Copyright 2023 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := grlib-multi flashdrv 10 | -------------------------------------------------------------------------------- /_targets/Makefile.sparcv8leon-gr740: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # sparcv8leon-gr740 drivers 5 | # 6 | # Copyright 2025 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := grlib-multi flashdrv 10 | -------------------------------------------------------------------------------- /libklog/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS libklog 3 | # 4 | # Copyright 2021 Phoenix Systems 5 | # 6 | 7 | NAME := libklog 8 | LOCAL_SRCS := libklog.c 9 | LOCAL_HEADERS := libklog.h 10 | 11 | include $(static-lib.mk) 12 | -------------------------------------------------------------------------------- /spi/imx6ull-ecspi/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imx6ull-ecspi driver 3 | # 4 | # Copyright 2018, 2019 Phoenix Systems 5 | # 6 | 7 | NAME := libimx6ull-ecspi 8 | LOCAL_SRCS := libecspi.c 9 | include $(static-lib.mk) 10 | -------------------------------------------------------------------------------- /gpio/rcpwm/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS remote control pwm messaging library 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | 8 | NAME := librcpwm 9 | LOCAL_SRCS := rcpwm.c 10 | 11 | include $(static-lib.mk) 12 | -------------------------------------------------------------------------------- /gpio/zynq-pwm/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS zynq-pwm driver 3 | # 4 | # Copyright 2022 Phoenix Systems 5 | # 6 | 7 | NAME := zynq-pwm 8 | LOCAL_SRCS := pwm.c 9 | DEP_LIBS := librcpwm 10 | 11 | include $(binary.mk) 12 | 13 | -------------------------------------------------------------------------------- /usb/cdc-demo/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS cdc demo 3 | # 4 | # Copyright 2020 Phoenix Systems 5 | # 6 | 7 | NAME := cdc-demo 8 | LOCAL_SRCS := cdc-demo.c 9 | LIBS := libusb libusbclient 10 | 11 | include $(binary.mk) 12 | -------------------------------------------------------------------------------- /_targets/Makefile.sparcv8leon-gr716: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # sparcv8leon-gr716 drivers 5 | # 6 | # Copyright 2023 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := gr716-flash grlib-multi libgrdmac2 10 | -------------------------------------------------------------------------------- /librtt/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS rtt pipes library 3 | # 4 | # Copyright 2023-2024 Phoenix Systems 5 | # 6 | 7 | NAME := librtt 8 | LOCAL_SRCS := librtt.c 9 | LOCAL_HEADERS := librtt.h 10 | 11 | include $(static-lib.mk) 12 | -------------------------------------------------------------------------------- /otp/README.md: -------------------------------------------------------------------------------- 1 | # OTP drivers 2 | 3 | Directory contains drivers for OTP (One-Time Programming) controllers. Such controllers usualy alows to blow fuses to permanently set the state 4 | of contoller PINs or write specific values into the ROM memory. 5 | -------------------------------------------------------------------------------- /tty/zynq-uart/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS zynq-uart driver 3 | # 4 | # Copyright 2021 Phoenix Systems 5 | # 6 | 7 | NAME := zynq-uart 8 | LOCAL_SRCS := zynq-uart.c 9 | DEP_LIBS := libtty libklog 10 | include $(binary.mk) 11 | -------------------------------------------------------------------------------- /dma/grdmac2/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS grlib-dmac2 API 3 | # 4 | # Copyright 2024 Phoenix Systems 5 | # 6 | 7 | NAME := libgrdmac2 8 | LOCAL_SRCS := grdmac2.c 9 | LOCAL_HEADERS := grdmac2.h 10 | 11 | include $(static-lib.mk) 12 | -------------------------------------------------------------------------------- /sdio/imx6ull/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imx6ull-sdio driver 3 | # 4 | # Copyright 2022 Phoenix Systems 5 | # 6 | 7 | NAME := imx6ull-sdio 8 | LOCAL_SRCS := imx6ull-sdio.c 9 | DEPS := sdio-common 10 | include $(static-lib.mk) 11 | -------------------------------------------------------------------------------- /tty/grlib-uart/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS grlib-uart driver 3 | # 4 | # Copyright 2023 Phoenix Systems 5 | # 6 | 7 | NAME := grlib-uart 8 | LOCAL_SRCS := grlib-uart.c 9 | DEP_LIBS := libtty libklog 10 | include $(binary.mk) 11 | -------------------------------------------------------------------------------- /tty/spike-tty/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS riscv-htiftty driver 3 | # 4 | # Copyright 2020 Phoenix Systems 5 | # 6 | 7 | NAME := spike-tty 8 | LOCAL_SRCS := spike-tty.c 9 | DEP_LIBS := libtty libklog 10 | include $(binary.mk) 11 | -------------------------------------------------------------------------------- /_targets/Makefile.ia32-generic: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # ia32/QEMU drivers 5 | # 6 | # Copyright 2019 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := pc-tty uart16550 pc-ata libusbehci umass libusbdrv-umass 10 | -------------------------------------------------------------------------------- /dma/imxrt-edma/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imxrt-edma API 3 | # 4 | # Copyright 2020 Phoenix Systems 5 | # 6 | 7 | NAME := libimxrt-edma 8 | LOCAL_SRCS := imxrt-edma.c 9 | LOCAL_HEADERS := edma.h 10 | 11 | include $(static-lib.mk) 12 | -------------------------------------------------------------------------------- /multi/imxrt-multi/tests/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imxrt-multi 3 | # 4 | # Copyright 2019 Phoenix Systems 5 | # 6 | 7 | NAME := multi-tests 8 | LOCAL_SRCS := multi_tests.c spi_tests.c 9 | DEPS := imxrt-multi 10 | include $(binary.mk) 11 | -------------------------------------------------------------------------------- /spacewire/grspw2/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS spacewire 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | # %LICENSE% 7 | # 8 | 9 | NAME := grspw2 10 | LOCAL_SRCS := grspw2.c 11 | DEP_LIBS := libgrspw 12 | 13 | include $(binary.mk) 14 | -------------------------------------------------------------------------------- /tty/imx6ull-uart/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imx6ull-uart driver 3 | # 4 | # Copyright 2018, 2019 Phoenix Systems 5 | # 6 | 7 | NAME := imx6ull-uart 8 | LOCAL_SRCS := imx6ull-uart.c 9 | DEP_LIBS := libtty libklog 10 | include $(binary.mk) 11 | -------------------------------------------------------------------------------- /watchdog/imx6ull/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imx6ull-wdg driver 3 | # 4 | # Copyright 2021 Phoenix Systems 5 | # 6 | 7 | NAME := imx6ull-wdg 8 | LOCAL_SRCS := imx6ull-wdg.c 9 | LOCAL_HEADERS := watchdog.h 10 | 11 | include $(binary.mk) 12 | -------------------------------------------------------------------------------- /libpseudodev/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS pseudo devices library 3 | # 4 | # Copyright 2023 Phoenix Systems 5 | # 6 | 7 | NAME := libpseudodev 8 | LOCAL_SRCS := pseudodev.c 9 | LOCAL_HEADERS := pseudodev.h 10 | 11 | include $(static-lib.mk) 12 | -------------------------------------------------------------------------------- /spacewire/grspwrtr/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS spacewire 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | # %LICENSE% 7 | # 8 | 9 | NAME := grspwrtr 10 | LOCAL_HEADERS := grspwrtr.h 11 | LOCAL_SRCS := grspwrtr.c 12 | 13 | include $(binary.mk) 14 | -------------------------------------------------------------------------------- /gpio/imx6ull-gpio/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imx6ull-gpio driver 3 | # 4 | # Copyright 2018, 2019 Phoenix Systems 5 | # 6 | 7 | NAME := imx6ull-gpio 8 | LOCAL_SRCS := imx6ull-gpio.c 9 | LOCAL_HEADERS := imx6ull-gpio.h 10 | 11 | include $(binary.mk) 12 | -------------------------------------------------------------------------------- /spacewire/libgrspw/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS spacewire 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | # %LICENSE% 7 | # 8 | 9 | NAME := libgrspw 10 | LOCAL_HEADERS := libgrspw.h 11 | LOCAL_SRCS := libgrspw.c 12 | 13 | include $(static-lib.mk) 14 | -------------------------------------------------------------------------------- /storage/flashdrv/drv/grlib-ftmctrl/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS libftmctrl driver 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | NAME := libftmctrl 8 | LOCAL_SRCS := amd-flash.c flashdrv.c flash.c intel-flash.c 9 | 10 | include $(static-lib.mk) 11 | -------------------------------------------------------------------------------- /storage/virtio-blk/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS virtio-blk driver 3 | # 4 | # Copyright 2021 Phoenix Systems 5 | # 6 | 7 | NAME := virtio-blk 8 | LOCAL_SRCS := vblksrv.c vblk.c 9 | LIBS := libvirtio libmbr libext2 libstorage 10 | 11 | include $(binary.mk) 12 | -------------------------------------------------------------------------------- /tty/libtty/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS libtty 3 | # 4 | # Copyright 2018, 2019 Phoenix Systems 5 | # 6 | 7 | NAME := libtty 8 | LOCAL_SRCS := libtty.c libtty_disc.c 9 | LOCAL_HEADERS := libtty.h libtty-lf-fifo.h ttydefaults.h 10 | include $(static-lib.mk) 11 | -------------------------------------------------------------------------------- /tty/cmsdk-apbuart/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS cmsdk-apbuart driver 3 | # 4 | # Copyright 2024 Phoenix Systems 5 | # 6 | # %LICENSE% 7 | # 8 | 9 | NAME := cmsdk-apbuart 10 | LOCAL_SRCS := cmsdk-apbuart.c 11 | DEP_LIBS := libtty libklog 12 | include $(binary.mk) 13 | -------------------------------------------------------------------------------- /storage/host-flash/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for flash emulator 3 | # 4 | # Copyright 2021 Phoenix Systems 5 | # 6 | # %LICENSE% 7 | # 8 | 9 | NAME := host-flash 10 | LOCAL_SRCS := host-flash.c host-flashsrv.c 11 | LOCAL_HEADERS := host-flashsrv.h 12 | 13 | include $(static-lib.mk) 14 | -------------------------------------------------------------------------------- /sdio/common/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for sdio library 3 | # 4 | # Copyright 2022 Phoenix Systems 5 | # Author: Artur Miller 6 | # 7 | # This file is part of Phoenix-RTOS. 8 | # 9 | # %LICENSE% 10 | # 11 | 12 | NAME := sdio-common 13 | LOCAL_HEADERS := sdio.h 14 | include $(static-lib.mk) 15 | -------------------------------------------------------------------------------- /storage/flashdrv/drv/grlib-spimctrl/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS libspimctrl driver 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | NAME := libspimctrl 8 | LOCAL_SRCS := flash.c flashdrv.c spimctrl.c 9 | LOCAL_CFLAGS := -fvisibility=hidden 10 | 11 | include $(static-lib.mk) 12 | -------------------------------------------------------------------------------- /tty/pc-tty/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS pc-tty driver 3 | # 4 | # Copyright 2017, 2018, 2019 Phoenix Systems 5 | # Copyright 2001, 2005-2006 Pawel Pisarczyk 6 | 7 | 8 | NAME := pc-tty 9 | SRCS := $(wildcard tty/pc-tty/*.c) 10 | DEP_LIBS := libtty libklog 11 | include $(binary.mk) 12 | -------------------------------------------------------------------------------- /pcie/pcie-xilinx-axi/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | ifeq ($(PCI_EXPRESS_XILINX_AXI),y) 8 | NAME := pcie-xilinx-axi 9 | LOCAL_SRCS := pcie-xilinx-axi.c 10 | LOCAL_HEADERS := pcie-xilinx-axi.h 11 | include $(static-lib.mk) 12 | endif 13 | -------------------------------------------------------------------------------- /pcie/pcie-xilinx-nwl/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | ifeq ($(PCI_EXPRESS_XILINX_NWL),y) 8 | NAME := pcie-xilinx-nwl 9 | LOCAL_SRCS := pcie-xilinx-nwl.c 10 | LOCAL_HEADERS := pcie-xilinx-nwl.h 11 | include $(static-lib.mk) 12 | endif 13 | -------------------------------------------------------------------------------- /storage/zynq-flash/tests/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for zynq-flash tests 3 | # 4 | # Copyright 2022 Phoenix Systems 5 | # 6 | # %LICENSE% 7 | # 8 | 9 | NAME := test_flashdrv 10 | LOCAL_SRCS := flashdrv.c 11 | DEP_LIBS := libflashdrv-zynq 12 | LIBS := unity libstorage libcache 13 | 14 | include $(binary.mk) 15 | -------------------------------------------------------------------------------- /tty/usbacm/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS USB CDC ACM driver 3 | # 4 | # Copyright 2021, 2024 Phoenix Systems 5 | # 6 | 7 | NAME := libusbdrv-usbacm 8 | LOCAL_SRCS := usbacm.c 9 | include $(static-lib.mk) 10 | 11 | NAME := usbacm 12 | LOCAL_SRCS := usbacm.c srv.c 13 | LIBS := libusb 14 | include $(binary.mk) 15 | -------------------------------------------------------------------------------- /watchdog/imx6ull/watchdog.h: -------------------------------------------------------------------------------- 1 | #ifndef IMX6ULL_WATCHDOG 2 | #define IMX6ULL_WATCHDOG 3 | 4 | #include 5 | 6 | #define WATCHDOG_IOCTL_BASE 'W' 7 | #define WDIOC_KEEPALIVE _IO(WATCHDOG_IOCTL_BASE, 5) 8 | #define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int) 9 | 10 | #endif /* IMX6ULL_WATCHDOG */ 11 | -------------------------------------------------------------------------------- /storage/flashdrv/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS ftmctrl-flash driver 3 | # 4 | # Copyright 2023-2025 Phoenix Systems 5 | # 6 | 7 | NAME := flashdrv 8 | LOCAL_SRCS := common.c flashsrv.c 9 | DEP_LIBS := libftmctrl libspimctrl 10 | LIBS := libjffs2 libstorage libmtd libptable libcache 11 | 12 | include $(binary.mk) 13 | -------------------------------------------------------------------------------- /multi/imxrt-multi/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT common 5 | * 6 | * Copyright 2019 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | #include "common.h" 16 | 17 | 18 | unsigned int multi_port; 19 | -------------------------------------------------------------------------------- /dma/imx6ull-sdma/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imx6ull-sdma driver 3 | # 4 | # Copyright 2018 Phoenix Systems 5 | # 6 | 7 | NAME := libsdma 8 | LOCAL_SRCS := libsdma.c 9 | LOCAL_HEADERS := sdma.h sdma-api.h 10 | 11 | include $(static-lib.mk) 12 | 13 | NAME := imx6ull-sdma 14 | LOCAL_SRCS := imx6ull-sdma.c 15 | 16 | include $(binary.mk) 17 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | # vim:sw=2:ts=2 2 | name: lint 3 | 4 | # on events 5 | on: 6 | push: 7 | branches: 8 | - master 9 | - 'feature/*' 10 | pull_request: 11 | branches: 12 | - master 13 | - 'feature/*' 14 | 15 | jobs: 16 | call-lint: 17 | uses: phoenix-rtos/phoenix-rtos-project/.github/workflows/lint.yml@master 18 | -------------------------------------------------------------------------------- /multi/grlib-multi/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS grlib-multi 3 | # 4 | # Copyright 2023 Phoenix Systems 5 | # 6 | # %LICENSE% 7 | # 8 | 9 | NAME := grlib-multi 10 | LOCAL_SRCS := adc.c gpio.c spi.c uart.c grlib-multi.c 11 | LOCAL_HEADERS := grlib-multi.h 12 | DEP_LIBS := libtty libklog libpseudodev libgrdmac2 libgrspw 13 | 14 | include $(binary.mk) 15 | -------------------------------------------------------------------------------- /storage/pc-ata/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS pc-ata driver 3 | # 4 | # Copyright 2018, 2019 Phoenix Systems 5 | # 6 | NAME := libata 7 | LOCAL_SRCS := ata.c 8 | LOCAL_HEADERS: ata.h 9 | 10 | include $(static-lib.mk) 11 | 12 | NAME := pc-ata 13 | LOCAL_SRCS := atasrv.c mbr.c 14 | DEP_LIBS := libata 15 | LIBS := libext2 16 | 17 | include $(binary.mk) 18 | -------------------------------------------------------------------------------- /display/oled-128O064B0/fonts/font.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Font 5 | * 6 | * Copyright 2018 Phoenix Systems 7 | * Author: Andrzej Glowinski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include "font.h" 15 | 16 | extern font_data_t font_5x7_info; 17 | 18 | font_data_t *font_common[] = {&font_5x7_info}; 19 | -------------------------------------------------------------------------------- /multi/imxrt-multi/imxrt1050.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT1050 definitions 5 | * 6 | * Copyright 2019 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _IMXRT1050_H_ 16 | #define _IMXRT1050_H_ 17 | 18 | #include "imxrt1060.h" 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /i2c/common/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS i2c API 3 | # 4 | # Copyright 2021 Phoenix Systems 5 | # 6 | 7 | # i2c API 8 | NAME := i2c-common 9 | LOCAL_HEADERS := i2c.h i2c-msg.h 10 | include $(static-lib.mk) 11 | 12 | 13 | # i2c API message implementation 14 | NAME := libi2c-msg 15 | DEPS := i2c-common 16 | LOCAL_SRCS := libi2c-msg.c 17 | include $(static-lib.mk) 18 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # vim:sw=2:ts=2 2 | name: ci 3 | 4 | # on events 5 | on: 6 | push: 7 | branches: 8 | - master 9 | - 'feature/*' 10 | pull_request: 11 | branches: 12 | - master 13 | - 'feature/*' 14 | 15 | jobs: 16 | call-ci: 17 | uses: phoenix-rtos/phoenix-rtos-project/.github/workflows/ci-submodule.yml@master 18 | secrets: inherit 19 | -------------------------------------------------------------------------------- /sensors/psp/psp.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef _SENSORHUB_PSP_H_ 4 | #define _SENSORHUB_PSP_H_ 5 | 6 | #include 7 | #include 8 | 9 | 10 | void bsp_busDealloc(sensor_bus_t *bus); 11 | 12 | 13 | int psp_busAlloc(sensor_bus_t *bus, enum sensor_bus_type type); 14 | 15 | 16 | void psp_busDone(void); 17 | 18 | 19 | int psp_busInit(void); 20 | 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /usb/ehci/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS ehci 3 | # 4 | # Copyright 2018, 2019 Phoenix Systems 5 | # 6 | 7 | # FIXME: rename usb host component 8 | NAME := libusbehci 9 | LOCAL_SRCS := ehci.c ehci-hub.c phy-$(TARGET_FAMILY)-$(TARGET_SUBFAMILY).c 10 | 11 | ifneq (,$(findstring imx,$(TARGET_SUBFAMILY))) 12 | LOCAL_CFLAGS += -DEHCI_IMX 13 | endif 14 | 15 | include $(static-lib.mk) 16 | -------------------------------------------------------------------------------- /storage/gr716-flash/tests/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Phoenix-RTOS 3 | # 4 | # GR716 storage tests 5 | # 6 | # Copyright 2023 Phoenix Systems 7 | # Author: Lukasz Leczkowski 8 | # 9 | 10 | NAME := gr716-flash-tests 11 | LOCAL_SRCS := tests.c flashsrv_mfs_tests.c flashsrv_raw_tests.c 12 | DEPS := gr716-flash 13 | DEP_LIBS := libflashdrv-gr716 14 | LIBS := libptable libmeterfs 15 | 16 | include $(binary.mk) 17 | 18 | -------------------------------------------------------------------------------- /multi/mcxn94x-multi/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS mcxn94x-multi 3 | # 4 | # Copyright 2024 Phoenix Systems 5 | # 6 | 7 | NAME := mcxn94x-multi 8 | 9 | LOCAL_PATH := $(call my-dir) 10 | 11 | LOCAL_SRCS = mcxn94x-multi.c common.c cpu.c dev.c dummyfs.c pipe.c uart.c 12 | DEP_LIBS := libtty libklog libpseudodev 13 | LIBS := libdummyfs libklog libpseudodev libposixsrv 14 | 15 | include $(binary.mk) 16 | -------------------------------------------------------------------------------- /spi/zynq-spi/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS zynq-spi 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | # Zynq7000 / ZynqMP SPI library 8 | NAME := libzynq-spi 9 | LOCAL_SRCS := libzynq-spi.c 10 | DEPS := spi-common 11 | include $(static-lib.mk) 12 | 13 | # Zynq7000 / ZynqMP SPI server 14 | NAME := zynq-spi 15 | LOCAL_SRCS := zynq-spi.c 16 | DEP_LIBS := libzynq-spi 17 | include $(binary.mk) 18 | -------------------------------------------------------------------------------- /storage/imxrt-flash/tests/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Phoenix-RTOS 3 | # 4 | # i.MX RT storage tests 5 | # 6 | # Copyright 2020 Phoenix Systems 7 | # Author: Hubert Buczynski 8 | # 9 | 10 | NAME := flash-tests 11 | LOCAL_SRCS := tests.c flashsrv_mfs_tests.c flashsrv_raw_tests.c flashdrv_tests.c 12 | DEPS := imxrt-flash 13 | DEP_LIBS := libflashdrv-imxrt 14 | LIBS := libptable libmeterfs 15 | 16 | include $(binary.mk) 17 | 18 | -------------------------------------------------------------------------------- /_targets/Makefile.aarch64a53-zynqmp: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # ZynqMP drivers 5 | # 6 | # Copyright 2024 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := zynq-uart zynq-flash zynqmp-can zynq-pwm uart16550 10 | DEFAULT_COMPONENTS += zynq-i2c zynq-spi 11 | DEFAULT_COMPONENTS += librcpwm 12 | DEFAULT_COMPONENTS += libsensorsclient libsensors sensors 13 | DEFAULT_COMPONENTS += pcie 14 | -------------------------------------------------------------------------------- /multi/imxrt-multi/cm4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT117x M4 cpu core driver 5 | * 6 | * Copyright 2021, 2023 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | #ifndef IMXRT117X_CM4_H 13 | #define IMXRT117X_CM4_H 14 | 15 | 16 | #include 17 | 18 | 19 | void cm4_handleMsg(msg_t *msg); 20 | 21 | 22 | void cm4_init(void); 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/adc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 ADC driver 5 | * 6 | * Copyright 2020 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef ADC_H_ 15 | #define ADC_H_ 16 | 17 | 18 | unsigned short adc_conversion(int adc, char chan); 19 | 20 | 21 | int adc_init(void); 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /temp/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS simple sensor devices 3 | # 4 | # Copyright 2021 Phoenix Systems 5 | # 6 | # 7 | 8 | # by default use i2c message implementation (can be overridden to use custom target i2c lib directly, eg. `make I2C_LIB=libimx6ull-i2c temp-nct75`) 9 | I2C_LIB ?= libi2c-msg 10 | 11 | NAME := temp-nct75 12 | LOCAL_SRCS := temp-nct75.c 13 | DEP_LIBS := $(I2C_LIB) 14 | include $(binary.mk) 15 | -------------------------------------------------------------------------------- /mag/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS simple sensor devices 3 | # 4 | # Copyright 2023 Phoenix Systems 5 | # 6 | # 7 | 8 | # by default use i2c message implementation (can be overridden to use custom target i2c lib directly, eg. `make I2C_LIB=libimx6ull-i2c mag-als31300`) 9 | I2C_LIB ?= libi2c-msg 10 | 11 | NAME := mag-als31300 12 | LOCAL_SRCS := mag-als31300.c 13 | DEP_LIBS := $(I2C_LIB) 14 | include $(binary.mk) 15 | -------------------------------------------------------------------------------- /multi/mcxn94x-multi/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * MCX N94x UART driver 5 | * 6 | * Copyright 2017-2019, 2024 Phoenix Systems 7 | * Author: Kamil Amanowicz, Marek Bialowas, Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef MCXN94X_UART_H_ 15 | #define MCXN94X_UART_H_ 16 | 17 | 18 | int uart_ttyInit(int ttyno); 19 | 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /multi/imxrt-multi/cm4/example/blinky.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | export TARGET=armv7m4-imxrt117x 6 | export PREFIX_BUILD=../../../../../_build/${TARGET} 7 | 8 | make -C ../lib -f Makefile.ext clean all 9 | make -C ../example -f Makefile.ext clean all 10 | 11 | pushd ${PREFIX_BUILD}/prog.stripped/ 12 | 13 | xxd -ps -c1 blinky.bin | awk '{printf("0x%s,",$0);if (NR % 16 == 0) printf("\n")}' > blinky.hex 14 | 15 | popd 16 | -------------------------------------------------------------------------------- /multi/imxrt-multi/trng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT TRNG driver 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Maciej Purski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _TRNG_H_ 16 | #define _TRNG_H_ 17 | 18 | #include 19 | 20 | int trng_handleMsg(msg_t *msg); 21 | 22 | 23 | int trng_init(void); 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /gpio/zynq7000-gpio/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS zynq7000-gpio driver 3 | # 4 | # Copyright 2022 Phoenix Systems 5 | # 6 | 7 | # zynq7000 GPIO message API 8 | NAME := libzynq7000-gpio-msg 9 | LOCAL_HEADERS := zynq7000-gpio-msg.h 10 | LOCAL_SRCS := libzynq7000-gpio-msg.c 11 | include $(static-lib.mk) 12 | 13 | # zynq7000 GPIO server 14 | NAME := zynq7000-gpio 15 | LOCAL_SRCS := gpio.c gpiosrv.c 16 | include $(binary.mk) 17 | -------------------------------------------------------------------------------- /spi/zynq7000-xspi/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS zynq7000-xspi 3 | # 4 | # Copyright 2022 Phoenix Systems 5 | # 6 | 7 | # zynq7000 AXI SPI library 8 | NAME := libzynq7000-xspi 9 | LOCAL_SRCS := libzynq7000-xspi.c 10 | DEPS := spi-common 11 | include $(static-lib.mk) 12 | 13 | # zynq7000 AXI SPI server 14 | NAME := zynq7000-xspi 15 | LOCAL_SRCS := zynq7000-xspi.c 16 | DEP_LIBS := libzynq7000-xspi 17 | include $(binary.mk) 18 | -------------------------------------------------------------------------------- /i2c/zynq/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS zynq-i2c driver 3 | # 4 | # Copyright 2022 Phoenix Systems 5 | # 6 | 7 | NAME := libzynq-i2c 8 | LOCAL_SRCS := libzynq-i2c.c 9 | DEPS := i2c-common 10 | # no install headers as we're implementing generic interface only 11 | include $(static-lib.mk) 12 | 13 | 14 | NAME := zynq-i2c 15 | LOCAL_SRCS := zynq-i2c.c 16 | DEP_LIBS := libzynq-i2c 17 | DEPS := i2c-common 18 | include $(binary.mk) 19 | -------------------------------------------------------------------------------- /multi/imxrt-multi/spi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT SPI driver 5 | * 6 | * Copyright 2019 Phoenix Systems 7 | * Author: Hubert Buczynski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _SPI_H_ 16 | #define _SPI_H_ 17 | 18 | #include 19 | 20 | 21 | int spi_handleMsg(msg_t *msg, int dev); 22 | 23 | 24 | int spi_init(void); 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /storage/gr716-flash/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS gr716-flash driver 3 | # 4 | # Copyright 2023 Phoenix Systems 5 | # 6 | 7 | NAME := libflashdrv-gr716 8 | LOCAL_SRCS := flashdrv.c spimctrl.c nor/nor.c 9 | 10 | include $(static-lib.mk) 11 | 12 | NAME := gr716-flash 13 | LOCAL_SRCS := flashsrv.c 14 | LOCAL_HEADERS := gr716-flashsrv.h 15 | DEP_LIBS := libflashdrv-gr716 16 | LIBS := libmeterfs libptable libtinyaes 17 | 18 | include $(binary.mk) 19 | -------------------------------------------------------------------------------- /i2c/imx6ull/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imx6ull-i2c driver 3 | # 4 | # Copyright 2021 Phoenix Systems 5 | # 6 | 7 | NAME := libimx6ull-i2c 8 | LOCAL_SRCS := libimx6ull-i2c.c 9 | DEPS := i2c-common 10 | # no install headers as we're implementing generic interface only 11 | include $(static-lib.mk) 12 | 13 | 14 | NAME := imx6ull-i2c 15 | LOCAL_SRCS := imx6ull-i2c.c 16 | DEP_LIBS := libimx6ull-i2c 17 | DEPS := i2c-common 18 | include $(binary.mk) 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # phoenix-rtos-devices 2 | This repository contains device drivers for Phoenix-RTOS. Device drivers work on the user-level and use message passing for interfacing with other operating system components. 3 | 4 | To learn the device driver architecuture and the method how to implement it please refer to the [Phoenix-RTOS Documentation](https://github.com/phoenix-rtos/phoenix-rtos-doc/). 5 | 6 | This work is licensed under a BSD license. See the LICENSE file for details. 7 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/rng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 RNG driver 5 | * 6 | * Copyright 2024 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef MULTI_RNG_H_ 15 | #define MULTI_RNG_H_ 16 | 17 | #include 18 | #include 19 | 20 | ssize_t rng_read(uint8_t *val, size_t len); 21 | 22 | 23 | int rng_init(void); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /spi/common/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS SPI API 3 | # 4 | # Copyright 2022 Phoenix Systems 5 | # 6 | 7 | # SPI API 8 | NAME := spi-common 9 | LOCAL_HEADERS := spi.h spi-msg.h 10 | include $(static-lib.mk) 11 | 12 | # SPI message API 13 | ifneq ($(findstring stm32,$(TARGET_SUBFAMILY)),) 14 | LOCAL_SRCS := libspi-msg-stm32.c 15 | else 16 | LOCAL_SRCS := libspi-msg.c 17 | endif 18 | 19 | NAME := libspi-msg 20 | DEPS := spi-common 21 | include $(static-lib.mk) 22 | -------------------------------------------------------------------------------- /storage/imxrt-flash/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Phoenix-RTOS 3 | # 4 | # flash driver 5 | # 6 | # Copyright 2019 Phoenix Systems 7 | # Author: Hubert Buczynski 8 | # 9 | 10 | NAME := libflashdrv-imxrt 11 | LOCAL_SRCS := flashdrv.c fspi.c nor.c 12 | 13 | include $(static-lib.mk) 14 | 15 | NAME := imxrt-flash 16 | LOCAL_SRCS := flashsrv.c 17 | LOCAL_HEADERS := imxrt-flashsrv.h 18 | DEP_LIBS := libflashdrv-imxrt 19 | LIBS := libmeterfs libptable libtinyaes 20 | 21 | include $(binary.mk) 22 | -------------------------------------------------------------------------------- /multi/imxrt-multi/pct2075.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT integrated PCT2075 driver 5 | * 6 | * Copyright 2024 Phoenix Systems 7 | * Author: Jacek Maksymowicz 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _PCT2075_H_ 15 | #define _PCT2075_H_ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | void pct2075_handleMsg(msg_t *msg); 23 | 24 | 25 | #endif /* _PCT2075_H_ */ 26 | -------------------------------------------------------------------------------- /spi/zynq7000-xspi/libzynq7000-xspi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Zynq-7000 AXI SPI controller (master mode only) 5 | * 6 | * Copyright 2022 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef LIBZYNQ7000_XSPI_H_ 15 | #define LIBZYNQ7000_XSPI_H_ 16 | 17 | #ifndef SPI_SS_COUNT 18 | #define SPI_SS_COUNT 4 /* Max number of SPI slaves per controller */ 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /storage/imx6ull-flashnor/imx6ull-flashnor-qspi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX 6ULL QSPI NOR flash driver 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Hubert Badocha 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _FLASHNOR_QSPI_H_ 15 | #define _FLASHNOR_QSPI_H_ 16 | 17 | #include "imx6ull-flashnor-drv.h" 18 | 19 | 20 | extern int flashnor_qspiInit(int ndev, flashnor_info_t *info); 21 | 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /_targets/Makefile.armv7a9-zynq7000: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # zynq7000 drivers 5 | # 6 | # Copyright 2021 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := zynq-uart uart16550 zynq-pwm zynq7000-xgpio zynq-spi zynq7000-xspi zynq7000-gpio 10 | DEFAULT_COMPONENTS += libflashdrv-zynq zynq-flash test_flashdrv libspi-msg libzynq7000-gpio-msg librcpwm 11 | DEFAULT_COMPONENTS += libsensors sensors libsensorsclient 12 | DEFAULT_COMPONENTS += zynq-i2c zynq7000-sdcard 13 | -------------------------------------------------------------------------------- /gpio/imx6ull-gpio/imx6ull-gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX 6ULL GPIO driver 5 | * 6 | * Copyright 2018 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _GPIODRV_H_ 15 | #define _GPIODRV_H_ 16 | 17 | typedef union { 18 | unsigned int val; 19 | struct { 20 | unsigned int val; 21 | unsigned int mask; 22 | } __attribute__((packed)) w; 23 | } gpiodata_t; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /rtc/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS rtc drivers 3 | # 4 | # Copyright 2021 Phoenix Systems 5 | # 6 | 7 | # common RTC API 8 | NAME := rtc-common 9 | LOCAL_HEADERS := rtc.h 10 | include $(static-lib.mk) 11 | 12 | 13 | # by default use i2c message implementation (can be overridden to use custom target i2c lib directly) 14 | I2C_LIB ?= libi2c-msg 15 | 16 | NAME := rtc-pcf85363a 17 | LOCAL_SRCS := pcf85363a.c 18 | DEPS := rtc-common 19 | DEP_LIBS := $(I2C_LIB) 20 | include $(binary.mk) 21 | -------------------------------------------------------------------------------- /multi/grlib-multi/adc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB ADC driver 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _MULTI_ADC_H_ 15 | #define _MULTI_ADC_H_ 16 | 17 | 18 | #include 19 | 20 | 21 | void adc_handleMsg(msg_t *msg, int dev); 22 | 23 | 24 | int adc_createDevs(oid_t *oid); 25 | 26 | 27 | int adc_init(void); 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /multi/grlib-multi/spi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB SPI driver 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _MULTI_SPI_H_ 15 | #define _MULTI_SPI_H_ 16 | 17 | 18 | #include 19 | 20 | 21 | void spi_handleMsg(msg_t *msg, int dev); 22 | 23 | 24 | int spi_createDevs(oid_t *oid); 25 | 26 | 27 | int spi_init(void); 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /adc/ade7913/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for ade7913 3 | # 4 | # Copyright 2021 Phoenix Systems 5 | # Author: Marcin Baran 6 | # 7 | # %LICENSE% 8 | # 9 | 10 | NAME := ade7913-test 11 | LOCAL_SRCS := gpio.c ade7913.c ade7913-test.c 12 | DEPS := imxrt-multi 13 | 14 | include $(binary.mk) 15 | 16 | NAME := ade7913-driver 17 | LOCAL_SRCS := gpio.c ade7913.c ade7913-driver.c flexpwm.c 18 | LOCAL_HEADERS := adc-api-ade7913.h 19 | DEPS := imxrt-multi 20 | DEP_LIBS := libimxrt-edma 21 | 22 | include $(binary.mk) 23 | -------------------------------------------------------------------------------- /adc/ade7913/gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Helper gpio functions 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Marcin Baran 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | #ifndef GPIO_H 18 | #define GPIO_H 19 | 20 | void gpio_setPin(oid_t *device, int gpio, int pin, int state); 21 | void gpio_setDir(oid_t *device, int gpio, int pin, int dir); 22 | 23 | #endif // GPIO_H 24 | -------------------------------------------------------------------------------- /multi/imxrt-multi/cm4/lib/string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT117x Cortex-M4 basic string funtions 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef M4STRING_H_ 15 | #define M4STRING_H_ 16 | 17 | #include 18 | 19 | void *memcpy(void *dst, void *src, size_t len); 20 | 21 | 22 | void *memset(void *dst, int val, size_t len); 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/libmulti/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS stm32-multi 3 | # 4 | # Copyright 2022 Phoenix Systems 5 | # 6 | 7 | LOCAL_PATH := $(call my-dir) 8 | 9 | NAME := libstm32l4-multi 10 | 11 | LOCAL_SRCS = libhash.c libi2c.c libuart.c 12 | ifeq ($(TARGET_SUBFAMILY),stm32l4x6) 13 | LOCAL_SRCS += libaes.c libdma.c libspi_l4.c 14 | else ifeq ($(TARGET_SUBFAMILY),stm32n6) 15 | LOCAL_SRCS += libgpdma.c libspi_n6.c 16 | endif 17 | 18 | DEPS := libtty 19 | 20 | include $(static-lib.mk) 21 | -------------------------------------------------------------------------------- /pcie/pcie-xilinx-nwl/pcie-xilinx-nwl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * PCI Express Xilinx NWL driver 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Dariusz Sabala 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | #ifndef PCIE_XILINX_NWL_H 13 | #define PCIE_XILINX_NWL_H 14 | 15 | /** 16 | * Initialise PCI Express Xilinx NWL driver 17 | * 18 | * Return values: 19 | * - 0: Operation succeed 20 | * - others values: Operation failed 21 | */ 22 | int pcie_xilinx_nwl_init(void); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /multi/grlib-multi/gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB GPIO driver 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _MULTI_GPIO_H_ 16 | #define _MULTI_GPIO_H_ 17 | 18 | 19 | #include 20 | 21 | 22 | void gpio_handleMsg(msg_t *msg, int dev); 23 | 24 | 25 | int gpio_createDevs(oid_t *oid); 26 | 27 | 28 | int gpio_init(void); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /storage/zynq-flash/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Phoenix-RTOS 3 | # 4 | # nor flash driver 5 | # 6 | # Copyright 2021 Phoenix Systems 7 | # Author: Hubert Buczynski, Malgorzata Wrobel 8 | # 9 | 10 | NAME := libflashdrv-zynq 11 | LOCAL_SRCS := qspi.c flashcfg.c flashdrv.c 12 | LOCAL_HEADERS := flashdrv.h flashcfg.h 13 | 14 | include $(static-lib.mk) 15 | 16 | NAME := zynq-flash 17 | LOCAL_SRCS := zynq-flash.c 18 | DEP_LIBS := libflashdrv-zynq 19 | LIBS := libstorage libjffs2 libmtd libcache 20 | 21 | include $(binary.mk) 22 | -------------------------------------------------------------------------------- /storage/zynq7000-sdcard/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Phoenix-RTOS 3 | # 4 | # SD card driver 5 | # 6 | # Copyright 2023 Phoenix Systems 7 | # Author: Jacek Maksymowicz 8 | # 9 | 10 | NAME := libsdcard-zynq 11 | LOCAL_SRCS := sdcard.c zynq7000-sdio.c 12 | LOCAL_HEADERS := sdcard.h 13 | 14 | include $(static-lib.mk) 15 | 16 | NAME := zynq7000-sdcard 17 | LOCAL_SRCS := sdstorage_dev.c sdstorage_srv.c 18 | DEP_LIBS := libsdcard-zynq 19 | LIBS := libstorage libcache libmbr libmtd libjffs2 libext2 20 | 21 | include $(binary.mk) 22 | -------------------------------------------------------------------------------- /storage/umass/umass.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * USB Mass Storage class driver 5 | * 6 | * Common header 7 | * 8 | * Copyright 2024 Phoenix Systems 9 | * Author: Adam Greloch 10 | * 11 | * This file is part of Phoenix-RTOS. 12 | * 13 | * %LICENSE% 14 | */ 15 | 16 | #ifndef _UMASS_H_ 17 | #define _UMASS_H_ 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | 25 | typedef struct { 26 | bool mount_root; 27 | } umass_args_t; 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /pcie/pcie-xilinx-axi/pcie-xilinx-axi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * PCI Express Xilinx AXI bridge driver 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Dariusz Sabala 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | #ifndef PCIE_XILINX_AXI_H 13 | #define PCIE_XILINX_AXI_H 14 | 15 | /** 16 | * Initialise PCI Express Xilinx PCIE AXI driver 17 | * 18 | * Return values: 19 | * - 0: Operation succeed 20 | * - others values: Operation failed 21 | */ 22 | int pcie_xilinx_axi_init(void); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /display/oled-128O064B0/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for BeSmart oled driver 3 | # 4 | # Copyright 2020 Phoenix Systems 5 | # Author: Hubert Buczynski, Marcin Baran 6 | # 7 | 8 | OLED_CORE := oled-phy.c 9 | OLED_GRAPHIC := oled-graphic.c fonts/font.c fonts/5x7.c 10 | 11 | NAME := oled-128O064B0 12 | LOCAL_SRCS := oled-dev.c $(OLED_GRAPHIC) $(OLED_CORE) 13 | LOCAL_HEADERS := oled-api.h 14 | DEPS := imxrt-multi 15 | include $(binary.mk) 16 | 17 | NAME := oled-test 18 | LOCAL_SRCS := oled-test.c $(OLED_CORE) 19 | include $(binary.mk) 20 | -------------------------------------------------------------------------------- /multi/imxrt-multi/cm4/lib/interrupt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT117x Cortex-M4 interrupt dispatcher 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef M4_INTERRUPT_H_ 15 | #define M4_INTERRUPT_H_ 16 | 17 | #define SIZE_INTERRUPTS 217 18 | 19 | #ifndef __ASSEMBLY__ 20 | 21 | int interrupt_register(int which, void (*callback)(int n), int priority); 22 | 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /multi/imxrt-multi/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * iMX RT UART driver 5 | * 6 | * Copyright 2019 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _UART_H_ 15 | #define _UART_H_ 16 | 17 | #include 18 | #include 19 | 20 | 21 | int uart_handleMsg(msg_t *msg, int dev); 22 | 23 | 24 | void uart_klogCblk(const char *data, size_t size); 25 | 26 | 27 | int uart_init(void); 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /storage/umass/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS USB Mass Storage driver 3 | # 4 | # Copyright 2020, 2024 Phoenix Systems 5 | # 6 | 7 | ifeq ($(TARGET_FAMILY),ia32) 8 | UMASS_LIBS := libext2 9 | UMASS_CFLAGS := -DUMASS_MOUNT_EXT2 10 | endif 11 | 12 | NAME := libusbdrv-umass 13 | LOCAL_SRCS := umass.c 14 | LOCAL_CFLAGS += $(UMASS_CFLAGS) 15 | include $(static-lib.mk) 16 | 17 | NAME := umass 18 | LOCAL_SRCS := umass.c srv.c 19 | LIBS := libusb $(UMASS_LIBS) 20 | LOCAL_CFLAGS += $(UMASS_CFLAGS) 21 | include $(binary.mk) 22 | -------------------------------------------------------------------------------- /libpseudodev/pseudodev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * pseudo devices 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Gerard Swiderski 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | #ifndef PSEUDO_H 13 | #define PSEUDO_H 14 | 15 | 16 | /* clang-format off */ 17 | 18 | enum { pseudo_idNull = 0, pseudo_idZero, pseudo_idFull, pseudo_idRandom }; 19 | 20 | /* clang-format on */ 21 | 22 | 23 | int pseudo_handleMsg(msg_t *msg, int id); 24 | 25 | 26 | void pseudo_init(void); 27 | 28 | 29 | #endif /* end of PSEUDO_H */ 30 | -------------------------------------------------------------------------------- /display/oled-128O064B0/fonts/font.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Font header 5 | * 6 | * Copyright 2018 Phoenix Systems 7 | * Author: Andrzej Glowinski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _FONT_H_ 15 | #define _FONT_H_ 16 | 17 | enum {font_5x7}; 18 | 19 | typedef struct font_data_s { 20 | int char_width; 21 | int char_height; 22 | int char_num; 23 | char first_char; 24 | void* data; 25 | } font_data_t; 26 | 27 | extern font_data_t *font_common[]; 28 | #endif 29 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/tty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 TTY driver 5 | * 6 | * Copyright 2017, 2018 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef UART_H_ 15 | #define UART_H_ 16 | 17 | #include 18 | #include /* FIXME - should be types.h */ 19 | 20 | ssize_t tty_log(const char *str, size_t len); 21 | 22 | 23 | void tty_createDev(void); 24 | 25 | 26 | int tty_init(void); 27 | 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /storage/imx6ull-flashnor/imx6ull-flashnor-ecspi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX 6ULL ECSPI NOR flash driver 5 | * 6 | * Copyright 2021, 2023 Phoenix Systems 7 | * Author: Lukasz Kosinski, Hubert Badocha 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _FLASHNOR_ECSPI_H_ 15 | #define _FLASHNOR_ECSPI_H_ 16 | 17 | #include 18 | 19 | #include "imx6ull-flashnor-drv.h" 20 | 21 | 22 | extern int flashnor_ecspiInit(int ndev, flashnor_info_t *info); 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /multi/mcxn94x-multi/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * MCX N94x M33 Mailbox core driver 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Daniel Sawka 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | #ifndef MCXN94X_CPU_H_ 13 | #define MCXN94X_CPU_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | ssize_t cpu_fifoWrite(const unsigned char *buf, size_t len, bool blocking, uint8_t ctl); 22 | 23 | 24 | int cpu_waitForEvent(uint32_t timeoutUs); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/exti.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 external interrupts driver 5 | * 6 | * Copyright 2019 Phoenix Systems 7 | * Author: Daniel Sawka 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | #ifndef EXTI_H_ 13 | #define EXTI_H_ 14 | 15 | #include 16 | 17 | 18 | int exti_configure(unsigned int line, unsigned char mode, unsigned char edge); 19 | 20 | 21 | int syscfg_mapexti(unsigned int line, int port); 22 | 23 | 24 | int exti_clear_irq(unsigned int line); 25 | 26 | 27 | int exti_init(void); 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /pcie/tebf0808/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | # TEBF0808 evaluation board specific initialisation code for PCI Express interface 8 | ifeq ($(PCI_EXPRESS_INIT_TEBF0808_PHY),y) 9 | NAME := tebf0808-pcie-refclk 10 | LOCAL_SRCS := tebf0808-pcie-refclk.c 11 | LOCAL_HEADERS := tebf0808-pcie-refclk.h 12 | include $(static-lib.mk) 13 | 14 | NAME := tebf0808-ps-gtr-phy 15 | LOCAL_SRCS := tebf0808-ps-gtr-phy.c 16 | LOCAL_HEADERS := tebf0808-ps-gtr-phy.h 17 | include $(static-lib.mk) 18 | endif 19 | -------------------------------------------------------------------------------- /pcie/tebf0808/tebf0808-pcie-refclk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * TEBF0808 evaluation board PCI Express reference clock initialisation 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Dariusz Sabala 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | #ifndef TEBF0808_PCIE_REFCLK_H 13 | #define TEBF0808_PCIE_REFCLK_H 14 | 15 | /** 16 | * Initialise PCI Express reference clock on TEBF0808 board 17 | * 18 | * Return values: 19 | * - 0: Operation succeed 20 | * - others values: Operation failed 21 | */ 22 | int tebf0808_pcieRefClkInit(void); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /multi/grlib-multi/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB UART driver 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _MULTI_UART_H_ 15 | #define _MULTI_UART_H_ 16 | 17 | 18 | #include 19 | 20 | 21 | void uart_handleMsg(msg_t *msg, int dev); 22 | 23 | 24 | void uart_klogClbk(const char *data, size_t size); 25 | 26 | 27 | int uart_createDevs(oid_t *oid); 28 | 29 | 30 | int uart_init(void); 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /multi/imxrt-multi/rtt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * iMX RT RTT communication driver 5 | * 6 | * Copyright 2024 Phoenix Systems 7 | * Author: Jacek Maksymowicz 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _RTT_H_ 15 | #define _RTT_H_ 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | 23 | int rtt_init(void); 24 | 25 | 26 | int rtt_handleMsg(msg_t *msg, int dev); 27 | 28 | 29 | void rtt_klogCblk(const char *data, size_t size); 30 | 31 | 32 | #endif /* _RTT_H_ */ 33 | -------------------------------------------------------------------------------- /multi/imxrt-multi/cm4/lib/mu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT117x Messaging Unit driver 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef MU_H_ 15 | #define MU_H_ 16 | 17 | #include 18 | #include 19 | 20 | #define CHANNEL_NO 4 21 | 22 | 23 | int mu_read(int channel, void *buff, int len); 24 | 25 | 26 | int mu_write(int channel, const void *buff, int len); 27 | 28 | 29 | void mu_init(void); 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /storage/pc-ata/mbr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Master Boot Record 5 | * 6 | * Copyright 2017, 2020 Phoenix Systems 7 | * Author: Kamil Amanowicz, Lukasz Kosinski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | 16 | #include "mbr.h" 17 | 18 | 19 | int mbr_read(ata_dev_t *dev, mbr_t *mbr) 20 | { 21 | ssize_t ret; 22 | 23 | if ((ret = ata_read(dev, 0, (char *)mbr, sizeof(mbr_t))) != sizeof(mbr_t)) 24 | return -EIO; 25 | 26 | if (mbr->magic != MBR_MAGIC) 27 | return -ENOENT; 28 | 29 | return EOK; 30 | } 31 | -------------------------------------------------------------------------------- /storage/flashdrv/include/flashdrv/flash_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Flash driver interface 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _FLASHDRV_FLASH_INTERFACE_H_ 15 | #define _FLASHDRV_FLASH_INTERFACE_H_ 16 | 17 | 18 | #include 19 | 20 | 21 | struct flash_driver { 22 | const char *name; 23 | storage_t *(*init)(addr_t mctrlBase, addr_t flashBase); 24 | void (*destroy)(storage_t *strg); 25 | }; 26 | 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /storage/flashdrv/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB FTMCTRL Flash driver 5 | * 6 | * Common auxiliary functions 7 | * 8 | * Copyright 2025 Phoenix Systems 9 | * Author: Lukasz Leczkowski 10 | * 11 | * This file is part of Phoenix-RTOS. 12 | * 13 | * %LICENSE% 14 | */ 15 | 16 | #include 17 | 18 | 19 | off_t common_getSectorOffset(size_t sectorsz, off_t offs) 20 | { 21 | return offs & ~(sectorsz - 1); 22 | } 23 | 24 | 25 | bool common_isValidAddress(size_t memsz, off_t offs, size_t len) 26 | { 27 | return ((offs < memsz) && ((offs + len) <= memsz)); 28 | } 29 | -------------------------------------------------------------------------------- /gpio/rcpwm/include/rcpwm/api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Remote control PWM driver binary interface 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef RCPWM_MSG_H 15 | #define RCPWM_MSG_H 16 | 17 | #include 18 | #include 19 | 20 | 21 | #define RCPWM_CHANNELS 8 22 | 23 | 24 | int rcpwm_set(oid_t *oid, uint32_t compval[RCPWM_CHANNELS], uint8_t mask); 25 | 26 | 27 | int rcpwm_get(oid_t *oid, uint32_t compval[RCPWM_CHANNELS]); 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 GPIO driver 5 | * 6 | * Copyright 2017, 2018 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef GPIO_H_ 15 | #define GPIO_H_ 16 | 17 | 18 | int gpio_setPort(int port, unsigned int mask, unsigned int val); 19 | 20 | 21 | int gpio_getPort(int port, unsigned int *val); 22 | 23 | 24 | int gpio_configPin(int port, char pin, char mode, char af, char otype, char ospeed, char pupd); 25 | 26 | 27 | int gpio_init(void); 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /tty/imx6ull-uart/README.md: -------------------------------------------------------------------------------- 1 | # imx6ull-uart 2 | 3 | 4 | This server provides TTY functionality for i.MX 6ULL SoC's UARTS. 5 | 6 | Usage: 7 | 8 | imx6ull-uart [mode] [device] [speed] [parity] [use_rts_cts] 9 | 10 | No args for default settings (cooked, uart1, B115200, 8N1). 11 | 12 | - mode: 0 - raw, 1 - cooked 13 | - device: 1 to 8 14 | - speed: baud_rate 15 | - parity: 0 - none, 1 - odd, 2 - even 16 | - use_rts_cts: 0 - no hardware flow control, 1 - use hardware flow control 17 | 18 | Server creates special file in the /dev directory - /dev/uartx, where x is number of an UART device. 19 | -------------------------------------------------------------------------------- /tty/pc-tty/ttypc_fbcon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * VGA framebuffer console 5 | * 6 | * Copyright 2024 Phoenix Systems 7 | * Author: Adam Greloch 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _TTYPC_FBCON_H_ 15 | #define _TTYPC_FBCON_H_ 16 | 17 | #include 18 | 19 | #include "ttypc.h" 20 | 21 | 22 | extern void _ttypc_fbcon_drawChar(ttypc_vt_t *vt, uint16_t col, uint16_t row, uint16_t val); 23 | 24 | 25 | extern int ttypc_fbcon_init(ttypc_t *ttypc); 26 | 27 | 28 | extern int ttypc_fbcon_destroy(ttypc_t *ttypc); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /can/zynqmp-can/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS Zynq7000-uart driver 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | # ZynqMP CAN driver interface library 8 | NAME := libzynqmp-can-if 9 | LOCAL_SRCS := zynqmp-can-if.c 10 | LOCAL_HEADERS := zynqmp-can-if.h 11 | include $(static-lib.mk) 12 | 13 | # ZynqMP CAN driver server 14 | NAME := zynqmp-can 15 | LOCAL_SRCS := zynqmp-can.c 16 | DEP_LIBS := libzynqmp-can-if 17 | include $(binary.mk) 18 | 19 | # ZynqMP CAN manual test application 20 | NAME := zynqmp-can-test 21 | LOCAL_SRCS := zynqmp-can-test.c 22 | DEP_LIBS := libzynqmp-can-if 23 | include $(binary.mk) 24 | -------------------------------------------------------------------------------- /i2c/common/i2c-msg.h: -------------------------------------------------------------------------------- 1 | /* i2c internal message API, to be used only by the implementers */ 2 | #ifndef _PHOENIX_I2C_MSG_H 3 | #define _PHOENIX_I2C_MSG_H 4 | 5 | #include 6 | 7 | enum { 8 | i2c_devctl_bus_write, /* input params: dev_addr, *data, len */ 9 | i2c_devctl_bus_read, /* input params: dev_addr, *data, len */ 10 | i2c_devctl_reg_read /* input params: dev_addr, reg_addr, *data, len */ 11 | }; 12 | 13 | typedef struct { 14 | struct { 15 | unsigned int type; 16 | uint8_t dev_addr; 17 | uint8_t reg_addr; 18 | } i; 19 | } __attribute__((packed)) i2c_devctl_t; 20 | 21 | #endif /* _PHOENIX_I2C_MSG_H */ 22 | -------------------------------------------------------------------------------- /storage/flashdrv/include/flashdrv/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB FTMCTRL Flash driver 5 | * 6 | * Common auxiliary functions 7 | * 8 | * Copyright 2025 Phoenix Systems 9 | * Author: Lukasz Leczkowski 10 | * 11 | * This file is part of Phoenix-RTOS. 12 | * 13 | * %LICENSE% 14 | */ 15 | 16 | #ifndef _FLASHDRV_COMMON_H_ 17 | #define _FLASHDRV_COMMON_H_ 18 | 19 | 20 | #include 21 | #include 22 | 23 | 24 | off_t common_getSectorOffset(size_t sectorsz, off_t offs); 25 | 26 | 27 | bool common_isValidAddress(size_t memsz, off_t offs, size_t len); 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /otp/imxrt117x-otp/README.md: -------------------------------------------------------------------------------- 1 | This tool blows OTP fuses of iMX RT117x MCU. 2 | 3 | Usage from psh: 4 | 5 | sysexec [map] imxrt117x-otp [-r | -w value] -f fuse 6 | 7 | Where: 8 | 9 | map - memory map for data (created by plo, dtcm or ocram2 for example) 10 | -r - read fuse value 11 | -w - write value to fuse 12 | -f - select fuse from fusemap (0x800 to 0x18F0) 13 | 14 | Example - burning of BT_FUSE_SEL fuse: 15 | 16 | sysexec dtcm imxrt117x-otp -f 0x960 - w 0x10 17 | 18 | to verify that the fuse has been burned successfuly: 19 | 20 | sysexec dtcm imxrt117x-otp -f 0x960 -r 21 | 22 | You should get the value 0x00000010. 23 | -------------------------------------------------------------------------------- /multi/imxrt-multi/trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Simple tracing helpers 5 | * 6 | * Copyright 2024 Phoenix Systems 7 | * Author: Gerard Swiderski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _MULTI_TRACE_H_ 15 | #define _MULTI_TRACE_H_ 16 | 17 | #include 18 | 19 | #ifdef TRACE_ENABLE 20 | #define TRACE(fmt, ...) printf("%s:" fmt "\n", __FUNCTION__, ##__VA_ARGS__) 21 | #define TRACE_IRQ() /* TODO: use rtt_write from librtt */ 22 | #else 23 | #define TRACE(fmt, ...) 24 | #define TRACE_IRQ() 25 | #endif 26 | 27 | 28 | #endif /* end of _MULTI_TRACE_H_ */ 29 | -------------------------------------------------------------------------------- /_targets/Makefile.armv7a7-imx6ull: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # iMX6ULL drivers 5 | # 6 | # Copyright 2019 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := imx6ull-sdma imx6ull-gpio libimx6ull-ecspi libimx6ull-qspi 10 | DEFAULT_COMPONENTS += imx6ull-flash 11 | DEFAULT_COMPONENTS += imx6ull-flashnor 12 | DEFAULT_COMPONENTS += libusbclient cdc-demo 13 | DEFAULT_COMPONENTS += imx6ull-uart imx6ull-otp 14 | DEFAULT_COMPONENTS += imx6ull-wdg imx6ull-i2c imx6ull-sdio 15 | 16 | DEFAULT_COMPONENTS += libusbehci umass libusbdrv-umass usbacm libusbdrv-usbacm 17 | DEFAULT_COMPONENTS += libsensors sensors libsensorsclient 18 | -------------------------------------------------------------------------------- /_targets/Makefile.armv7m7-imxrt106x: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 device drivers 3 | # 4 | # iMX RT drivers 5 | # 6 | # Copyright 2019 Phoenix Systems 7 | # 8 | 9 | DEFAULT_COMPONENTS := imxrt-multi 10 | 11 | ifneq (, $(findstring 117, $(TARGET))) 12 | DEFAULT_COMPONENTS += libusbclient imxrt-flash cdc-demo imxrt117x-otp libusbehci umass libusbdrv-umass usbacm libusbdrv-usbacm 13 | else ifneq (, $(findstring 105, $(TARGET))) 14 | # placeholder 15 | else ifneq (, $(findstring 106, $(TARGET))) 16 | DEFAULT_COMPONENTS += libusbclient imxrt-flash cdc-demo libimxrt-edma libusbehci umass libusbdrv-umass usbacm libusbdrv-usbacm 17 | endif 18 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/uart.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 UART driver 5 | * 6 | * Copyright 2017, 2018 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _UART_H_ 15 | #define _UART_H_ 16 | 17 | 18 | int uart_configure(int uart, char bits, char parity, unsigned int baud, char enable); 19 | 20 | 21 | int uart_write(int uart, const void *buff, unsigned int bufflen); 22 | 23 | 24 | int uart_read(int uart, void* buff, unsigned int count, char mode, unsigned int timeout); 25 | 26 | 27 | int uart_init(void); 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/spi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 SPI driver 5 | * 6 | * Copyright 2018 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef SPI_H_ 16 | #define SPI_H_ 17 | 18 | 19 | #include 20 | 21 | 22 | int spi_transaction(int spi, int dir, unsigned char cmd, unsigned int addr, unsigned char flags, 23 | unsigned char *ibuff, const unsigned char *obuff, size_t bufflen); 24 | 25 | 26 | int spi_configure(int spi, char mode, char bdiv, int enable); 27 | 28 | 29 | void spi_init(void); 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /usb/libusbclient/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Phoenix-RTOS 3 | # 4 | # usbc - usb module loader 5 | # 6 | # Copyright 2019 Phoenix Systems 7 | # Author: Kamil Amanowicz, Hubert Buczynski 8 | 9 | NAME := libusbclient 10 | LOCAL_PATH := $(call my-dir) 11 | SRCS := $(wildcard $(LOCAL_PATH)/imx-usbc/*.c) 12 | 13 | ifneq (, $(findstring imxrt, $(TARGET))) 14 | SRCS += $(wildcard $(LOCAL_PATH)/imxrt-usbc/*.c) 15 | else ifneq (, $(findstring imx6ull, $(TARGET))) 16 | SRCS += $(wildcard $(LOCAL_PATH)/imx6ull-usbc/*.c) 17 | else 18 | $(NAME): ; $(error $(NAME) for $(TARGET) not implemented) 19 | endif 20 | 21 | DEPS := usb 22 | 23 | include $(static-lib.mk) 24 | 25 | 26 | -------------------------------------------------------------------------------- /adc/ad7779/imx6ull/spi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "../ad7779.h" 7 | 8 | 9 | int spi_exchange(uint8_t *buff, uint8_t len) 10 | { 11 | return ecspi_exchangeBusy(ecspi1, buff, buff, len); 12 | } 13 | 14 | 15 | int spi_init(void) 16 | { 17 | int res; 18 | 19 | /* Initialize ecspi1 with channel 0 */ 20 | if ((res = ecspi_init(ecspi1, 1)) < 0) { 21 | log_error("failed to initialize ecspi"); 22 | return res; 23 | } 24 | 25 | if ((res = ecspi_setClockDiv(ecspi1, 0xF, 0x4))) { 26 | log_error("failed to divide ecspi clock"); 27 | return res; 28 | } 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /tty/pc-tty/ttypc_bioskbd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * 101-key US BIOS keyboard 5 | * 6 | * Copyright 2020 Phoenix Systems 7 | * Author: Lukasz Kosinski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _TTYPC_BIOSKBD_H_ 15 | #define _TTYPC_BIOSKBD_H_ 16 | 17 | #include "ttypc.h" 18 | 19 | 20 | /* Updates keyboard LEDs */ 21 | extern int _ttypc_bioskbd_updateled(ttypc_t *ttypc); 22 | 23 | 24 | /* Destroys keyboard */ 25 | extern void ttypc_bioskbd_destroy(ttypc_t *ttypc); 26 | 27 | 28 | /* Initializes BIOS keyboard */ 29 | extern int ttypc_bioskbd_init(ttypc_t *ttypc); 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /gpio/rcpwm/include/rcpwm/msg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Xilinx Zynq7000 / ZynqMP PWM driver binary interface 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef RCPWM_PRIV_H 15 | #define RCPWM_PRIV_H 16 | 17 | #include 18 | #include 19 | 20 | 21 | typedef struct { 22 | enum { rcpwm_msgSet, 23 | rcpwm_msgGet } type; 24 | uint32_t compval[8]; 25 | uint8_t mask; 26 | } rcpwm_imsg_t; 27 | 28 | 29 | typedef struct { 30 | int err; 31 | uint32_t compval[8]; 32 | } rcpwm_omsg_t; 33 | 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /sensors/psp/generic/psp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * generic/stub platform support package (PSP) 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Mateusz Niewiadomski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #include 16 | #include 17 | 18 | 19 | void bsp_busDealloc(struct _sensor_bus_t *bus) 20 | { 21 | return; 22 | } 23 | 24 | 25 | int psp_busAlloc(sensor_bus_t *bus, enum sensor_bus_type type) 26 | { 27 | return -1; 28 | } 29 | 30 | 31 | void psp_busDone(void) 32 | { 33 | return; 34 | } 35 | 36 | 37 | int psp_busInit(void) 38 | { 39 | return -1; 40 | } 41 | -------------------------------------------------------------------------------- /multi/imxrt-multi/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imxrt-multi 3 | # 4 | # Copyright 2019 Phoenix Systems 5 | # 6 | 7 | NAME := imxrt-multi 8 | 9 | LOCAL_PATH := $(call my-dir) 10 | 11 | LOCAL_SRCS = imxrt-multi.c common.c uart.c gpio.c spi.c i2c.c fs.c posixsrv.c pct2075.c rtt.c 12 | ifneq ($(TARGET_SUBFAMILY), imxrt117x) 13 | LOCAL_SRCS += trng.c 14 | else 15 | LOCAL_SRCS += cm4.c 16 | endif 17 | DEP_LIBS := libtty libklog libpseudodev i2c-common librtt 18 | LIBS := libdummyfs libklog libpseudodev libposixsrv 19 | LOCAL_HEADERS := imxrt-multi.h 20 | 21 | # FIXME: adapt code to array-bounds checker 22 | LOCAL_CFLAGS := -Wno-array-bounds 23 | 24 | include $(binary.mk) 25 | -------------------------------------------------------------------------------- /multi/imxrt-multi/cm4/lib/string.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT117x Cortex-M4 basic string funtions 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include "string.h" 15 | 16 | void *memcpy(void *dst, void *src, size_t len) 17 | { 18 | size_t i; 19 | 20 | for (i = 0; i < len; ++i) 21 | ((char *)dst)[i] = ((char *)src)[i]; 22 | 23 | return dst; 24 | } 25 | 26 | 27 | void *memset(void *dst, int val, size_t len) 28 | { 29 | size_t i; 30 | 31 | for (i = 0; i < len; ++i) 32 | ((char *)dst)[i] = (char)val; 33 | 34 | return dst; 35 | } 36 | -------------------------------------------------------------------------------- /pcie/server/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | # PCI Express server 8 | NAME := pcie 9 | LOCAL_SRCS := pcie.c 10 | LOCAL_HEADERS := pcie.h 11 | 12 | ifeq ($(PCI_EXPRESS_INIT_TEBF0808_PHY),y) 13 | CFLAGS += -DPCI_EXPRESS_INIT_TEBF0808_PHY 14 | DEP_LIBS := tebf0808-pcie-refclk tebf0808-ps-gtr-phy i2c-common libi2c-msg 15 | endif 16 | 17 | ifeq ($(PCI_EXPRESS_XILINX_NWL),y) 18 | CFLAGS += -DPCI_EXPRESS_XILINX_NWL 19 | DEP_LIBS += pcie-xilinx-nwl 20 | endif 21 | 22 | ifeq ($(PCI_EXPRESS_XILINX_AXI),y) 23 | CFLAGS += -DPCI_EXPRESS_XILINX_AXI 24 | DEP_LIBS += pcie-xilinx-axi 25 | endif 26 | 27 | include $(binary.mk) 28 | -------------------------------------------------------------------------------- /tty/uart16550/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS pc-uart driver 3 | # 4 | # Copyright 2017, 2018 Phoenix Systems 5 | # Copyright 2001, 2005-2006 Pawel Pisarczyk 6 | # 7 | 8 | NAME := uart16550 9 | LOCAL_SRCS := uart16550.c 10 | 11 | ifeq ($(TARGET_FAMILY),riscv64) 12 | LOCAL_SRCS += uarthw-riscv.c 13 | else ifeq ($(TARGET_FAMILY),ia32) 14 | LOCAL_SRCS += uarthw-pc.c 15 | else ifeq ($(TARGET_SUBFAMILY),zynq7000) 16 | LOCAL_SRCS += uarthw-zynq.c 17 | else ifeq ($(TARGET_SUBFAMILY),zynqmp) 18 | LOCAL_SRCS += uarthw-zynq.c 19 | else ifeq ($(TARGET_SUBFAMILY),tda4vm) 20 | LOCAL_SRCS += uarthw-tda4vm.c 21 | endif 22 | 23 | DEP_LIBS := libtty libklog 24 | include $(binary.mk) 25 | -------------------------------------------------------------------------------- /tty/pc-tty/ttypc_mouse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * PS/2 3-button mouse 5 | * 6 | * Copyright 2024 Phoenix Systems 7 | * Author: Adam Greloch 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _TTYPC_MOUSE_H_ 15 | #define _TTYPC_MOUSE_H_ 16 | 17 | #include "ttypc_vt.h" 18 | 19 | 20 | /* Initializes PS/2 mouse */ 21 | extern int ttypc_mouse_init(ttypc_t *ttypc); 22 | 23 | 24 | /* Reads a mouse event from I/O buffer and handles it */ 25 | extern int ttypc_mouse_handle_event(ttypc_t *ttypc, unsigned char b); 26 | 27 | 28 | /* Destroys PS/2 mouse */ 29 | extern void ttypc_mouse_destroy(ttypc_t *ttypc); 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /display/oled-128O064B0/oled-phy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * OLED physical interface 5 | * 6 | * Copyright 2020 Phoenix Systems 7 | * Author: Hubert Buczyński 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _OLED_PHY_H_ 16 | #define _OLED_PHY_H_ 17 | 18 | 19 | #include 20 | 21 | 22 | extern int oledphy_sendCmd(uint8_t cmd); 23 | 24 | extern int oledphy_sendData(uint8_t data); 25 | 26 | extern int oledphy_sendDataBuf(uint8_t *data, uint8_t size); 27 | 28 | extern int oledphy_init(void); 29 | 30 | extern int oledphy_setPos(uint8_t x, uint8_t y); 31 | 32 | extern int oledphy_reset(void); 33 | 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /multi/imxrt-multi/gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT GPIO driver 5 | * 6 | * Copyright 2019 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _GPIO_H_ 15 | #define _GPIO_H_ 16 | 17 | #include 18 | 19 | 20 | int gpio_handleMsg(msg_t *msg, int dev); 21 | 22 | 23 | int gpio_init(void); 24 | 25 | 26 | int gpio_setPort(int port, uint32_t mask, uint32_t val); 27 | 28 | 29 | int gpio_getPort(int port, uint32_t *val); 30 | 31 | 32 | int gpio_setDir(int port, uint32_t mask, uint32_t val); 33 | 34 | 35 | int gpio_getDir(int port, uint32_t *val); 36 | 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /storage/imx6ull-flash/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imx6ull-flash driver 3 | # 4 | # Copyright 2018, 2019 Phoenix Systems 5 | # 6 | 7 | NAME := libflashdrv-imx6ull 8 | LOCAL_SRCS := flashdrv.c 9 | LOCAL_HEADERS := imx6ull-flashdrv.h 10 | 11 | include $(static-lib.mk) 12 | 13 | NAME := imx6ull-flash 14 | LOCAL_SRCS := flashsrv.c flashdev.c 15 | LOCAL_HEADERS := imx6ull-flashsrv.h imx6ull-flashdev.h 16 | DEP_LIBS := libflashdrv-imx6ull 17 | LIBS := libjffs2 libstorage libmtd libptable 18 | 19 | include $(binary.mk) 20 | 21 | # NAND flash test program 22 | NAME := imx6ull-flash-test 23 | LOCAL_SRCS := imx6ull-flash-test.c 24 | DEP_LIBS := libflashdrv-imx6ull 25 | 26 | include $(binary.mk) 27 | -------------------------------------------------------------------------------- /pcie/README.md: -------------------------------------------------------------------------------- 1 | # PCI Express Driver 2 | 3 | This driver is split into several modules: 4 | - `/sbin/pcie` - platform-agnostic server 5 | - Zynq UltraScale+ platform drivers: 6 | - `pcie-xilinx-nwl` - controls the PCI Express peripheral in the Processing Subsystem (PS) 7 | - `pcie-xilinx-axi` - controls the PCI Express peripheral instantiated in Programmable Logic (PL) 8 | - board-specific support: 9 | - `tebf0808` – provides initialisation code for the TEBF0808 baseboard, setting up the reference clock and PHY. 10 | 11 | ## Configuration 12 | 13 | Configuration is driven by: 14 | 1. Environment variables stored in the `build.project` file 15 | 2. Pre-processor macros defined in `board_config.h` file 16 | -------------------------------------------------------------------------------- /sensors/gps/sensors.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Part of makefile for Phoenix-RTOS sensor manager 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | # Simulated gps sensor 8 | NAME := gps_sim 9 | SENSORHUB_DRIVERS_ALL += $(NAME) 10 | LOCAL_SRCS := gps_sim.c 11 | LOCAL_HEADERS_DIR := nothing 12 | DEPS := $(SENSORHUB_COMMON_DEPS) 13 | include $(static-lib.mk) 14 | 15 | 16 | # PA6H gps sensor 17 | NAME := pa6h 18 | SENSORHUB_DRIVERS_ALL += $(NAME) 19 | LOCAL_SRCS := pa6h.c 20 | DEPS := $(SENSORHUB_COMMON_DEPS) 21 | include $(static-lib.mk) 22 | 23 | 24 | # UBLOX gps sensor 25 | NAME := ubx 26 | SENSORHUB_DRIVERS_ALL += $(NAME) 27 | LOCAL_SRCS := ubx.c 28 | DEPS := $(SENSORHUB_COMMON_DEPS) 29 | include $(static-lib.mk) 30 | -------------------------------------------------------------------------------- /tty/usbacm/srv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * USB CDC ACM driver 5 | * 6 | * Device driver server 7 | * 8 | * Copyright 2024 Phoenix Systems 9 | * Author: Adam Greloch 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #include 16 | #include 17 | 18 | 19 | int main(int argc, char *argv[]) 20 | { 21 | int ret; 22 | usb_driver_t *driver = usb_registeredDriverPop(); 23 | if (driver == NULL) { 24 | fprintf(stderr, "usbacm: no driver registered!"); 25 | return 1; 26 | } 27 | 28 | ret = usb_driverProcRun(driver, NULL); 29 | if (ret < 0) { 30 | fprintf(stderr, "usbacm: failed to start server: %d\n", ret); 31 | } 32 | 33 | return ret == 0 ? 0 : 1; 34 | } 35 | -------------------------------------------------------------------------------- /sensors/common/bus/bus.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Sensor bus operands and management 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Mateusz Niewiadomski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | 16 | 17 | extern int sensor_bus_genericSpiSetup(sensor_bus_t *bus, const char *spiDev, const char *ss, int speed, char mode) 18 | { 19 | if (bus->bustype != bus_spi) { 20 | return -1; 21 | } 22 | 23 | if (bus->ops.bus_open(bus, spiDev, ss) < 0) { 24 | return -2; 25 | } 26 | 27 | if (bus->ops.bus_cfg(bus, speed, mode) < 0) { 28 | bus->ops.bus_close(bus); 29 | return -3; 30 | } 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /sensors/imu/sensors.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Part of makefile for Phoenix-RTOS sensor manager 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | # Simulated imu sensor 8 | NAME := imu_sim 9 | SENSORHUB_DRIVERS_ALL += $(NAME) 10 | LOCAL_SRCS := imu_sim.c 11 | DEPS := $(SENSORHUB_COMMON_DEPS) 12 | include $(static-lib.mk) 13 | 14 | 15 | # STM lsm9dsxx imu part sensor 16 | NAME := lsm9dsxx_imu 17 | SENSORHUB_DRIVERS_ALL += $(NAME) 18 | LOCAL_SRCS := lsm9dsxx.c 19 | DEPS := $(SENSORHUB_COMMON_DEPS) 20 | include $(static-lib.mk) 21 | 22 | 23 | # TDK IvenSense MPU6000 imu sensor 24 | NAME := mpu6000 25 | SENSORHUB_DRIVERS_ALL += $(NAME) 26 | LOCAL_SRCS := mpu6000.c 27 | DEPS := $(SENSORHUB_COMMON_DEPS) 28 | include $(static-lib.mk) 29 | -------------------------------------------------------------------------------- /sensors/baro/sensors.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Part of makefile for Phoenix-RTOS sensor manager 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | # Simulated baro sensor 8 | NAME := baro_sim 9 | SENSORHUB_DRIVERS_ALL += $(NAME) 10 | LOCAL_SRCS := baro_sim.c 11 | DEPS := $(SENSORHUB_COMMON_DEPS) 12 | include $(static-lib.mk) 13 | 14 | 15 | # TE Connectivity MS5611 barometer sensor 16 | NAME := ms5611 17 | SENSORHUB_DRIVERS_ALL += $(NAME) 18 | LOCAL_SRCS := ms5611.c 19 | DEPS := $(SENSORHUB_COMMON_DEPS) 20 | include $(static-lib.mk) 21 | 22 | 23 | # STM LPS25xx barometer sensor 24 | NAME := lps25xx 25 | SENSORHUB_DRIVERS_ALL += $(NAME) 26 | LOCAL_SRCS := lps25xx.c 27 | DEPS := $(SENSORHUB_COMMON_DEPS) 28 | include $(static-lib.mk) 29 | -------------------------------------------------------------------------------- /sensors/mag/sensors.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Part of makefile for Phoenix-RTOS sensor manager 3 | # 4 | # Copyright 2025 Phoenix Systems 5 | # 6 | 7 | # Simulated magnetometer sensor 8 | NAME := mag_sim 9 | SENSORHUB_DRIVERS_ALL += $(NAME) 10 | LOCAL_SRCS := mag_sim.c 11 | DEPS := $(SENSORHUB_COMMON_DEPS) 12 | include $(static-lib.mk) 13 | 14 | 15 | # STM LIS2MDL sensor 16 | NAME := lis2mdl 17 | SENSORHUB_DRIVERS_ALL += $(NAME) 18 | LOCAL_SRCS := lis2mdl.c 19 | DEPS := $(SENSORHUB_COMMON_DEPS) 20 | include $(static-lib.mk) 21 | 22 | 23 | # STM lsm9dsxx magnetometer part sensor 24 | NAME := lsm9dsxx_mag 25 | SENSORHUB_DRIVERS_ALL += $(NAME) 26 | LOCAL_SRCS := lsm9dsxx.c 27 | DEPS := $(SENSORHUB_COMMON_DEPS) 28 | include $(static-lib.mk) 29 | -------------------------------------------------------------------------------- /usb/libusbclient/imx-usbc/phy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * phy - depends on the platform 5 | * 6 | * Copyright 2020-2021 Phoenix Systems 7 | * Author: Hubert Buczynski, Gerard Swiderski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _PHY_H_ 16 | #define _PHY_H_ 17 | 18 | #include 19 | 20 | 21 | void *usbclient_allocBuff(uint32_t size); 22 | 23 | 24 | void usbclient_buffDestory(void *addrs, uint32_t size); 25 | 26 | 27 | void phy_setClock(void); 28 | 29 | 30 | uint32_t phy_getIrq(void); 31 | 32 | 33 | void *phy_getBase(uint32_t size); 34 | 35 | 36 | void phy_reset(void); 37 | 38 | 39 | void phy_init(void); 40 | 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /tty/pc-tty/ttypc_kbd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * PS/2 101-key US keyboard (based on FreeBSD 4.4 pcvt) 5 | * 6 | * Copyright 2001, 2006 Pawel Pisarczyk 7 | * Copyright 2012, 2019, 2020 Phoenix Systems 8 | * Author: Pawel Pisarczyk, Lukasz Kosinski 9 | * 10 | * This file is part of Phoenix-RTOS. 11 | * 12 | * %LICENSE% 13 | */ 14 | 15 | #ifndef _TTYPC_KBD_H_ 16 | #define _TTYPC_KBD_H_ 17 | 18 | #include "ttypc.h" 19 | 20 | 21 | /* Updates keyboard LEDs */ 22 | extern int _ttypc_kbd_updateled(ttypc_t *ttypc); 23 | 24 | 25 | /* Destroys keyboard */ 26 | extern void ttypc_kbd_destroy(ttypc_t *ttypc); 27 | 28 | 29 | /* Initializes PS/2 keyboard */ 30 | extern int ttypc_kbd_init(ttypc_t *ttypc); 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/rtc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 RTC driver 5 | * 6 | * Copyright 2017, 2018 Phoenix Systems 7 | * Author: Jakub Sejdak, Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef RTC_H_ 15 | #define RTC_H_ 16 | 17 | 18 | #include "stm32l4-multi.h" 19 | 20 | 21 | void rtc_setCalib(int value); 22 | 23 | 24 | int rtc_getTime(rtctimestamp_t *timestamp); 25 | 26 | 27 | int rtc_setTime(rtctimestamp_t *timestamp); 28 | 29 | 30 | int rtc_setAlarm(rtctimestamp_t *timestamp); 31 | 32 | 33 | int rtc_storeBackup(const void *buff, size_t bufflen); 34 | 35 | 36 | int rtc_recallBackup(void *buff, size_t bufflen); 37 | 38 | 39 | int rtc_init(void); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /rtc/rtc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX 6ULL RTC driver API 5 | * 6 | * Copyright 2018 Phoenix Systems 7 | * Author: Krystian Wasik 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef RTC_API_H 15 | #define RTC_API_H 16 | 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | 23 | struct rtc_time { 24 | int tm_sec; 25 | int tm_min; 26 | int tm_hour; 27 | int tm_mday; 28 | int tm_mon; 29 | int tm_year; 30 | int tm_wday; 31 | int tm_yday; 32 | int tm_isdst; 33 | }; 34 | 35 | #define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time) /* Read RTC time */ 36 | #define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time) /* Set RTC time */ 37 | 38 | #endif /* RTC_API_H */ 39 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS stm32-multi 3 | # 4 | # Copyright 2018, 2020 Phoenix Systems 5 | # 6 | 7 | LOCAL_PATH := $(call my-dir) 8 | 9 | NAME := stm32l4-multi 10 | 11 | LOCAL_SRCS = fs.c gpio.c i2c.c posixsrv.c rng.c rtc.c spi.c stm32l4-multi.c tty.c uart.c 12 | ifeq ($(TARGET_SUBFAMILY),stm32l4x6) 13 | LOCAL_CFLAGS += -DMULTIDRV_STACKSZ=640 14 | LOCAL_SRCS += adc_l4.c exti_l4.c flash.c rcc_l4.c 15 | else ifeq ($(TARGET_SUBFAMILY),stm32n6) 16 | LOCAL_CFLAGS += -DMULTIDRV_STACKSZ=2048 17 | LOCAL_SRCS += adc_n6.c clockdef_n6.c exti_n6.c rcc_n6.c pwm_n6.c 18 | endif 19 | 20 | LOCAL_HEADERS := stm32l4-multi.h 21 | DEP_LIBS := libstm32l4-multi libtty libklog 22 | LIBS := libdummyfs libklog libposixsrv 23 | 24 | include $(binary.mk) 25 | -------------------------------------------------------------------------------- /libklog/libklog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Phoenix-RTOS klog driver 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Maciej Purski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | #ifndef _LIBKLOG_H_ 14 | #define _LIBKLOG_H_ 15 | 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | typedef void (*libklog_write_t)(const char *buf, size_t size); 23 | 24 | 25 | int libklog_ctrlHandle(uint32_t port, msg_t *msg, msg_rid_t rid); 26 | 27 | 28 | void libklog_enable(int enable); 29 | 30 | 31 | int libklog_ctrlRegister(oid_t *oid); 32 | 33 | 34 | int libklog_initNoDev(libklog_write_t clbk); 35 | 36 | 37 | int libklog_init(libklog_write_t clbk); 38 | 39 | 40 | #endif /* _LIBKLOG_H_ */ 41 | -------------------------------------------------------------------------------- /multi/imxrt-multi/i2c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT i2c driver 5 | * 6 | * Copyright 2019, 2024 Phoenix Systems 7 | * Author: Andrzej Glowinski, Jacek Maksymowicz 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _I2C_H_ 15 | #define _I2C_H_ 16 | 17 | #include 18 | 19 | 20 | void i2c_handleMsg(msg_t *msg, int dev); 21 | 22 | 23 | int i2c_init(void); 24 | 25 | 26 | int multi_i2c_busWrite(unsigned bus, uint8_t dev_addr, const uint8_t *data, uint32_t len); 27 | 28 | 29 | int multi_i2c_busRead(unsigned bus, uint8_t dev_addr, uint8_t *data_out, uint32_t len); 30 | 31 | 32 | int multi_i2c_regRead(unsigned bus, uint8_t dev_addr, uint8_t reg_addr, uint8_t *data_out, uint32_t len); 33 | 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /gpio/zynq-pwm/README.md: -------------------------------------------------------------------------------- 1 | # zynq-pwm 2 | This hardware driver server provides access to Zynq7000/ZynqMP PWM8X IP core. This driver require the PWM8X IP core to be loaded to the PL. 3 | 4 | ## Usage 5 | `zynq-pwm [OPTIONS]` 6 | Options: 7 | - `-b base_addr` - base address of PWM8X IP (required) 8 | - `-r reload` - reload value 0-4294967295, optional, default 100000 9 | - `-p priority - server thread priority 10 | - `-h` - help 11 | 12 | ## Interface 13 | Server creates a file in /dev for each PWM channel (e.g. /dev/pwm0, /dev/pwm1 ...). Manipulation of PWM duty cycle is performed via writes and reads to/from this files. 14 | Example: 15 | - setting 100/100000 duty cycle on channel #0: `echo 100 > /dev/pwm0` 16 | - getting current duty cycle of channel #0: `cat /dev/pwm0` 17 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/i2c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 I2C driver 5 | * 6 | * Copyright 2020 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef I2C_H_ 16 | #define I2C_H_ 17 | 18 | 19 | #include 20 | 21 | 22 | ssize_t i2c_read(int i2c, unsigned char addr, void *buff, size_t len); 23 | 24 | 25 | ssize_t i2c_readReg(int i2c, unsigned char addr, unsigned char reg, void *buff, size_t len); 26 | 27 | 28 | ssize_t i2c_write(int i2c, unsigned char addr, const void *buff, size_t len); 29 | 30 | 31 | ssize_t i2c_writeReg(int i2c, unsigned char addr, unsigned char reg, const void *buff, size_t len); 32 | 33 | 34 | void i2c_init(void); 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/rcc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 reset and clock controller driver 5 | * 6 | * Copyright 2017, 2018 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef RCC_H_ 15 | #define RCC_H_ 16 | 17 | 18 | #include 19 | 20 | #if defined(__CPU_STM32N6) 21 | #include "clockdef_n6.h" 22 | 23 | 24 | int rcc_setClksel(enum ipclks ipclk, enum clock_ids clkID); 25 | #endif 26 | 27 | 28 | void pwr_lock(void); 29 | 30 | 31 | void pwr_lockFromIRQ(uint32_t previous); 32 | 33 | 34 | void pwr_unlock(void); 35 | 36 | 37 | uint32_t pwr_unlockFromIRQ(void); 38 | 39 | 40 | int rcc_setHsi(int state); 41 | 42 | 43 | int rcc_init(void); 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for phoenix-rtos-devices 3 | # 4 | # Copyright 2018, 2019 Phoenix Systems 5 | # 6 | # %LICENSE% 7 | # 8 | 9 | include ../phoenix-rtos-build/Makefile.common 10 | 11 | .DEFAULT_GOAL := all 12 | 13 | # should define DEFAULT_COMPONENTS and target-specific variables 14 | include _targets/Makefile.$(TARGET_FAMILY)-$(TARGET_SUBFAMILY) 15 | 16 | # default path for the programs to be installed in rootfs 17 | DEFAULT_INSTALL_PATH := /sbin 18 | 19 | # read out all components 20 | ALL_MAKES := $(shell find . -mindepth 2 -name Makefile -not -path '*/.*') 21 | include $(ALL_MAKES) 22 | 23 | # create generic targets 24 | .PHONY: all install clean 25 | all: $(DEFAULT_COMPONENTS) 26 | install: $(patsubst %,%-install,$(DEFAULT_COMPONENTS)) 27 | clean: $(patsubst %,%-clean,$(ALL_COMPONENTS)) 28 | -------------------------------------------------------------------------------- /storage/imx6ull-flash/imx6ull-flashdev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * IMX6ULL NAND flash device interface 5 | * 6 | * Copyright 2022 Phoenix Systems 7 | * Author: Hubert Buczynski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _IMX6ULL_FLASHDEV_H_ 15 | #define _IMX6ULL_FLASHDEV_H_ 16 | 17 | #include 18 | #include "imx6ull-flashdrv.h" 19 | 20 | 21 | /* Storage device context definition */ 22 | typedef struct _storage_devCtx_t { 23 | flashdrv_dma_t *dma; 24 | void *databuf; /* at least writesz + metasz */ 25 | void *metabuf; /* at least metasz */ 26 | handle_t lock; 27 | } storage_devCtx_t; 28 | 29 | 30 | extern int flashdev_done(storage_t *strg); 31 | 32 | 33 | extern int flashdev_init(storage_t *strg); 34 | 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /multi/imxrt-multi/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT common 5 | * 6 | * Copyright 2017, 2018 Phoenix Systems 7 | * Author: Aleksander Kaminski, Hubert Buczynski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _COMMON_H_ 15 | #define _COMMON_H_ 16 | 17 | #include 18 | 19 | #include "config.h" 20 | #include "helpers.h" 21 | #include "imxrt-multi.h" 22 | 23 | 24 | extern unsigned int multi_port; 25 | 26 | 27 | static inline void common_dataBarrier(void) 28 | { 29 | __asm__ volatile ("dmb"); 30 | } 31 | 32 | 33 | static inline void common_dataSyncBarrier(void) 34 | { 35 | __asm__ volatile ("dsb"); 36 | } 37 | 38 | 39 | static inline void common_instrBarrier(void) 40 | { 41 | __asm__ volatile ("isb"); 42 | } 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /multi/mcxn94x-multi/dev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Multidriver device manager 5 | * 6 | * Copyright 2024 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef MULTI_DEV_H_ 15 | #define MULTI_DEV_H_ 16 | 17 | #include 18 | 19 | typedef void devHandler(msg_t *msg, msg_rid_t rid, unsigned int major, unsigned int minor); 20 | 21 | 22 | int dev_allocMajor(unsigned int *major); 23 | 24 | 25 | int dev_registerFile(const char *fname, unsigned int major, unsigned int minor); 26 | 27 | 28 | int dev_msgReceive(msg_t *msg, msg_rid_t *rid); 29 | 30 | 31 | void dev_handle(msg_t *msg, msg_rid_t rid); 32 | 33 | 34 | void dev_register(devHandler *handler, unsigned int major); 35 | 36 | #endif /* MULTI_DEV_H_ */ 37 | -------------------------------------------------------------------------------- /tty/pc-tty/ttypc_ps2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * PS/2 common utilities 5 | * 6 | * Copyright 2024 Phoenix Systems 7 | * Author: Adam Greloch 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _TTYPC_PS2_H_ 15 | #define _TTYPC_PS2_H_ 16 | 17 | #include "ttypc_vt.h" 18 | 19 | 20 | /* Writes a byte to PS/2 control buffer */ 21 | extern int ttypc_ps2_write_ctrl(ttypc_t *ttypc, unsigned char byte); 22 | 23 | 24 | /* Reads a byte from PS/2 I/O buffer */ 25 | extern int ttypc_ps2_read(ttypc_t *ttypc); 26 | 27 | 28 | /* Writes a byte to PS/2 I/O buffer */ 29 | extern int ttypc_ps2_write(ttypc_t *ttypc, unsigned char byte); 30 | 31 | 32 | /* Reads a byte from PS/2 control buffer */ 33 | extern unsigned char ttypc_ps2_read_ctrl(ttypc_t *ttypc); 34 | 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /storage/flashdrv/drv/grlib-ftmctrl/flashdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB FTMCTRL Flash driver 5 | * 6 | * Copyright 2023-2025 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _FTMCTRL_FLASHDRV_H_ 16 | #define _FTMCTRL_FLASHDRV_H_ 17 | 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | struct cache_devCtx_s { 26 | struct _storage_t *strg; 27 | }; 28 | 29 | 30 | struct _storage_devCtx_t { 31 | cfi_info_t cfi; 32 | const struct _flash_dev_t *dev; 33 | 34 | void *ftmctrl; 35 | 36 | handle_t lock; 37 | size_t sectorsz; 38 | 39 | cachectx_t *cache; 40 | cache_devCtx_t cacheCtx; 41 | }; 42 | 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /tty/uart16550/uarthw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * UART 16550 device driver 5 | * 6 | * Hardware abstracion layer interface 7 | * 8 | * Copyright 2020-2022 Phoenix Systems 9 | * Author: Pawel Pisarczyk 10 | * 11 | * This file is part of Phoenix-RTOS. 12 | * 13 | * %LICENSE% 14 | */ 15 | 16 | #ifndef _DEV_UART16550_UARTHW_H_ 17 | #define _DEV_UART16550_UARTHW_H_ 18 | 19 | #include 20 | 21 | 22 | extern uint8_t uarthw_read(void *hwctx, unsigned int reg); 23 | 24 | 25 | extern void uarthw_write(void *hwctx, unsigned int reg, uint8_t val); 26 | 27 | 28 | extern char *uarthw_dump(void *hwctx, char *s, size_t sz); 29 | 30 | 31 | extern unsigned int uarthw_irq(void *hwctx); 32 | 33 | 34 | extern int uarthw_init(unsigned int uartn, void *hwctx, size_t hwctxsz, unsigned int *fclk); 35 | 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /multi/imxrt-multi/cm4/lib/_startc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT117x Cortex-M4 core start code 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | 16 | #include "cm4.h" 17 | #include "gpio.h" 18 | #include "string.h" 19 | #include "mu.h" 20 | 21 | extern char __bss_start; 22 | extern char _end; 23 | extern int main(int argc, char *argv[]); 24 | 25 | 26 | __attribute__((noreturn)) void _startc(void) 27 | { 28 | memset(&__bss_start, 0, &_end - &__bss_start); 29 | 30 | /* TODO .data init */ 31 | 32 | /* Platform init */ 33 | cm4_init(); 34 | gpio_init(); 35 | mu_init(); 36 | 37 | __asm__ volatile ("cpsie if"); 38 | 39 | main(0, NULL); 40 | 41 | for (;;) 42 | ; 43 | } 44 | -------------------------------------------------------------------------------- /storage/flashdrv/drv/grlib-spimctrl/flashdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB SPIMCTRL Flash driver 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _SPIMCTRL_FLASHDRV_H_ 16 | #define _SPIMCTRL_FLASHDRV_H_ 17 | 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | struct cache_devCtx_s { 26 | struct _storage_t *strg; 27 | }; 28 | 29 | 30 | struct _storage_devCtx_t { 31 | cfi_info_t cfi; 32 | const struct flash_dev *dev; 33 | 34 | struct spimctrl *spimctrl; 35 | 36 | handle_t lock; 37 | size_t sectorsz; 38 | 39 | cachectx_t *cache; 40 | cache_devCtx_t cacheCtx; 41 | }; 42 | 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /sensors/server-include/libsensors/sim/simsensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Generic functions for all sensor simulators 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Piotr Nieciecki 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | 16 | 17 | typedef struct { 18 | const char *name; 19 | sensor_type_t sensorTypes; 20 | unsigned int messageQueueLen; 21 | time_t timeHorizon; 22 | } simsens_settings_t; 23 | 24 | 25 | /* Starts simsensor. Function is meant to be while registering new sensor type. */ 26 | extern int simsens_start(sensor_info_t *info); 27 | 28 | 29 | /* Allocates simsensor with specified settings. Meant to be used while registering new type. */ 30 | extern int simsens_alloc(sensor_info_t *info, const char *args, const simsens_settings_t *settings); 31 | -------------------------------------------------------------------------------- /storage/host-flash/host-flashsrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Emulated flash server 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Tomasz Korniluk 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | #ifndef HOST_FLASHSRV_H 13 | #define HOST_FLASHSRV_H 14 | 15 | #include 16 | #include 17 | 18 | 19 | int hostflashsrv_readFile(id_t *id, off_t off, char *buff, size_t bufflen); 20 | 21 | 22 | int hostflashsrv_writeFile(id_t *id, const char *buff, size_t bufflen); 23 | 24 | 25 | int hostflashsrv_lookup(const char *name, id_t *res); 26 | 27 | 28 | int hostflashsrv_open(id_t *id); 29 | 30 | 31 | int hostflashsrv_close(id_t *id); 32 | 33 | 34 | int hostflashsrv_devctl(meterfs_i_devctl_t *i, meterfs_o_devctl_t *o); 35 | 36 | 37 | int hostflashsrv_init(size_t *flashsz, size_t *sectorsz, const char *fileName); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /pcie/tebf0808/tebf0808-ps-gtr-phy.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (C) 2010-2020 Xilinx, Inc. All rights reserved. 3 | * SPDX-License-Identifier: MIT 4 | ******************************************************************************/ 5 | 6 | /* 7 | * Phoenix-RTOS 8 | * 9 | * PCI Express PS PHY initialisation code for TEBF0808 baseboard + TE0807 SOM 10 | * Code is derived from Trenz Electronic example design. 11 | * 12 | * Copyright 2025 Phoenix Systems 13 | * Author: Dariusz Sabala 14 | * 15 | * %LICENSE% 16 | */ 17 | 18 | #ifndef TEBF0808_PS_GTR_PHY_H 19 | #define TEBF0808_PS_GTR_PHY_H 20 | 21 | /** 22 | * Initialise PS GTR PHY 23 | * 24 | * Return values: 25 | * - 0: Operation succeed 26 | * - others values: Operation failed 27 | */ 28 | int tebf0808_pciePsGtrPhyInit(void); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /storage/host-flash/host-flash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Flash emulator 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Tomasz Korniluk 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | #ifndef HOST_FLASH_H 13 | #define HOST_FLASH_H 14 | 15 | #include 16 | #include 17 | 18 | 19 | ssize_t hostflash_read(struct _meterfs_devCtx_t *devCtx, off_t offs, void *buff, size_t bufflen); 20 | 21 | 22 | ssize_t hostflash_write(struct _meterfs_devCtx_t *devCtx, off_t offs, const void *buff, size_t bufflen); 23 | 24 | 25 | int hostflash_sectorErase(struct _meterfs_devCtx_t *devCtx, off_t offs); 26 | 27 | 28 | void hostflash_powerCtrl(struct _meterfs_devCtx_t *devCtx, int state); 29 | 30 | 31 | struct _meterfs_devCtx_t *hostflash_devCtx(void); 32 | 33 | 34 | int hostflash_init(size_t *flashsz, size_t *sectorsz, const char *fileName); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /display/oled-128O064B0/oled-api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Oled driver message API 5 | * 6 | * Copyright 2020 Phoenix Systems 7 | * Author: Marcin Baran 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _OLED_API_H_ 15 | #define _OLED_API_H_ 16 | 17 | #include 18 | 19 | #define OLED_DRIVER "/dev/oled" 20 | #define OLED_X_RES 128 21 | #define OLED_Y_RES 64 22 | 23 | typedef enum { 24 | oled_write__rect, 25 | oled_write__bitmap, 26 | oled_write__text_abs, 27 | oled_write__text_cont, 28 | oled_write__clear, 29 | oled_write__draw 30 | } oled_write_type_t; 31 | 32 | typedef struct { 33 | oled_write_type_t type; 34 | 35 | uint8_t x; 36 | uint8_t y; 37 | uint8_t w; 38 | uint8_t h; 39 | 40 | union { 41 | const char *text; 42 | uint8_t filled; 43 | const uint64_t *data; 44 | }; 45 | } oled_write_t; 46 | 47 | #endif -------------------------------------------------------------------------------- /gpio/zynq7000-xgpio/README.md: -------------------------------------------------------------------------------- 1 | # zynq7000-xgpio 2 | This hardware driver server provides access to Zynq7000 AXI GPIO IP core. This driver requires the AXI GPIO IP core to be loaded to the PL. 3 | 4 | ## Usage 5 | `zynq7000-xgpio [OPTIONS]` 6 | Options: 7 | - `-b base_addr` - base address of AXI GPIO IP (required) 8 | - `-p priority` - server thread priority 9 | - `-h` - help 10 | 11 | ## Interface 12 | Server creates a directory in /dev for each GPIO channel (i.e. `/dev/xgpio0`, `/dev/xgpio1`). Each directory contains 3 types of files: 13 | - port - provides read/write access to the whole 32 bit-wide GPIO port 14 | - dir - allows GPIO port configuration (0: input, 1: output) 15 | - pinx - access to the individual GPIO pins 16 | 17 | Example: 18 | - setting GPIO channel 1 pin 15 to logic one: `echo 1 > /dev/xgpio0/pin15` 19 | - getting value of GPIO channel 2 (whole port): `cat /dev/xgpio1/port` 20 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: WebKit 3 | 4 | ColumnLimit: 0 5 | AlignAfterOpenBracket: DontAlign 6 | UseTab: ForContinuationAndIndentation 7 | IndentWidth: 4 8 | ContinuationIndentWidth: 8 9 | BracedInitializerIndentWidth: 4 10 | TabWidth: 4 11 | 12 | PointerAlignment: Right 13 | SpaceAfterCStyleCast: false 14 | BreakBeforeBraces: Stroustrup 15 | 16 | AlignConsecutiveMacros: 17 | Enabled: true 18 | AlignEscapedNewlines: DontAlign 19 | AlignTrailingComments: 20 | Kind: Always 21 | OverEmptyLines: 0 22 | AllowShortBlocksOnASingleLine: true 23 | AllowShortCaseLabelsOnASingleLine: true 24 | AllowShortLoopsOnASingleLine: false 25 | IndentCaseLabels: true 26 | MaxEmptyLinesToKeep: 2 27 | SortIncludes: false 28 | SpacesBeforeTrailingComments: 2 29 | 30 | BreakBeforeBinaryOperators: None 31 | BreakBeforeTernaryOperators: false 32 | BreakConstructorInitializers: AfterColon 33 | 34 | InsertNewlineAtEOF: true 35 | ... 36 | -------------------------------------------------------------------------------- /storage/imx6ull-flashnor/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS imx6ull-flashnor driver 3 | # 4 | # Copyright 2021 Phoenix Systems 5 | # 6 | 7 | 8 | NAME := libflashnordrv-imx6ull 9 | LOCAL_SRCS := flashnor-ecspi.c flashnor-qspi.c flashnor-drv.c nor.c 10 | LOCAL_HEADERS := imx6ull-flashnor-ecspi.h imx6ull-flashnor-qspi.h imx6ull-flashnor-drv.h imx6ull-nor.h 11 | DEPS := libimx6ull-ecspi libimx6ull-qspi 12 | 13 | include $(static-lib.mk) 14 | 15 | NAME := imx6ull-flashnor 16 | LOCAL_SRCS := flashnor-srv.c 17 | DEP_LIBS := libflashnordrv-imx6ull libimx6ull-ecspi libimx6ull-qspi 18 | LIBS := libmeterfs-storage libmeterfs libstorage libjffs2 libmtd libtinyaes 19 | LOCAL_INSTALL_PATH := /sbin 20 | 21 | include $(binary.mk) 22 | 23 | # NOR flash test program 24 | NAME := flashnor-test 25 | LOCAL_SRCS := flashnor-test.c 26 | DEP_LIBS := libflashnordrv-imx6ull libimx6ull-ecspi libimx6ull-qspi 27 | 28 | include $(binary.mk) 29 | -------------------------------------------------------------------------------- /multi/imxrt-multi/cm4/lib/gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT117x Cortex-M4 core gpio driver 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef M4GPIO_H_ 15 | #define M4GPIO_H_ 16 | 17 | #include 18 | 19 | // clang-format off 20 | enum { gpio1 = 0, gpio2, gpio3, gpio4, gpio5, gpio6, gpio7, gpio8, gpio9, gpio10, gpio11, gpio12, gpio13}; 21 | 22 | 23 | enum { gpio_in = 0, gpio_out }; 24 | // clang-format on 25 | 26 | 27 | int gpio_setPin(int port, int pin, int state); 28 | 29 | 30 | int gpio_togglePin(int port, int pin); 31 | 32 | 33 | int gpio_setPort(int port, uint32_t mask, uint32_t val); 34 | 35 | 36 | int gpio_getPort(int port, unsigned int *val); 37 | 38 | 39 | int gpio_setDir(int port, int pin, int dir); 40 | 41 | 42 | void gpio_init(void); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /storage/flashdrv/include/flashdrv/flashsrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Flash server 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _FLASHDRV_FLASHSRV_H_ 15 | #define _FLASHDRV_FLASHSRV_H_ 16 | 17 | #include 18 | #include 19 | 20 | /* clang-format off */ 21 | #define LOG(fmt, ...) do { (void)fprintf(stdout, "flashsrv: " fmt "\n", ##__VA_ARGS__); } while (0) 22 | #define LOG_ERROR(fmt, ...) do { (void)fprintf(stdout, "flashsrv:%s:%d: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__); } while (0) 23 | #define TRACE(fmt, ...) do { if (0) { (void)fprintf(stdout, "flashsrv:%s:%d: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__); } } while (0) 24 | /* clang-format on */ 25 | 26 | 27 | void flashsrv_register(const struct flash_driver *driver); 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /storage/gr716-flash/gr716-flashsrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GR716 Flash server 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _GR716_FLASHSRV_H_ 16 | #define _GR716_FLASHSRV_H_ 17 | 18 | 19 | #include 20 | 21 | 22 | /* clang-format off */ 23 | enum { flashsrv_devctl_properties = 0, flashsrv_devctl_sync, flashsrv_devctl_eraseSector, flashsrv_devctl_erasePartition, 24 | flashsrv_devctl_directWrite }; 25 | /* clang-format on */ 26 | 27 | 28 | typedef struct { 29 | int type; 30 | uint32_t addr; 31 | } __attribute__((packed)) flash_i_devctl_t; 32 | 33 | 34 | typedef struct { 35 | struct { 36 | uint32_t size; 37 | uint32_t psize; 38 | uint32_t ssize; 39 | uint32_t offs; 40 | } properties; 41 | } __attribute__((packed)) flash_o_devctl_t; 42 | 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /spacewire/grspwrtr/grspwrtr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB SpaceWire driver 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Andrzej Tlomak 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef SPWRTR_H 16 | #define SPWRTR_H 17 | 18 | #include 19 | 20 | 21 | typedef struct { 22 | /* clang-format off */ 23 | enum { spwrtr_pmap_set = 0, spwrtr_pmap_get, spwrtr_pctrl, spwrtr_reset } type; 24 | /* clang-format on */ 25 | union { 26 | struct { 27 | uint8_t port; 28 | uint32_t enPorts; 29 | } mapping; 30 | } task; 31 | } spwrtr_t; 32 | 33 | 34 | _Static_assert(sizeof(spwrtr_t) <= sizeof(((msg_t *)0)->i.raw), "spwrtr_t exceeds size of msg.i.raw"); 35 | 36 | 37 | typedef struct { 38 | unsigned int val; 39 | } spwrtr_o_t; 40 | 41 | 42 | _Static_assert(sizeof(spwrtr_o_t) <= sizeof(((msg_t *)0)->i.raw), "spwrtr_o_t exceeds size of msg.i.raw"); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /adc/ad7779/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for AD7779 driver 3 | # 4 | # Copyright 2019, 2020 Phoenix Systems 5 | # 6 | 7 | NAME := ad7779 8 | LOCAL_PATH := $(call my-dir) 9 | SRCS := $(addprefix $(LOCAL_PATH), ad7779.c ad7779-driver.c) 10 | LOCAL_HEADERS := adc-api-ad7779.h 11 | 12 | ifneq (, $(findstring imxrt, $(TARGET))) 13 | SRCS += $(wildcard $(LOCAL_PATH)imxrt/*.c) 14 | DEP_LIBS := libimxrt-edma 15 | DEPS := imxrt-multi 16 | CFLAGS += -DAD7779_BUFFER_CNT=4 -DAD7779_BUFFER_SIZE=2048 17 | else ifneq (, $(findstring imx6ull, $(TARGET))) 18 | SRCS += $(wildcard $(LOCAL_PATH)imx6ull/*.c) 19 | DEP_LIBS := libsdma libimx6ull-ecspi 20 | DEPS := imx6ull-gpio 21 | CFLAGS += -DAD7779_BUFFER_CNT=2 -DAD7779_BUFFER_SIZE=4096 22 | else 23 | $(NAME): ; $(error $(NAME) for $(TARGET) not implemented) 24 | endif 25 | 26 | include $(binary.mk) 27 | 28 | NAME := ad7779-tool 29 | SRCS := $(addprefix $(LOCAL_PATH), ad7779-tool.c) 30 | DEPS := ad7779 31 | include $(binary.mk) 32 | -------------------------------------------------------------------------------- /display/oled-128O064B0/oled-graphic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * OLED graphic API 5 | * 6 | * Copyright 2018 Phoenix Systems 7 | * Author: Andrzej Glowinski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _OLED_GRAPHIC_H_ 15 | #define _OLED_GRAPHIC_H_ 16 | 17 | #include 18 | 19 | 20 | void oledgraph_fillRect(int x, int y, int w, int h, int filled); 21 | 22 | 23 | void oledgraph_fillBitmap(int x, int y, int w, int h, const uint64_t map[]); 24 | 25 | 26 | void oledgraph_fillChar(int x, int y, int w, int h, int font, char c); 27 | 28 | 29 | void oledgraph_drawStringAbs(int x, int y, int w, int h, int font, int size, const char* str); 30 | 31 | 32 | void oledgraph_drawStringCont(int x, int y, int w, int h, int font, int size, const char* str); 33 | 34 | 35 | void oledgraph_reset(int x, int y, int w, int h); 36 | 37 | 38 | void oledgraph_drawBuffer(int x, int y, int w, int h, int force); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /storage/gr716-flash/tests/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GR716 test utilities 5 | * 6 | * Copyright 2020, 2023 Phoenix Systems 7 | * Author: Hubert Buczynski, Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _GR716_FLASH_TEST_UTILS_H_ 15 | #define _GR716_FLASH_TEST_UTILS_H_ 16 | 17 | #include 18 | 19 | static int testCounter = 1; 20 | static int categoryCounter = 0; 21 | 22 | #define TEST_CATEGORY(category) \ 23 | do { \ 24 | printf("\n\n## %d. %s :", ++categoryCounter, category); \ 25 | testCounter = 1; \ 26 | } while (0) 27 | 28 | 29 | #define TEST_CASE(test) \ 30 | do { \ 31 | printf("\nTEST CASE %d.%d: %-20s\t", categoryCounter, testCounter++, #test); \ 32 | if ((test) == EOK) { \ 33 | printf("-- PASSED"); \ 34 | } \ 35 | else { \ 36 | printf("-- FAILED"); \ 37 | } \ 38 | printf("\n"); \ 39 | fflush(stdout); \ 40 | } while (0) 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /can/zynqmp-can/README.md: -------------------------------------------------------------------------------- 1 | # zynqmp-can 2 | The `zynqmp-can` is a hardware driver that provides access to the ZynqMP CAN (Processor Subsystem) peripheral. 3 | 4 | ## Usage 5 | `zynqmp-can [options]` 6 | 7 | ### Options: 8 | - `-n id` - Specifies the peripheral number (ZynqMP has two peripherals: CAN0 and CAN1). 9 | - `-b baudrate` - Sets the baud rate in [kbps]. 10 | - `-h` - Displays the help menu. 11 | 12 | ### Example: 13 | The command `zynqmp-can -n 1 -b 125` initializes CAN1 with a baud rate of 125000 baud/s. 14 | 15 | ## Interface 16 | The server creates device files `/dev/can0` or `/dev/can1`. However, due to the relatively complex nature of CAN frames, these files cannot be accessed using standard open/close/read/write calls. Instead, a static library called `libzynqmp-can-if` is provided, which includes dedicated functions for interface users. 17 | 18 | ## Manual Test Application 19 | A test application named `zynqmp-can-test` is available to test the API functionality of this driver. 20 | -------------------------------------------------------------------------------- /multi/mcxn94x-multi/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * MCX N94x common 5 | * 6 | * Copyright 2017, 2018, 2024, 2025 Phoenix Systems 7 | * Author: Aleksander Kaminski, Hubert Buczynski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | #include "common.h" 18 | 19 | 20 | int common_setClock(int dev, int sel, int div, int enable) 21 | { 22 | int res; 23 | platformctl_t pctl; 24 | 25 | pctl.action = pctl_get; 26 | pctl.type = pctl_devclk; 27 | pctl.devClk.dev = dev; 28 | 29 | res = platformctl(&pctl); 30 | 31 | if (res != 0) { 32 | return res; 33 | } 34 | 35 | pctl.action = pctl_set; 36 | 37 | if (sel >= 0) { 38 | pctl.devClk.sel = (unsigned int)sel; 39 | } 40 | 41 | if (div >= 0) { 42 | pctl.devClk.div = (unsigned int)div; 43 | } 44 | 45 | if (enable >= 0) { 46 | pctl.devClk.enable = enable; 47 | } 48 | 49 | return platformctl(&pctl); 50 | } 51 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/libmulti/include/libmulti/libaes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Multidrv-lib: STM32L4 AES driver 5 | * 6 | * Copyright 2020 Phoenix Systems 7 | * Author: Daniel Sawka 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | 13 | #ifndef LIBAES_H_ 14 | #define LIBAES_H_ 15 | 16 | 17 | enum { aes_128 = 0, aes_256 = 1 }; 18 | 19 | 20 | enum { aes_ecb = 0, aes_cbc = 1, aes_ctr = 2 }; 21 | 22 | 23 | enum { aes_encrypt = 0, aes_decrypt = 2 }; 24 | 25 | 26 | void libaes_setKey(const unsigned char *key, int keylen); 27 | 28 | 29 | void libaes_getKey(unsigned char *key, int keylen); 30 | 31 | 32 | void libaes_setIv(const unsigned char *iv); 33 | 34 | 35 | void libaes_getIv(unsigned char *iv); 36 | 37 | 38 | void libaes_deriveDecryptionKey(void); 39 | 40 | 41 | void libaes_prepare(int mode, int dir); 42 | 43 | 44 | void libaes_unprepare(void); 45 | 46 | 47 | void libaes_processBlock(const unsigned char *in, unsigned char *out); 48 | 49 | 50 | int libaes_init(void); 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /multi/mcxn94x-multi/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * MCX N94x common 5 | * 6 | * Copyright 2017, 2018, 2024 Phoenix Systems 7 | * Author: Aleksander Kaminski, Hubert Buczynski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _COMMON_H_ 15 | #define _COMMON_H_ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | #define NELEMS(x) (sizeof(x) / sizeof(*(x))) 23 | 24 | 25 | #define ALIGN_ADDR(addr, align) ((align) ? (((addr) + ((align) - 1)) & ~((align) - 1)) : (addr)) 26 | 27 | 28 | static inline void common_dataBarrier(void) 29 | { 30 | __asm__ volatile ("dmb"); 31 | } 32 | 33 | 34 | static inline void common_dataSyncBarrier(void) 35 | { 36 | __asm__ volatile ("dsb"); 37 | } 38 | 39 | 40 | static inline void common_instrBarrier(void) 41 | { 42 | __asm__ volatile ("isb"); 43 | } 44 | 45 | 46 | int common_setClock(int dev, int sel, int div, int enable); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /sensors/gps/gps_sim.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Simsensor for gps sensors. Used in potential tests 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Piotr Nieciecki 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | 16 | #define GPS_SIMESENS_NAME "gps_sim" 17 | #define GPS_SIM_QLEN 10 18 | #define GPS_TIME_HORIZON 100000 19 | 20 | 21 | int gpssim_alloc(sensor_info_t *info, const char *args) 22 | { 23 | simsens_settings_t settings = { 24 | .name = GPS_SIMESENS_NAME, 25 | .messageQueueLen = GPS_SIM_QLEN, 26 | .sensorTypes = SENSOR_TYPE_GPS, 27 | .timeHorizon = GPS_TIME_HORIZON 28 | }; 29 | 30 | return simsens_alloc(info, args, &settings); 31 | } 32 | 33 | 34 | void __attribute__((constructor)) gpssim_register(void) 35 | { 36 | static sensor_drv_t sensor = { 37 | .name = GPS_SIMESENS_NAME, 38 | .alloc = gpssim_alloc, 39 | .start = simsens_start 40 | }; 41 | 42 | sensors_register(&sensor); 43 | } 44 | -------------------------------------------------------------------------------- /sensors/mag/mag_sim.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Simsensor for magnetometer sensors. Used in potential tests 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Piotr Nieciecki 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | 16 | #define MAG_SIMESENS_NAME "mag_sim" 17 | #define MAG_SIM_QLEN 10 18 | #define MAG_TIME_HORIZON 100000 19 | 20 | 21 | int magsim_alloc(sensor_info_t *info, const char *args) 22 | { 23 | simsens_settings_t settings = { 24 | .name = MAG_SIMESENS_NAME, 25 | .messageQueueLen = MAG_SIM_QLEN, 26 | .sensorTypes = SENSOR_TYPE_MAG, 27 | .timeHorizon = MAG_TIME_HORIZON 28 | }; 29 | 30 | return simsens_alloc(info, args, &settings); 31 | } 32 | 33 | 34 | void __attribute__((constructor)) magsim_register(void) 35 | { 36 | static sensor_drv_t sensor = { 37 | .name = MAG_SIMESENS_NAME, 38 | .alloc = magsim_alloc, 39 | .start = simsens_start 40 | }; 41 | 42 | sensors_register(&sensor); 43 | } 44 | -------------------------------------------------------------------------------- /storage/flashdrv/drv/grlib-ftmctrl/ftmctrl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB FTMCTRL Flash driver 5 | * 6 | * FTMCTRL routines 7 | * 8 | * Copyright 2023-2025 Phoenix Systems 9 | * Author: Lukasz Leczkowski 10 | * 11 | * This file is part of Phoenix-RTOS. 12 | * 13 | * %LICENSE% 14 | */ 15 | 16 | #ifndef _FTMCTRL_H_ 17 | #define _FTMCTRL_H_ 18 | 19 | 20 | #include 21 | 22 | 23 | static inline void ftmctrl_WrEn(volatile uint32_t *ftmctrl) 24 | { 25 | *ftmctrl |= (1 << 11); 26 | } 27 | 28 | 29 | static inline void ftmctrl_WrDis(volatile uint32_t *ftmctrl) 30 | { 31 | *ftmctrl &= ~(1 << 11); 32 | } 33 | 34 | 35 | static inline void ftmctrl_ioEn(volatile uint32_t *ftmctrl) 36 | { 37 | *ftmctrl |= (1 << 19); 38 | } 39 | 40 | 41 | static inline void ftmctrl_ioDis(volatile uint32_t *ftmctrl) 42 | { 43 | *ftmctrl &= ~(1 << 19); 44 | } 45 | 46 | 47 | static inline int ftmctrl_portWidth(volatile uint32_t *ftmctrl) 48 | { 49 | return (((*ftmctrl >> 8) & 0x3) == 0) ? 8 : 16; 50 | } 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /sensors/baro/baro_sim.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Simsensor for baro sensors. Used in potential tests 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Piotr Nieciecki 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | 16 | #define BARO_SIMESENS_NAME "baro_sim" 17 | #define BARO_SIM_QLEN 10 18 | #define BARO_TIME_HORIZON 100000 19 | 20 | 21 | int barosim_alloc(sensor_info_t *info, const char *args) 22 | { 23 | simsens_settings_t settings = { 24 | .name = BARO_SIMESENS_NAME, 25 | .messageQueueLen = BARO_SIM_QLEN, 26 | .sensorTypes = SENSOR_TYPE_BARO, 27 | .timeHorizon = BARO_TIME_HORIZON 28 | }; 29 | 30 | return simsens_alloc(info, args, &settings); 31 | } 32 | 33 | 34 | void __attribute__((constructor)) barosim_register(void) 35 | { 36 | static sensor_drv_t sensor = { 37 | .name = BARO_SIMESENS_NAME, 38 | .alloc = barosim_alloc, 39 | .start = simsens_start 40 | }; 41 | 42 | sensors_register(&sensor); 43 | } 44 | -------------------------------------------------------------------------------- /sensors/imu/imu_sim.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Simsensor for imu sensors. Used in potential tests 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Piotr Nieciecki 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | 16 | #define IMU_SIMESENS_NAME "imu_sim" 17 | #define IMU_SIM_QLEN 10 18 | #define IMU_TIME_HORIZON 100000 19 | 20 | 21 | int imusim_alloc(sensor_info_t *info, const char *args) 22 | { 23 | simsens_settings_t settings = { 24 | .name = IMU_SIMESENS_NAME, 25 | .messageQueueLen = IMU_SIM_QLEN, 26 | .sensorTypes = SENSOR_TYPE_ACCEL | SENSOR_TYPE_GYRO, 27 | .timeHorizon = IMU_TIME_HORIZON 28 | }; 29 | 30 | return simsens_alloc(info, args, &settings); 31 | } 32 | 33 | 34 | void __attribute__((constructor)) imusim_register(void) 35 | { 36 | static sensor_drv_t sensor = { 37 | .name = IMU_SIMESENS_NAME, 38 | .alloc = imusim_alloc, 39 | .start = simsens_start 40 | }; 41 | 42 | sensors_register(&sensor); 43 | } 44 | -------------------------------------------------------------------------------- /storage/zynq7000-sdcard/sdstorage_dev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * SD Card libstorage-based driver header file 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Jacek Maksymowicz 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _SDSTORAGE_DEV_H_ 15 | #define _SDSTORAGE_DEV_H_ 16 | 17 | #define DEVTYPE_POS (29) 18 | #define DEVTYPE_MASK (3 << DEVTYPE_POS) 19 | #define DEVTYPE_MTD (1 << DEVTYPE_POS) 20 | #define DEVTYPE_BLOCK (2 << DEVTYPE_POS) 21 | 22 | #define GET_STORAGE_ID(id) ((id) & ~DEVTYPE_MASK) 23 | #define IS_MTD_DEVICE_ID(id) (((id)&DEVTYPE_MTD) != 0) 24 | #define IS_BLOCK_DEVICE_ID(id) (((id)&DEVTYPE_BLOCK) != 0) 25 | 26 | 27 | int sdstorage_handleInsertion(unsigned int slot); 28 | 29 | 30 | int sdstorage_handleRemoval(unsigned int slot); 31 | 32 | 33 | int sdstorage_initHost(unsigned int slot); 34 | 35 | 36 | int sdstorage_runPresenceDetection(void); 37 | 38 | 39 | void sdstorage_setDefaultCachePolicy(int cachePolicy); 40 | 41 | #endif /* _SDSTORAGE_DEV_H_ */ 42 | -------------------------------------------------------------------------------- /i2c/common/i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef _PHOENIX_I2C_H 2 | #define _PHOENIX_I2C_H 3 | 4 | #include 5 | 6 | 7 | /* initialises peripheral, returns 0 on success <0 on error */ 8 | extern int i2c_init(unsigned int dev_no); 9 | 10 | 11 | /* below read/write operations return: 12 | * 0 -> success 13 | * -EBUSY -> bus is busy (multimaster mode) 14 | * -ETIMEDOUT -> timed out waiting for the transfer to succeed 15 | * -EIO -> transfer was not ACKed by the slave device (eg. invalid dev_addr) 16 | */ 17 | 18 | 19 | /* Performs i2c generic write operation to the given slave device. */ 20 | extern int i2c_busWrite(uint8_t dev_addr, const uint8_t *data, uint32_t len); 21 | 22 | 23 | /* Performs i2c generic read operation from the given slave device. */ 24 | extern int i2c_busRead(uint8_t dev_addr, uint8_t *data_out, uint32_t len); 25 | 26 | 27 | /* Performs i2c regiester read operation from the given slave device */ 28 | extern int i2c_regRead(uint8_t dev_addr, uint8_t reg_addr, uint8_t *data_out, uint32_t len); 29 | 30 | #endif /* _PHOENIX_I2C_H */ 31 | -------------------------------------------------------------------------------- /sensors/server-include/libsensors/local/sensors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Sensor Manager local implementation 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Mateusz Niewiadomski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _SENSORS_LOCAL_H 16 | #define _SENSORS_LOCAL_H 17 | 18 | #include 19 | 20 | 21 | /** 22 | * Finds a driver specified by `name`. Returns NULL if not found. 23 | */ 24 | const sensor_drv_t *locsensors_find(const char *name); 25 | 26 | 27 | /** 28 | * Function registers "drv" as local driver. 29 | * 30 | * Not meant to be used by application 31 | */ 32 | void locsensors_register(const sensor_drv_t *drv); 33 | 34 | 35 | /** 36 | * Function digests `event` from an `devId` sensor. 37 | * Function meant to be used as remapping from generic "sensor_register()" 38 | * 39 | * #TODO: This function is stub-implemented, no publishig is done! 40 | */ 41 | int locsensors_publish(unsigned int devId, const sensor_event_t *event); 42 | 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /storage/zynq-flash/flashdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Zynq-7000 nor flash driver 5 | * 6 | * Copyright 2021, 2022 Phoenix Systems 7 | * Author: Hubert Buczynski, Malgorzata Wrobel 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _FLASH_DRIVER_H_ 15 | #define _FLASH_DRIVER_H_ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | /* Storage device context definition */ 22 | typedef struct _storage_devCtx_t { 23 | unsigned int id; /* flash device memory id */ 24 | } storage_devCtx_t; 25 | 26 | 27 | /* Clean up flash memory driver, returns 0 on success <0 on error */ 28 | extern int flashdrv_done(storage_t *strg); 29 | 30 | 31 | /* Initialize only a one physicall flash memory via qspi interface, returns: 32 | * - >0 - number of remaining logic devices for initialization (in case where there are multiple regions) 33 | * - <0 - on error 34 | * - 0 - all logic devices are initialized 35 | */ 36 | extern int flashdrv_init(storage_t *strg); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /can/zynqmp-can/zynqmp-can-priv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * ZynqMP CAN driver interface library 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Dariusz Sabala 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | #ifndef ZYNQMP_CAN_PRIV_H 13 | #define ZYNQMP_CAN_PRIV_H 14 | 15 | #include 16 | 17 | /* Marker used in messages between the application and the server to distinguish operations */ 18 | typedef enum { 19 | zynqmp_canOpSend = 0, /**< Send CAN frames */ 20 | zynqmp_canOpRecv = 1, /**< Receive CAN frames */ 21 | } zynqmp_canDriverOpCode; 22 | 23 | /* Information passed to the driver as a request */ 24 | typedef struct { 25 | uint8_t operation; /**< Operation code (see zynqmp_canDriverOpCode) */ 26 | uint8_t block; /**< Boolean switch to enable or disable blocking behaviour */ 27 | uint32_t timeoutUs; /**< Timeout for the operation [microseconds] */ 28 | } zynqmp_canDriverReq; 29 | 30 | /* Information returned by the driver */ 31 | typedef struct { 32 | uint32_t framesReceivedSend; /**< Number of frames received or sent */ 33 | } zynqmp_canDriverResp; 34 | 35 | #endif /* ZYNQMP_CAN_PRIV_H */ 36 | -------------------------------------------------------------------------------- /adc/ade7913/adc-api-ade7913.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * ADE7913 driver API 5 | * 6 | * Copyright 2021-2024 Phoenix Systems 7 | * Author: Marcin Baran, Gerard Swiderski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef ADC_API_H 15 | #define ADC_API_H 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | #define ADC_DEVICE_FILE_NAME "/dev/ade7913" 23 | 24 | 25 | typedef struct { 26 | enum { 27 | ade7913_dev_ctl__enable = 0, 28 | ade7913_dev_ctl__disable, 29 | ade7913_dev_ctl__reset, 30 | ade7913_dev_ctl__status, 31 | ade7913_dev_ctl__set_config, 32 | ade7913_dev_ctl__get_config, 33 | ade7913_dev_ctl__get_buffers, 34 | ade7913_dev_ctl__pwr_off, 35 | ade7913_dev_ctl__pwr_on, 36 | } type; 37 | 38 | union { 39 | /* buffers */ 40 | struct { 41 | addr_t paddr; 42 | size_t num; 43 | size_t size; 44 | } buffers; 45 | 46 | /* config */ 47 | struct { 48 | uint32_t sampling_rate; 49 | uint8_t devices; 50 | uint8_t bits; 51 | } config; 52 | }; 53 | } ade7913_dev_ctl_t; 54 | 55 | 56 | #endif /* ADC_API_H */ 57 | -------------------------------------------------------------------------------- /gpio/zynq-pwm/ip/README.md: -------------------------------------------------------------------------------- 1 | # PWM8X IP core 2 | This IP core provides 8 PWM channels. AXI Lite interface is used. 3 | 4 | ## Functional description 5 | 32-bit forward counter is incremented on each AXI clock cycle. When counter reaches `reload` value (register #9) it value is reset to zero. Each PWM channel has `compare value` register. PWM output is high, when `compare value` is greater then current `counter` value, otherwise output is set low. Output is synchronized to AXI clock, so it's glitch free. Each `compare value` register is buffered - it's new value is taken into account only on `counter` reset. 6 | 7 | ## Registers description 8 | All registers are 32-bit wide, only 32-bit access is supported 9 | - base + 0x00: PWM channel 0 compare value 10 | - base + 0x04: PWM channel 1 compare value 11 | - base + 0x08: PWM channel 2 compare value 12 | - base + 0x0A: PWM channel 3 compare value 13 | - base + 0x0C: PWM channel 4 compare value 14 | - base + 0x10: PWM channel 5 compare value 15 | - base + 0x14: PWM channel 6 compare value 16 | - base + 0x18: PWM channel 7 compare value 17 | - base + 0x1C: PWM channel 8 compare value 18 | - base + 0x20: PWM counter reload value 19 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/libmulti/include/libmulti/libi2c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Multidrv-lib: STM32L4 I2C driver 5 | * 6 | * Copyright 2020 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef LIBI2C_H_ 16 | #define LIBI2C_H_ 17 | 18 | #include 19 | #include 20 | 21 | 22 | typedef struct { 23 | volatile unsigned int *base; 24 | volatile int err; 25 | int clk; 26 | 27 | handle_t irqlock; 28 | handle_t irqcond; 29 | } libi2c_ctx_t; 30 | 31 | 32 | enum { i2c1 = 0, i2c2, i2c3, i2c4 }; 33 | 34 | 35 | ssize_t libi2c_read(libi2c_ctx_t *ctx, unsigned char addr, void *buff, size_t len); 36 | 37 | 38 | ssize_t libi2c_readReg(libi2c_ctx_t *ctx, unsigned char addr, unsigned char reg, void *buff, size_t len); 39 | 40 | 41 | ssize_t libi2c_write(libi2c_ctx_t *ctx, unsigned char addr, const void *buff, size_t len); 42 | 43 | 44 | ssize_t libi2c_writeReg(libi2c_ctx_t *ctx, unsigned char addr, unsigned char reg, const void *buff, size_t len); 45 | 46 | 47 | int libi2c_init(libi2c_ctx_t *ctx, int i2c); 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /storage/flashdrv/drv/grlib-spimctrl/spimctrl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB SPIMCTRL driver 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _SPIMCTRL_H_ 15 | #define _SPIMCTRL_H_ 16 | 17 | #include 18 | #include 19 | 20 | 21 | struct spimctrl { 22 | volatile uint32_t *base; 23 | 24 | uint8_t ear; 25 | }; 26 | 27 | 28 | struct xferOp { 29 | /* clang-format off */ 30 | enum { xfer_opRead = 0, xfer_opWrite } type; 31 | /* clang-format on */ 32 | const uint8_t *cmd; 33 | size_t cmdLen; 34 | union { 35 | const uint8_t *txData; 36 | uint8_t *rxData; 37 | }; 38 | size_t dataLen; 39 | }; 40 | 41 | 42 | /* Execute a transfer through spimctrl */ 43 | int spimctrl_xfer(const struct spimctrl *spimctrl, struct xferOp *op); 44 | 45 | 46 | /* Reset spimctrl core */ 47 | void spimctrl_reset(const struct spimctrl *spimctrl); 48 | 49 | 50 | /* Initialize spimctrl instance */ 51 | int spimctrl_init(struct spimctrl *spimctrl, addr_t mctrlBase); 52 | 53 | 54 | void spimctrl_destroy(struct spimctrl *spimctrl); 55 | 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /usb/libusbclient/imx6ull-usbc/phy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * usbclient - usb device controller driver 5 | * 6 | * Copyright 2020-2021 Phoenix Systems 7 | * Author: Hubert Buczynski, Gerard Swiderski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | 16 | #include "../imx-usbc/phy.h" 17 | 18 | #define USB_BASE_ADDR 0x02184000 19 | 20 | 21 | /* TODO: It should be moved into imx-usbc. */ 22 | void *usbclient_allocBuff(uint32_t size) 23 | { 24 | return mmap(NULL, size, PROT_WRITE | PROT_READ, MAP_UNCACHED | MAP_ANONYMOUS, -1, 0); 25 | } 26 | 27 | 28 | /* TODO: It should be moved into imx-usbc. */ 29 | void usbclient_buffDestory(void *addrs, uint32_t size) 30 | { 31 | munmap(addrs, size); 32 | } 33 | 34 | 35 | void phy_setClock(void) 36 | { 37 | 38 | } 39 | 40 | 41 | void *phy_getBase(uint32_t size) 42 | { 43 | return mmap(NULL, size, PROT_WRITE | PROT_READ, MAP_DEVICE | MAP_PHYSMEM | MAP_ANONYMOUS, -1, USB_BASE_ADDR); 44 | } 45 | 46 | 47 | uint32_t phy_getIrq(void) 48 | { 49 | return 75; 50 | } 51 | 52 | 53 | void phy_reset(void) 54 | { 55 | 56 | } 57 | 58 | 59 | void phy_init(void) 60 | { 61 | 62 | } 63 | -------------------------------------------------------------------------------- /pcie/server/pcie.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * PCI Express driver server 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Dariusz Sabala 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | #ifndef PCIE_H_ 13 | #define PCIE_H_ 14 | 15 | #include 16 | 17 | 18 | #define UPPER_32_BITS(n) ((uint32_t)(((n) >> 16) >> 16)) 19 | #define LOWER_32_BITS(n) ((uint32_t)((n) & 0xffffffff)) 20 | 21 | 22 | /* ECAM commands */ 23 | #define PCI_CMD_IO_ENABLE 0x01 24 | #define PCI_CMD_MEM_ENABLE 0x02 25 | #define PCI_CMD_MASTER_ENABLE 0x04 26 | #define PCI_CMD_PARITY_ERR_ENABLE 0x40 27 | #define PCI_CMD_SERR_ERR_ENABLE 0x100 28 | 29 | 30 | static inline uint32_t readReg(uint32_t *base, uint32_t offset) 31 | { 32 | return *((volatile uint32_t *)((char *)base + offset)); 33 | } 34 | 35 | 36 | static inline void writeReg(uint32_t *base, uint32_t offset, uint32_t value) 37 | { 38 | *((volatile uint32_t *)((char *)base + offset)) = value; 39 | } 40 | 41 | 42 | static inline void writeRegMsk(uint32_t *base, uint32_t offset, uint32_t clr, uint32_t set) 43 | { 44 | uint32_t value = readReg(base, offset); 45 | value &= ~clr; 46 | value |= set; 47 | writeReg(base, offset, value); 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/libmulti/include/libmulti/libhash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Multidrv-lib: STM32L4 HASH driver 5 | * 6 | * Copyright 2022 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef LIBHASH_H_ 15 | #define LIBHASH_H_ 16 | 17 | #include 18 | #include 19 | 20 | #define LIBHASH_MD5_DIGESTSZ (128 / 8) 21 | #define LIBHASH_SHA1_DIGESTSZ (160 / 8) 22 | #define LIBHASH_SHA224_DIGESTSZ (224 / 8) 23 | #define LIBHASH_SHA256_DIGESTSZ (256 / 8) 24 | #define LIBHASH_SHA384_DIGESTSZ (384 / 8) 25 | #define LIBHASH_SHA512_224_DIGESTSZ (224 / 8) 26 | #define LIBHASH_SHA512_256_DIGESTSZ (256 / 8) 27 | #define LIBHASH_SHA512_DIGESTSZ (512 / 8) 28 | 29 | typedef enum { 30 | libhash_sha1, 31 | libhash_sha224, 32 | libhash_sha256, 33 | libhash_md5, 34 | libhash_sha384, 35 | libhash_sha512_224, 36 | libhash_sha512_256, 37 | libhash_sha512, 38 | } libhash_algo_t; 39 | 40 | int libhash_start(libhash_algo_t algorithm); 41 | 42 | 43 | ssize_t libhash_feed(const void *buff, size_t size); 44 | 45 | 46 | ssize_t libhash_finish(uint8_t *digest); 47 | 48 | 49 | int libhash_init(void); 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /storage/gr716-flash/nor/nor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GR716 flash driver 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _NOR_H_ 15 | #define _NOR_H_ 16 | 17 | #include "../spimctrl.h" 18 | 19 | #define NOR_ERASED_STATE 0xff 20 | #define NOR_SECTORSZ_MAX 0x1000 21 | #define NOR_PAGESZ_MAX 0x100 22 | 23 | 24 | struct nor_info { 25 | uint32_t jedecId; 26 | const char *name; 27 | size_t totalSz; 28 | size_t pageSz; 29 | size_t sectorSz; 30 | time_t tPP; 31 | time_t tSE; 32 | time_t tCE; 33 | }; 34 | 35 | 36 | extern int nor_waitBusy(spimctrl_t *spimctrl, time_t timeout); 37 | 38 | 39 | extern int nor_eraseChip(spimctrl_t *spimctrl, time_t timeout); 40 | 41 | 42 | extern int nor_eraseSector(spimctrl_t *spimctrl, addr_t addr, time_t timeout); 43 | 44 | 45 | extern int nor_pageProgram(spimctrl_t *spimctrl, addr_t addr, const void *src, size_t len, time_t timeout); 46 | 47 | 48 | extern ssize_t nor_readData(spimctrl_t *spimctrl, addr_t addr, void *buff, size_t len); 49 | 50 | 51 | extern int nor_probe(spimctrl_t *spimctrl, const struct nor_info **nor, const char **pVendor); 52 | 53 | 54 | #endif /* _NOR_H_ */ 55 | -------------------------------------------------------------------------------- /dma/imx6ull-sdma/sdma.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX 6ULL SDMA lib 5 | * 6 | * Copyright 2018 Phoenix Systems 7 | * Author: Krystian Wasik 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef IMX6ULL_SDMA_LIB_H 15 | #define IMX6ULL_SDMA_LIB_H 16 | 17 | #include "sdma-api.h" 18 | 19 | typedef struct { 20 | oid_t oid; 21 | } sdma_t; 22 | 23 | int sdma_open(sdma_t *s, const char *dev_name); 24 | int sdma_close(sdma_t *s); 25 | 26 | int sdma_channel_configure(sdma_t *s, sdma_channel_config_t *cfg); 27 | 28 | int sdma_data_mem_write(sdma_t *s, void *data, size_t size, addr_t addr); 29 | int sdma_data_mem_read(sdma_t *s, void *data, size_t size, addr_t addr); 30 | 31 | int sdma_context_dump(sdma_t *s, sdma_context_t *ctx); 32 | int sdma_context_set(sdma_t *s, const sdma_context_t *ctx); 33 | 34 | int sdma_enable(sdma_t *s); 35 | int sdma_disable(sdma_t *s); 36 | int sdma_trigger(sdma_t *s); 37 | 38 | /* cnt - number of interrupts for this channel registered up until this point */ 39 | int sdma_wait_for_intr(sdma_t *s, uint32_t *cnt); 40 | 41 | void *sdma_alloc_uncached(sdma_t *s, size_t size, addr_t *paddr, int ocram); 42 | int sdma_free_uncached(void *vaddr, size_t size); 43 | 44 | #endif /* IMX6ULL_SDMA_LIB_H */ 45 | -------------------------------------------------------------------------------- /storage/pc-ata/mbr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Master Boot Record 5 | * 6 | * Copyright 2017, 2020 Phoenix Systems 7 | * Author: Kamil Amanowicz, Lukasz Kosinski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _MBR_H_ 15 | #define _MBR_H_ 16 | 17 | #include 18 | 19 | #include "ata.h" 20 | 21 | 22 | /* Misc definitions */ 23 | #define MBR_MAGIC 0xaa55 24 | 25 | 26 | /* Partition types */ 27 | enum { 28 | PENTRY_LINUX = 0x83, /* Any native Linux partition */ 29 | PENTRY_PROTECTIVE = 0xee /* Protective MBR mode for GPT partition table */ 30 | }; 31 | 32 | 33 | typedef struct { 34 | uint8_t status; /* Partition status */ 35 | uint8_t first[3]; /* First sector (CHS) */ 36 | uint8_t type; /* Partition type */ 37 | uint8_t last[3]; /* Last sector (CHS) */ 38 | uint32_t start; /* Partition start (LBA) */ 39 | uint32_t sectors; /* Number of sectors */ 40 | } __attribute__((packed)) pentry_t; 41 | 42 | 43 | typedef struct { 44 | char bca[446]; /* Bootstrap Code Area */ 45 | pentry_t pent[4]; /* Partition entries */ 46 | uint16_t magic; /* MBR magic */ 47 | } __attribute__((packed)) mbr_t; 48 | 49 | 50 | /* Reads MBR */ 51 | int mbr_read(ata_dev_t *dev, mbr_t *mbr); 52 | 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /multi/imxrt-multi/cm4/lib/interrupt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT117x Cortex-M4 interrupt dispatcher 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | #include "interrupt.h" 16 | #include "cm4.h" 17 | 18 | #define SIZE_HANDLERS 4 19 | 20 | /* .bss, doesn't need init */ 21 | static void (*callbacks[SIZE_INTERRUPTS][SIZE_HANDLERS])(int n); 22 | 23 | 24 | void interrupt_dispatch(int n) 25 | { 26 | int i; 27 | 28 | n -= 16; 29 | 30 | for (i = 0; i < SIZE_HANDLERS; ++i) { 31 | if (callbacks[n][i] != NULL) 32 | callbacks[n][i](n); 33 | else 34 | break; 35 | } 36 | } 37 | 38 | 39 | int interrupt_register(int which, void (*callback)(int n), int priority) 40 | { 41 | int i; 42 | 43 | which -= 16; 44 | 45 | if (which < 0 || which > SIZE_INTERRUPTS || priority > 15) 46 | return -1; 47 | 48 | for (i = 0; i < SIZE_HANDLERS; ++i) { 49 | if (callbacks[which][i] == NULL) 50 | break; 51 | } 52 | 53 | if (i >= SIZE_HANDLERS) 54 | return -1; 55 | 56 | callbacks[which][i] = callback; 57 | 58 | if (priority >= 0) 59 | cm4_nvicSetPriority(which, priority); 60 | 61 | cm4_nvicSetIRQ(which, 1); 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /sensors/locsensor.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Sensor Manager local implementation 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Mateusz Niewiadomski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef SENSORS_MAX 16 | #define SENSORS_MAX 8 17 | #endif 18 | 19 | #define ERRSTR "locsensors" 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | 27 | struct { 28 | /* sensor auto-registration storage */ 29 | const sensor_drv_t *drv[SENSORS_MAX]; 30 | int ndrv; 31 | } locsensors_common; 32 | 33 | 34 | const sensor_drv_t *locsensors_find(const char *name) 35 | { 36 | for (int i = 0; i < locsensors_common.ndrv; i++) { 37 | if (strcmp(locsensors_common.drv[i]->name, name) == 0) { 38 | return locsensors_common.drv[i]; 39 | } 40 | } 41 | 42 | return NULL; 43 | } 44 | 45 | 46 | void locsensors_register(const sensor_drv_t *drv) 47 | { 48 | if (locsensors_common.ndrv >= SENSORS_MAX) { 49 | printf("locsensors: no register space: %s\n", drv->name); 50 | return; 51 | } 52 | 53 | locsensors_common.drv[locsensors_common.ndrv++] = drv; 54 | } 55 | 56 | 57 | int locsensors_publish(unsigned int devId, const sensor_event_t *event) 58 | { 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /storage/imx6ull-flashnor/imx6ull-flashnor-drv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX 6ULL ECSPI NOR flash driver 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Hubert Badocha 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _FLASHNOR_DRV_H_ 15 | #define _FLASHNOR_DRV_H_ 16 | 17 | #include 18 | #include 19 | 20 | 21 | typedef struct { 22 | ssize_t (*read)(int ndev, off_t offs, void *buff, size_t bufflen); 23 | ssize_t (*write)(int ndev, off_t offs, const void *buff, size_t bufflen); 24 | int (*erase)(int ndev, off_t offs, size_t size); 25 | } flashnor_ops_t; 26 | 27 | 28 | /* information about NOR flash configuration */ 29 | typedef struct { 30 | const char *name; 31 | size_t size; /* total NOR size in bytes */ 32 | size_t writeBuffsz; /* write page size in bytes */ 33 | size_t erasesz; /* erase block size in bytes (multiple of writesize) */ 34 | } flashnor_devInfo_t; 35 | 36 | 37 | typedef struct { 38 | const flashnor_devInfo_t *devInfo; 39 | const flashnor_ops_t *ops; 40 | int ndev; 41 | } flashnor_info_t; 42 | 43 | 44 | extern void flashnor_drvDone(storage_t *storage); 45 | 46 | 47 | extern int flashnor_drvInit(const flashnor_info_t *info, storage_t *storage); 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /adc/ade7913/gpio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Helper gpio functions 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Marcin Baran 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | 16 | #include "gpio.h" 17 | 18 | 19 | void gpio_setPin(oid_t *device, int gpio, int pin, int state) 20 | { 21 | msg_t msg; 22 | multi_i_t *imsg = NULL; 23 | 24 | msg.type = mtDevCtl; 25 | msg.i.data = NULL; 26 | msg.i.size = 0; 27 | msg.o.data = NULL; 28 | msg.o.size = 0; 29 | msg.oid.id = gpio; 30 | msg.oid.port = device->port; 31 | 32 | imsg = (multi_i_t *)msg.i.raw; 33 | 34 | imsg->gpio.type = gpio_set_port; 35 | imsg->gpio.port.val = !!state << pin; 36 | imsg->gpio.port.mask = 1 << pin; 37 | 38 | msgSend(device->port, &msg); 39 | } 40 | 41 | 42 | void gpio_setDir(oid_t *device, int gpio, int pin, int dir) 43 | { 44 | msg_t msg; 45 | multi_i_t *imsg = NULL; 46 | 47 | msg.type = mtDevCtl; 48 | msg.i.data = NULL; 49 | msg.i.size = 0; 50 | msg.o.data = NULL; 51 | msg.o.size = 0; 52 | msg.oid.id = gpio; 53 | msg.oid.port = device->port; 54 | 55 | imsg = (multi_i_t *)msg.i.raw; 56 | 57 | imsg->gpio.type = gpio_set_dir; 58 | imsg->gpio.dir.val = !!dir << pin; 59 | imsg->gpio.dir.mask = 1 << pin; 60 | 61 | msgSend(device->port, &msg); 62 | } -------------------------------------------------------------------------------- /storage/zynq-flash/qspi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Zynq-7000 Quad-SPI Controller driver 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Hubert Buczynski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _QUAD_SPI_H_ 16 | #define _QUAD_SPI_H_ 17 | 18 | #include 19 | #include 20 | 21 | 22 | /* NOTE: All synchronization and exclusion must be done externally. */ 23 | 24 | 25 | /* Transmit and receive number of data defines in 'size'. If TX Buff is empty, the dummy words are sent, 26 | * otherwise txBuff data is sent, returns EOK on success or <0 on error */ 27 | extern ssize_t qspi_transfer(const uint8_t *txBuff, uint8_t *rxBuff, size_t size, time_t timeout); 28 | 29 | 30 | /* Raise CS down, enable controller */ 31 | extern void qspi_start(void); 32 | 33 | 34 | /* Clean up RX fifo, raise CS high and disable controller */ 35 | extern void qspi_stop(void); 36 | 37 | 38 | /* Switch off clocks and qspi controller */ 39 | extern int qspi_deinit(void); 40 | 41 | 42 | /* Initialize controller: 43 | * - I/O mode and manual mode, 44 | * - little endian 45 | * - src clk = 200 MHz, qspi clk = 100 MHz or 50 MHz if Feedback Clock (QSPI_FCLK < 0) pin is not used. 46 | * returns EOK on success <0 on error */ 47 | extern int qspi_init(void); 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /storage/umass/scsi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * USB Mass Storage class driver 5 | * 6 | * SCSI transparent command set definitions header 7 | * 8 | * Copyright 2024 Phoenix Systems 9 | * Author: Adam Greloch 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _SCSI_H_ 16 | #define _SCSI_H_ 17 | 18 | #include 19 | 20 | 21 | /* Opcodes */ 22 | #define SCSI_REQUEST_SENSE 0x03 23 | #define SCSI_INQUIRY 0x12 24 | 25 | 26 | typedef struct { 27 | uint8_t opcode; 28 | uint8_t action_misc0; /* [8:3] action, [3:0] misc0 */ 29 | uint32_t lba; 30 | uint8_t misc1; 31 | uint16_t length; 32 | uint8_t control; 33 | } __attribute__((packed)) scsi_cdb10_t; 34 | 35 | 36 | typedef struct { 37 | uint8_t opcode; 38 | uint8_t misc0[3]; 39 | uint8_t length; 40 | uint8_t control; 41 | } __attribute__((packed)) scsi_cdb6_t; 42 | 43 | 44 | typedef struct { 45 | uint8_t errorcode; 46 | uint8_t segnum; 47 | uint8_t misc0_sensekey; /* [8:4] misc0, [4:0] sensekey */ 48 | uint8_t misc[17]; 49 | } __attribute__((packed)) scsi_sense_t; 50 | 51 | 52 | typedef struct { 53 | uint8_t qualifier_devicetype; /* [8:5] qualifier, [5:0] devicetype */ 54 | uint8_t misc0; 55 | uint8_t version; 56 | uint8_t misc1[5]; 57 | char vendorid[8]; 58 | char productid[16]; 59 | uint8_t misc[4]; 60 | } __attribute__((packed)) scsi_inquiry_t; 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /storage/gr716-flash/flashdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GR716 Flash driver 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _GR716_FLASH_H_ 15 | #define _GR716_FLASH_H_ 16 | 17 | #include 18 | #include 19 | 20 | #include "spimctrl.h" 21 | #include "nor/nor.h" 22 | 23 | 24 | typedef struct { 25 | const char *vendor; 26 | const struct nor_info *properties; 27 | spimctrl_t spimctrl; 28 | uint8_t port; 29 | 30 | uint32_t address; 31 | uint32_t instance; 32 | 33 | addr_t sectorBufAddr; 34 | uint8_t sectorBufDirty; 35 | uint8_t *sectorBuf; 36 | } flash_context_t; 37 | 38 | 39 | ssize_t flash_readData(flash_context_t *ctx, addr_t offs, void *buff, size_t len); 40 | 41 | 42 | ssize_t flash_directWrite(flash_context_t *ctx, addr_t offs, const void *buff, size_t len); 43 | 44 | 45 | ssize_t flash_bufferedWrite(flash_context_t *ctx, addr_t offs, const void *buff, size_t len); 46 | 47 | 48 | int flash_sync(flash_context_t *ctx); 49 | 50 | 51 | int flash_sectorErase(flash_context_t *ctx, addr_t offs); 52 | 53 | 54 | int flash_chipErase(flash_context_t *ctx); 55 | 56 | 57 | int flash_init(flash_context_t *ctx, int instance); 58 | 59 | 60 | void flash_contextDestroy(flash_context_t *ctx); 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /storage/zynq7000-sdcard/zynq7000-sdio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Zynq-7000 SDIO peripheral initialization header 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Jacek Maksymowicz 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _ZYNQ7000_SDIO_H_ 15 | #define _ZYNQ7000_SDIO_H_ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | /* Number of SD Host Controllers available. */ 22 | #define PLATFORM_SDIO_N_HOSTS 1 23 | 24 | /* Structure with platform-specific information that the SD Host Controller may need */ 25 | typedef struct { 26 | /* Frequency of reference clock that was selected (Hz) */ 27 | uint32_t refclkFrequency; 28 | /* Physical address of the SD Host Controller register bank */ 29 | addr_t regBankPhys; 30 | /* Number of the interrupt that will be used by this controller */ 31 | int interruptNum; 32 | /* Does this slot have a physical Card Detect switch connected */ 33 | bool isCDPinSupported; 34 | /* Does this slot have a physical Write Protect switch connected */ 35 | bool isWPPinSupported; 36 | } sdio_platformInfo_t; 37 | 38 | 39 | static inline void sdio_dataBarrier(void) 40 | { 41 | __asm__ volatile("dmb"); 42 | } 43 | 44 | 45 | int sdio_platformConfigure(unsigned int slot, sdio_platformInfo_t *infoOut); 46 | 47 | #endif /* _ZYNQ7000_SDIO_H_ */ 48 | -------------------------------------------------------------------------------- /tty/uart16550/uart16550.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * UART 16550 device driver 5 | * 6 | * Copyright 2012-2015, 2020-2022 Phoenix Systems 7 | * Copyright 2001, 2005, 2008 Pawel Pisarczyk 8 | * Author: Pawel Pisarczyk, Pawel Kolodziej 9 | * 10 | * This file is part of Phoenix-RTOS. 11 | * 12 | * %LICENSE% 13 | */ 14 | 15 | #ifndef _DEV_SERIAL_H_ 16 | #define _DEV_SERIAL_H_ 17 | 18 | 19 | /* UART registers */ 20 | #define REG_RBR 0 21 | #define REG_THR 0 22 | #define REG_IMR 1 23 | #define REG_IIR 2 24 | #define REG_LCR 3 25 | #define REG_MCR 4 26 | #define REG_LSR 5 27 | #define REG_MSR 6 28 | #define REG_ADR 7 29 | #define REG_LSB 0 30 | #define REG_MSB 1 31 | #define REG_FCR 2 32 | 33 | 34 | /* Register bits */ 35 | #define IMR_THRE 0x02 36 | #define IMR_DR 0x01 37 | 38 | #define IIR_IRQPEND 0x01 39 | #define IIR_CODE_MS 0x00 /* Modem Status */ 40 | #define IIR_CODE_THRE 0x01 /* Transmitter Holding Register Empty */ 41 | #define IIR_CODE_DR 0x02 /* Received Data Ready */ 42 | #define IIR_CODE_LS 0x03 /* Receiver Line Status */ 43 | #define IIR_CODE_RTO 0x06 /* Reception Timeout */ 44 | 45 | #define LCR_DLAB 0x80 46 | #define LCR_D8N1 0x03 47 | #define LCR_D8N2 0x07 48 | 49 | #define MCR_OUT2 0x08 50 | #define MCR_OUT1 0x04 51 | #define MCR_RTS 0x02 52 | #define MCR_DTR 0x01 53 | 54 | #define LSR_DR 0x01 55 | #define LSR_THRE 0x20 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /spi/imx6ull-qspi/include/imx6ull-qspi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * imx6ull QSPI Controller driver 5 | * 6 | * Copyright 2021-2023 Phoenix Systems 7 | * Author: Gerard Swiderski, Hubert Badocha 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _QSPI_H_ 16 | #define _QSPI_H_ 17 | 18 | #include 19 | 20 | #define QSPI_PORTS 4 21 | 22 | #define QSPI_RXBUFSIZE 128u 23 | 24 | 25 | /* Use to enable particular slave buses of QSPI controller (slPortMask) */ 26 | enum { qspi_slBusA1 = 0x1, 27 | qspi_slBusA2 = 0x2, 28 | qspi_slBusB1 = 0x4, 29 | qspi_slBusB2 = 0x8 }; 30 | 31 | 32 | typedef struct { 33 | volatile uint32_t *base; 34 | uint8_t *ahbBase; 35 | addr_t ahbAddr; 36 | uint8_t slPortMask; 37 | size_t slFlashSz[4]; 38 | } qspi_t; 39 | 40 | 41 | struct xferOp { 42 | enum { xfer_opCommand = 0, 43 | xfer_opRead, 44 | xfer_opWrite } op; 45 | time_t timeout; 46 | uint32_t addr; 47 | uint8_t port; 48 | uint8_t seqIdx; 49 | union { 50 | struct { 51 | void *ptr; 52 | size_t sz; 53 | } read; 54 | struct { 55 | const void *ptr; 56 | size_t sz; 57 | } write; 58 | uint8_t command; 59 | } data; 60 | }; 61 | 62 | 63 | /* Execute a transfer using lookup table of QSPI sequences */ 64 | extern ssize_t qspi_xferExec(qspi_t *qspi, struct xferOp *xfer); 65 | 66 | 67 | extern int qspi_init(qspi_t *qspi_t); 68 | 69 | 70 | #endif /* _QSPI_H_ */ 71 | -------------------------------------------------------------------------------- /adc/ad7779/ad7779-low.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * AD7779 components API 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * 8 | * This file is part of Phoenix-RTOS. 9 | * 10 | * %LICENSE% 11 | */ 12 | 13 | #ifndef AD7779_LOW_H 14 | #define AD7779_LOW_H 15 | 16 | /* For now most of the drivers do not have common api. 17 | This set of functions represents abstraction layer for targets 18 | and must be implemented by the user */ 19 | 20 | /* DMA api */ 21 | int dma_init(size_t size, size_t count, addr_t *phys_addr); 22 | 23 | 24 | int dma_reset(void); 25 | 26 | 27 | void dma_free(void); 28 | 29 | 30 | void dma_enable(void); 31 | 32 | 33 | void dma_disable(void); 34 | 35 | 36 | /* dma_read in most cases is used to read an interrupt counter (and to wait for the interrupt) */ 37 | int dma_read(void *data, size_t len); 38 | 39 | 40 | /* SAI api */ 41 | int sai_init(void); 42 | 43 | 44 | void sai_free(void); 45 | 46 | 47 | void sai_rx_enable(void); 48 | 49 | 50 | void sai_rx_disable(void); 51 | 52 | 53 | addr_t sai_fifo_rx_ptr(void); 54 | 55 | 56 | uint32_t sai_fifo_watermark(void); 57 | 58 | 59 | /* SPI api */ 60 | int spi_exchange(uint8_t *buff, uint8_t len); 61 | 62 | 63 | int spi_init(void); 64 | 65 | 66 | /* GPIO api */ 67 | typedef enum { 68 | start, 69 | reset, 70 | hardreset 71 | } ad7779_gpio_t; 72 | 73 | 74 | int ad7779_gpio(ad7779_gpio_t gpio, int state); 75 | 76 | 77 | int ad7779_gpio_init(void); 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /tty/pc-tty/event_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Simple circular buffer for enqueueing PS/2 events 5 | * 6 | * Copyright 2024 Phoenix Systems 7 | * Author: Adam Greloch 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _EVENT_QUEUE_H_ 16 | #define _EVENT_QUEUE_H_ 17 | 18 | #include 19 | 20 | #define TTYPC_EQBUF_SIZE 256u 21 | 22 | typedef struct _event_queue_t { 23 | unsigned char buf[TTYPC_EQBUF_SIZE]; 24 | unsigned int cnt; 25 | unsigned int r; 26 | unsigned int w; 27 | handle_t mutex; 28 | handle_t waitq; 29 | } event_queue_t; 30 | 31 | 32 | /* Initializes event queue */ 33 | extern int event_queue_init(event_queue_t *eq); 34 | 35 | 36 | /* Puts a byte into event queue */ 37 | extern int event_queue_put(event_queue_t *eq, unsigned char event, unsigned int notify_cnt); 38 | 39 | 40 | /* Reads data from event queue */ 41 | extern int event_queue_get(event_queue_t *eq, char *dest, unsigned int size, unsigned int minsize, unsigned int flags); 42 | 43 | 44 | /* Reads 3-byte mouse packets from event queue */ 45 | extern int event_queue_get_mouse(event_queue_t *meq, char *dest, unsigned int size, unsigned int flags); 46 | 47 | 48 | /* Retrieves number of bytes stored in event queue */ 49 | extern int event_queue_count(const event_queue_t *eq); 50 | 51 | 52 | /* Destroys event queue */ 53 | extern void event_queue_destroy(const event_queue_t *eq); 54 | 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /spi/common/spi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * SPI interface 5 | * 6 | * Copyright 2022 Phoenix Systems 7 | * Author: Lukasz Kosinski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _PHOENIX_SPI_H_ 15 | #define _PHOENIX_SPI_H_ 16 | 17 | #include 18 | 19 | 20 | /* SPI clock mode (phase and polarity) */ 21 | #define SPI_CPHA (1 << 0) 22 | #define SPI_CPOL (1 << 1) 23 | #define SPI_MODE0 (0 | 0) 24 | #define SPI_MODE1 (0 | SPI_CPHA) 25 | #define SPI_MODE2 (SPI_CPOL | 0) 26 | #define SPI_MODE3 (SPI_CPOL | SPI_CPHA) 27 | 28 | /* SPI external slave select line. Passed to spi_xfer() for manual SS control */ 29 | #define SPI_SS_EXTERNAL ((unsigned int)-1) 30 | 31 | 32 | /* Performs SPI transaction with SPI slave given by ss */ 33 | extern int spi_xfer(unsigned int dev, unsigned int ss, const void *out, size_t olen, void *in, size_t ilen, size_t iskip); 34 | 35 | 36 | /* Returns SPI clock speed (in Hz) */ 37 | extern int spi_getSpeed(unsigned int dev, unsigned int *speed); 38 | 39 | 40 | /* Sets SPI clock speed (in Hz) */ 41 | extern int spi_setSpeed(unsigned int dev, unsigned int speed); 42 | 43 | 44 | /* Returns SPI clock mode */ 45 | extern int spi_getMode(unsigned int dev, unsigned char *mode); 46 | 47 | 48 | /* Sets SPI clock mode */ 49 | extern int spi_setMode(unsigned int dev, unsigned char mode); 50 | 51 | 52 | /* Initializes SPI controller */ 53 | extern int spi_init(unsigned int dev); 54 | 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /storage/flashdrv/drv/grlib-ftmctrl/cmds.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB FTMCTRL Flash driver 5 | * 6 | * Flash commands 7 | * 8 | * Copyright 2025 Phoenix Systems 9 | * Author: Lukasz Leczkowski 10 | * 11 | * This file is part of Phoenix-RTOS. 12 | * 13 | * %LICENSE% 14 | */ 15 | 16 | #ifndef _FTMCTRL_CMDS_H_ 17 | #define _FTMCTRL_CMDS_H_ 18 | 19 | 20 | /* Common flash commands */ 21 | #define CMD_RD_QUERY 0x98u /* Read/Enter Query */ 22 | #define CMD_RD_STATUS 0x70u /* Read Status Register */ 23 | 24 | /* Intel command set */ 25 | #define INTEL_CMD_RESET 0xffu /* Reset/Read Array */ 26 | #define INTEL_CMD_WR_BUF 0xe8u /* Write to Buffer */ 27 | #define INTEL_CMD_WR_CONFIRM 0xd0u /* Write Confirm */ 28 | #define INTEL_CMD_CLR_STATUS 0x50u /* Clear Status Register */ 29 | #define INTEL_CMD_BE_CYC1 0x20u /* Block Erase (1st bus cycle) */ 30 | 31 | /* AMD command set */ 32 | #define AMD_CMD_RESET 0xf0u /* Reset/ASO Exit */ 33 | #define AMD_CMD_WR_BUF 0x25u /* Write to Buffer */ 34 | #define AMD_CMD_WR_CONFIRM 0x29u /* Write Confirm */ 35 | #define AMD_CMD_CLR_STATUS 0x71u /* Clear Status Register */ 36 | #define AMD_CMD_CE_CYC1 0x80u /* Chip Erase (1st bus cycle) */ 37 | #define AMD_CMD_CE_CYC2 0x10u /* Chip Erase (2nd bus cycle) */ 38 | #define AMD_CMD_BE_CYC1 0x80u /* Block Erase (1st bus cycle) */ 39 | #define AMD_CMD_BE_CYC2 0x30u /* Block Erase (2nd bus cycle) */ 40 | #define AMD_CMD_EXIT_QUERY 0xf0u /* Exit Query */ 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/posixsrv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 builtin posix server (libposixsrv) 5 | * 6 | * Copyright 2024 Phoenix Systems 7 | * Author: Gerard Swiderski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include "config.h" 15 | 16 | #if BUILTIN_POSIXSRV 17 | 18 | #include 19 | #include 20 | 21 | #ifndef POSIXSRV_PRIO 22 | #define POSIXSRV_PRIO 4 23 | #endif 24 | 25 | #ifndef POSIXSRV_THREADS_NO 26 | #define POSIXSRV_THREADS_NO 1 27 | #endif 28 | 29 | 30 | struct { 31 | char stacks[2 + POSIXSRV_THREADS_NO][_PAGE_SIZE] __attribute__((aligned(8))); 32 | unsigned srvPort; 33 | unsigned eventPort; 34 | } libposixsrv_common; 35 | 36 | 37 | int posixsrv_start(void) 38 | { 39 | if (posixsrv_init(&libposixsrv_common.srvPort, &libposixsrv_common.eventPort) < 0) { 40 | return -1; 41 | } 42 | 43 | beginthread(posixsrv_threadRqTimeout, POSIXSRV_PRIO, libposixsrv_common.stacks[0], sizeof(libposixsrv_common.stacks[0]), NULL); 44 | beginthread(posixsrv_threadMain, POSIXSRV_PRIO, libposixsrv_common.stacks[1], sizeof(libposixsrv_common.stacks[1]), (void *)libposixsrv_common.eventPort); 45 | 46 | for (int i = 2; i < sizeof(libposixsrv_common.stacks) / sizeof(libposixsrv_common.stacks[0]); ++i) { 47 | beginthread(posixsrv_threadMain, POSIXSRV_PRIO, libposixsrv_common.stacks[i], sizeof(libposixsrv_common.stacks[i]), (void *)libposixsrv_common.srvPort); 48 | } 49 | 50 | return 0; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /gpio/zynq7000-gpio/gpio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Zynq-7000 GPIO controller 5 | * 6 | * Copyright 2022 Phoenix Systems 7 | * Author: Lukasz Kosinski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _ZYNQ7000_GPIO_H_ 15 | #define _ZYNQ7000_GPIO_H_ 16 | 17 | #include 18 | 19 | 20 | #define GPIO_BANKS 2 /* Number of GPIO banks */ 21 | #define GPIO_PINS 32 /* Max number of pins per bank */ 22 | 23 | 24 | /* GPIO pins configuration */ 25 | extern const int gpioPins[GPIO_BANKS][GPIO_PINS]; 26 | 27 | 28 | /* Returns GPIO pin state (0 - low, 1 - high) */ 29 | extern int gpio_readPin(unsigned int bank, unsigned int pin, uint32_t *val); 30 | 31 | 32 | /* Sets GPIO pin state (0 - low, 1 - high) */ 33 | extern int gpio_writePin(unsigned int bank, unsigned int pin, uint32_t val); 34 | 35 | 36 | /* Returns GPIO pins state (0 - low, 1 - high) */ 37 | extern int gpio_readPort(unsigned int bank, uint32_t *val); 38 | 39 | 40 | /* Sets GPIO pins state (0 - low, 1 - high) */ 41 | extern int gpio_writePort(unsigned int bank, uint32_t val, uint32_t mask); 42 | 43 | 44 | /* Returns GPIO pins direction (0 - input, 1 - output) */ 45 | extern int gpio_readDir(unsigned int bank, uint32_t *dir); 46 | 47 | 48 | /* Sets GPIO pins direction (0 - input, 1 - output) */ 49 | extern int gpio_writeDir(unsigned int bank, uint32_t dir, uint32_t mask); 50 | 51 | 52 | /* Initializes GPIO controller */ 53 | extern int gpio_init(void); 54 | 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /multi/imxrt-multi/posixsrv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT builtin posix server (libposixsrv) 5 | * 6 | * Copyright 2023-2024 Phoenix Systems 7 | * Author: Gerard Swiderski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include "config.h" 15 | 16 | #if BUILTIN_POSIXSRV 17 | 18 | #include 19 | #include 20 | 21 | #ifndef POSIXSRV_PRIO 22 | #define POSIXSRV_PRIO IMXRT_MULTI_PRIO 23 | #endif 24 | 25 | #ifndef POSIXSRV_THREADS_NO 26 | #define POSIXSRV_THREADS_NO 1 27 | #endif 28 | 29 | 30 | struct { 31 | char stacks[2 + POSIXSRV_THREADS_NO][_PAGE_SIZE] __attribute__((aligned(8))); 32 | unsigned srvPort; 33 | unsigned eventPort; 34 | } libposixsrv_common; 35 | 36 | 37 | int posixsrv_start(void) 38 | { 39 | if (posixsrv_init(&libposixsrv_common.srvPort, &libposixsrv_common.eventPort) < 0) { 40 | return -1; 41 | } 42 | 43 | beginthread(posixsrv_threadRqTimeout, POSIXSRV_PRIO, libposixsrv_common.stacks[0], sizeof(libposixsrv_common.stacks[0]), NULL); 44 | beginthread(posixsrv_threadMain, POSIXSRV_PRIO, libposixsrv_common.stacks[1], sizeof(libposixsrv_common.stacks[1]), (void *)libposixsrv_common.eventPort); 45 | 46 | for (int i = 2; i < sizeof(libposixsrv_common.stacks) / sizeof(libposixsrv_common.stacks[0]); ++i) { 47 | beginthread(posixsrv_threadMain, POSIXSRV_PRIO, libposixsrv_common.stacks[i], sizeof(libposixsrv_common.stacks[i]), (void *)libposixsrv_common.srvPort); 48 | } 49 | 50 | return 0; 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /multi/imxrt-multi/cm4/example/blinky.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT117x Cortex-M4 blinky example 5 | * 6 | * Copyright 2021 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | static struct { 19 | unsigned int start; 20 | unsigned int end; 21 | } common; 22 | 23 | 24 | static void setTimer(unsigned int howlong) 25 | { 26 | common.start = cm4_getJiffies(); 27 | common.end = common.start + howlong; 28 | } 29 | 30 | 31 | static int checkTimer(void) 32 | { 33 | int val; 34 | 35 | val = cm4_getJiffies(); 36 | 37 | if ((common.start < common.end && val > common.end) || (val < common.start && val > common.end)) 38 | return 1; 39 | 40 | return 0; 41 | } 42 | 43 | 44 | int main(int argc, char *argv[]) 45 | { 46 | char byte; 47 | int i; 48 | static const char str[] = "Hearth beat\n"; 49 | 50 | /* GPIO_AD_10 - GPIO9 pin 9*/ 51 | cm4_setIOmux(pctl_mux_gpio_ad_10, 0, 10); 52 | cm4_setIOpad(pctl_pad_gpio_ad_10, 0, 1, 0, 0, 0, 0); 53 | 54 | gpio_setDir(gpio9, 9, gpio_out); 55 | gpio_setPin(gpio9, 9, 1); 56 | 57 | setTimer(500); 58 | 59 | while (1) { 60 | if (checkTimer()) { 61 | setTimer(500); 62 | gpio_togglePin(gpio9, 9); 63 | mu_write(0, str, sizeof(str) - 1); 64 | } 65 | 66 | for (i = 1; i < 4; ++i) { 67 | if (mu_read(i, &byte, 1)) { 68 | byte += i - 1; 69 | mu_write(i, &byte, 1); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /storage/umass/srv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * USB Mass Storage class driver 5 | * 6 | * Device driver server 7 | * 8 | * Copyright 2024 Phoenix Systems 9 | * Author: Adam Greloch 10 | * 11 | * This file is part of Phoenix-RTOS. 12 | * 13 | * %LICENSE% 14 | */ 15 | 16 | #include "umass.h" 17 | #include 18 | 19 | 20 | static void printHelp(const char *name) 21 | { 22 | fprintf(stderr, 23 | "Usage: %s [opts]\n" 24 | " -r Mount as rootfs\n" 25 | " -h Print this help\n", 26 | name); 27 | } 28 | 29 | 30 | int main(int argc, char *argv[]) 31 | { 32 | int ret; 33 | char c; 34 | oid_t oid; 35 | umass_args_t umass_args = { .mount_root = false }; 36 | usb_driver_t *driver = usb_registeredDriverPop(); 37 | 38 | if (driver == NULL) { 39 | fprintf(stderr, "umass: no driver registered!"); 40 | return 1; 41 | } 42 | 43 | if (argc > 1) { 44 | /* Process command line options */ 45 | for (;;) { 46 | c = getopt(argc, argv, "hr"); 47 | if (c == -1) { 48 | break; 49 | } 50 | switch (c) { 51 | case 'r': 52 | umass_args.mount_root = true; 53 | break; 54 | case 'h': 55 | default: 56 | printHelp(argv[0]); 57 | return 0; 58 | } 59 | } 60 | } 61 | 62 | if (!umass_args.mount_root) { 63 | /* Wait for root filesystem if not responsible for mounting it */ 64 | while (lookup("/", NULL, &oid) < 0) { 65 | usleep(10000); 66 | } 67 | } 68 | 69 | ret = usb_driverProcRun(driver, &umass_args); 70 | 71 | return ret == 0 ? 0 : 1; 72 | } 73 | -------------------------------------------------------------------------------- /storage/flashdrv/include/flashdrv/cfi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * GRLIB FTMCTRL Flash driver 5 | * 6 | * CFI 7 | * 8 | * Copyright 2025 Phoenix Systems 9 | * Author: Lukasz Leczkowski 10 | * 11 | * This file is part of Phoenix-RTOS. 12 | * 13 | * %LICENSE% 14 | */ 15 | 16 | #ifndef _FLASHDRV_CFI_H_ 17 | #define _FLASHDRV_CFI_H_ 18 | 19 | 20 | #include 21 | 22 | /* Timeouts in us */ 23 | #define CFI_TIMEOUT_MAX_PROGRAM(typical, maximum) ((1u << (typical)) * (1u << (maximum))) 24 | #define CFI_TIMEOUT_MAX_ERASE(typical, maximum) ((1u << (typical)) * (1u << (maximum)) * 1024u) 25 | 26 | #define CFI_SIZE(size) (1u << ((uint32_t)(size))) 27 | #define CFI_REGION_SIZE(size) ((size) * 256u) 28 | 29 | 30 | typedef struct { 31 | uint8_t wordProgram; 32 | uint8_t bufWrite; 33 | uint8_t blkErase; 34 | uint8_t chipErase; 35 | } __attribute__((packed)) cfi_timeout_t; 36 | 37 | 38 | typedef struct { 39 | uint8_t vendorData[0x10]; 40 | uint8_t qry[3]; 41 | uint16_t cmdSet1; 42 | uint16_t addrExt1; 43 | uint16_t cmdSet2; 44 | uint16_t addrExt2; 45 | struct { 46 | uint8_t vccMin; 47 | uint8_t vccMax; 48 | uint8_t vppMin; 49 | uint8_t vppMax; 50 | } __attribute__((packed)) voltages; 51 | cfi_timeout_t toutTypical; 52 | cfi_timeout_t toutMax; 53 | uint8_t chipSz; 54 | uint16_t fdiDesc; 55 | uint16_t bufSz; 56 | uint8_t regionCnt; 57 | struct { 58 | uint16_t count; 59 | uint16_t size; 60 | } __attribute__((packed)) regions[4]; 61 | } __attribute__((packed)) cfi_info_t; 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /storage/imxrt-flash/imxrt-flashsrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT Flash server 5 | * 6 | * Copyright 2019 Phoenix Systems 7 | * Author: Hubert Buczynski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _IMXRT_FLASH_SERVER_H_ 16 | #define _IMXRT_FLASH_SERVER_H_ 17 | 18 | 19 | #include 20 | 21 | 22 | /* clang-format off */ 23 | 24 | enum { flashsrv_devctl_properties = 0, flashsrv_devctl_sync, flashsrv_devctl_eraseSector, 25 | flashsrv_devctl_erasePartition, flashsrv_devctl_directWrite, flashsrv_devctl_directRead, 26 | flashsrv_devctl_calcCrc32 }; 27 | 28 | /* clang-format on */ 29 | 30 | 31 | typedef struct { 32 | int type; 33 | 34 | union { 35 | /* eraseSector */ 36 | struct { 37 | uint32_t addr; 38 | } erase; 39 | 40 | /* directWrite */ 41 | struct { 42 | uint32_t addr; 43 | } write; 44 | 45 | /* directRead */ 46 | struct { 47 | uint32_t addr; 48 | } read; 49 | 50 | /* calcCrc32 */ 51 | struct { 52 | /* set addr & len to 0 for full range */ 53 | uint32_t addr; 54 | uint32_t len; 55 | uint32_t base; 56 | } crc32; 57 | }; 58 | } __attribute__((packed)) flash_i_devctl_t; 59 | 60 | 61 | typedef struct { 62 | uint32_t size; 63 | uint32_t psize; 64 | uint32_t ssize; 65 | uint32_t offs; 66 | } flashsrv_properties_t; 67 | 68 | 69 | typedef struct { 70 | union { 71 | flashsrv_properties_t properties; 72 | uint32_t crc32; 73 | }; 74 | } __attribute__((packed)) flash_o_devctl_t; 75 | 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /storage/imxrt-flash/tests/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT utilities 5 | * 6 | * Copyright 2020 Phoenix Systems 7 | * Author: Hubert Buczynski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | 16 | #define COL_GREY "\033[1;30m" 17 | #define COL_RED "\033[1;31m" 18 | #define COL_GREEN "\033[1;32m" 19 | #define COL_YELLOW "\033[1;33m" 20 | #define COL_BLUE "\033[1;34m" 21 | #define COL_CYAN "\033[1;36m" 22 | #define COL_VIOLET "\033[1;35m" 23 | #define COL_NORMAL "\033[0m" 24 | 25 | #define LOG_CTG_COLOR COL_YELLOW 26 | #define LOG_INFO_COLOR COL_NORMAL 27 | #define LOG_ERR_COLOR COL_RED 28 | #define LOG_SUCCESS_COLOR COL_GREEN 29 | 30 | 31 | static int testCounter = 1; 32 | static int categoryCounter = 0; 33 | 34 | #define TEST_CATEGORY(category) \ 35 | do { \ 36 | printf(LOG_CTG_COLOR); \ 37 | printf("\n\n## %d. %s :", ++categoryCounter, category); \ 38 | testCounter = 1; \ 39 | printf(LOG_INFO_COLOR); \ 40 | } while(0) 41 | 42 | 43 | #define TEST_CASE(test) \ 44 | do { \ 45 | if ((test) == EOK) { \ 46 | printf("\nTEST CASE %d.%d: %-60s\t", categoryCounter, testCounter++, #test); \ 47 | printf(LOG_SUCCESS_COLOR); \ 48 | printf("-- PASSED"); } \ 49 | else { \ 50 | printf(LOG_ERR_COLOR); \ 51 | printf("\nTEST CASE %d.%d: %-60s\t", categoryCounter, testCounter++, #test); \ 52 | printf("-- FAILED"); \ 53 | } \ 54 | printf(LOG_INFO_COLOR); \ 55 | fflush(stdout); \ 56 | } while (0) 57 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, Phoenix Systems. 2 | All Rights Reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 1. Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 3. Neither the name of the Phoenix Systems nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL PHOENIX SYSTEMS BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /adc/ad7779/imxrt/spi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include "../ad7779.h" 8 | 9 | static oid_t spi_driver; 10 | 11 | 12 | int spi_exchange(uint8_t *buff, uint8_t len) 13 | { 14 | int res; 15 | msg_t msg = { 0 }; 16 | multi_i_t *imsg = (multi_i_t *)msg.i.raw; 17 | 18 | msg.type = mtDevCtl; 19 | msg.i.data = buff; 20 | msg.i.size = len; 21 | msg.o.data = buff; 22 | msg.o.size = len; 23 | msg.oid.id = id_spi4; 24 | msg.oid.port = spi_driver.port; 25 | 26 | imsg->spi.type = spi_transaction; 27 | imsg->spi.transaction.cs = 0; 28 | imsg->spi.transaction.frameSize = len; 29 | 30 | if ((res = msgSend(spi_driver.port, &msg)) < 0) 31 | return res; 32 | 33 | return msg.o.err; 34 | } 35 | 36 | 37 | int spi_init(void) 38 | { 39 | int res; 40 | msg_t msg; 41 | multi_i_t *imsg = (multi_i_t *)msg.i.raw; 42 | 43 | if (spi_driver.port == 0) { 44 | while (lookup("/dev/spi4", NULL, &spi_driver) < 0) 45 | usleep(100 * 1000); 46 | } 47 | 48 | msg.type = mtDevCtl; 49 | msg.i.data = NULL; 50 | msg.i.size = 0; 51 | msg.o.data = NULL; 52 | msg.o.size = 0; 53 | msg.oid.id = id_spi4; 54 | msg.oid.port = spi_driver.port; 55 | 56 | imsg->spi.type = spi_config; 57 | imsg->spi.config.cs = 0; 58 | imsg->spi.config.mode = spi_mode_0; 59 | imsg->spi.config.endian = spi_msb; 60 | imsg->spi.config.sckDiv = 4; 61 | imsg->spi.config.prescaler = 3; 62 | 63 | if ((res = msgSend(spi_driver.port, &msg)) < 0) 64 | return res; 65 | 66 | return msg.o.err; 67 | } 68 | -------------------------------------------------------------------------------- /gpio/rcpwm/rcpwm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Xilinx Zynq7000 / ZynqMP PWM driver binary interface 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | int rcpwm_set(oid_t *oid, uint32_t compval[RCPWM_CHANNELS], uint8_t mask) 21 | { 22 | int ret; 23 | msg_t msg; 24 | rcpwm_imsg_t *i = (rcpwm_imsg_t *)msg.i.raw; 25 | rcpwm_omsg_t *o = (rcpwm_omsg_t *)msg.o.raw; 26 | 27 | msg.i.data = NULL; 28 | msg.i.size = 0; 29 | msg.o.data = NULL; 30 | msg.o.size = 0; 31 | 32 | msg.type = mtDevCtl; 33 | i->type = rcpwm_msgSet; 34 | i->mask = mask; 35 | msg.oid = *oid; 36 | memcpy(i->compval, compval, sizeof(i->compval)); 37 | 38 | ret = msgSend(oid->port, &msg); 39 | if (ret >= 0) { 40 | ret = o->err; 41 | } 42 | 43 | return ret; 44 | } 45 | 46 | 47 | int rcpwm_get(oid_t *oid, uint32_t compval[RCPWM_CHANNELS]) 48 | { 49 | int ret; 50 | msg_t msg; 51 | rcpwm_imsg_t *i = (rcpwm_imsg_t *)msg.i.raw; 52 | rcpwm_omsg_t *o = (rcpwm_omsg_t *)msg.o.raw; 53 | 54 | msg.i.data = NULL; 55 | msg.i.size = 0; 56 | msg.o.data = NULL; 57 | msg.o.size = 0; 58 | 59 | msg.type = mtDevCtl; 60 | i->type = rcpwm_msgGet; 61 | msg.oid = *oid; 62 | ret = msgSend(oid->port, &msg); 63 | if (ret >= 0) { 64 | ret = o->err; 65 | } 66 | 67 | if (ret >= 0) { 68 | memcpy(compval, o->compval, sizeof(o->compval)); 69 | } 70 | 71 | return ret; 72 | } 73 | -------------------------------------------------------------------------------- /spi/common/spi-msg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * SPI message interface 5 | * 6 | * Copyright 2022 Phoenix Systems 7 | * Author: Lukasz Kosinski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _PHOENIX_SPI_MSG_H_ 15 | #define _PHOENIX_SPI_MSG_H_ 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | 23 | enum { 24 | spi_devctl_xfer = 0, /* input: *ctx, *out, olen, *in, ilen, iskip */ 25 | }; 26 | 27 | 28 | typedef struct { 29 | oid_t oid; /* SPI slave oid, initialized by spimsg_open() */ 30 | unsigned char mode; /* SPI clock mode (phase and polarity), should be set by the user */ 31 | unsigned int speed; /* SPI clock speed, should be set by the user */ 32 | } spimsg_ctx_t; 33 | 34 | 35 | typedef struct { 36 | struct { 37 | unsigned int type; /* Devctl type */ 38 | spimsg_ctx_t ctx; /* SPI context */ 39 | struct { 40 | size_t isize; /* Size of input data */ 41 | size_t osize; /* Size of output data */ 42 | size_t iskip; /* Number of bytes to skip from MISO */ 43 | } xfer; 44 | } i; 45 | 46 | unsigned char payload[0]; 47 | } spi_devctl_t; 48 | 49 | 50 | /* Performs SPI transaction */ 51 | extern int spimsg_xfer(const spimsg_ctx_t *ctx, const void *out, size_t olen, void *in, size_t ilen, size_t iskip); 52 | 53 | 54 | /* Closes SPI message context */ 55 | extern int spimsg_close(const spimsg_ctx_t *ctx); 56 | 57 | 58 | /* Opens SPI message context and initializes its oid */ 59 | extern int spimsg_open(unsigned int dev, unsigned int ss, spimsg_ctx_t *ctx); 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /adc/ade7913/flexpwm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX FlexPWM 5 | * 6 | * Copyright 2021-2023 Phoenix Systems 7 | * Author: Gerard Swiderski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef FLEXPWM_H 15 | #define FLEXPWM_H 16 | 17 | 18 | /* Flag for use in board config */ 19 | #define FLEXPWM_BOARDCONFIG 20 | 21 | 22 | /* Device selector */ 23 | #define FLEXPWM_PWM1 0u 24 | #define FLEXPWM_PWM2 1u 25 | #define FLEXPWM_PWM3 2u 26 | #define FLEXPWM_PWM4 3u 27 | 28 | 29 | /* Input capture edge setup */ 30 | #define FLEXPWM_CAP_DISABLED 0u 31 | #define FLEXPWM_CAP_EDGE_FALLING 1u 32 | #define FLEXPWM_CAP_EDGE_RISING 2u 33 | #define FLEXPWM_CAP_EDGE_ANY 3u 34 | 35 | 36 | /* Submodule */ 37 | #define FLEXPWM_SM0 0u 38 | #define FLEXPWM_SM1 1u 39 | #define FLEXPWM_SM2 2u 40 | #define FLEXPWM_SM3 3u 41 | 42 | 43 | /* PWM pin */ 44 | #define FLEXPWM_PWMX 0u 45 | #define FLEXPWM_PWMB 1u 46 | #define FLEXPWM_PWMA 2u 47 | 48 | 49 | /* DMA Requests read/write */ 50 | #define FLEXPWM_DMA_RREQ(dev, sm) (85u + (unsigned)(dev)*8u + (unsigned)(sm) + 0u) 51 | #define FLEXPWM_DMA_WREQ(dev, sm) (85u + (unsigned)(dev)*8u + (unsigned)(sm) + 4u) 52 | 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | 59 | /* Initialize base address using dev index */ 60 | int flexpwm_init(unsigned int dev); 61 | 62 | 63 | /* Configure input capture mode */ 64 | int flexpwm_input_capture(unsigned int sm, unsigned int pwm, unsigned int cap0_edge, unsigned int cap1_edge); 65 | 66 | 67 | #ifdef __cplusplus 68 | }; 69 | #endif 70 | 71 | 72 | #endif /* end of FLEXPWM_H */ 73 | -------------------------------------------------------------------------------- /adc/ade7913/ade7913.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT1176 ADE7913 API 5 | * 6 | * Copyright 2021-2022 Phoenix Systems 7 | * Author: Marcin Baran, Gerard Swiderski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef ADE7913_H 15 | #define ADE7913_H 16 | 17 | #include 18 | #include 19 | 20 | 21 | typedef struct { 22 | uint32_t iwv : 24; 23 | uint32_t v1wv : 24; 24 | uint32_t v2wv : 24; 25 | uint16_t adc_crc; 26 | uint8_t status0; 27 | uint16_t cnt_snapshot; 28 | } __attribute__((packed)) ade7913_burst_reg_t; 29 | 30 | 31 | int ade7913_init(oid_t *device, int cs, int clkout); 32 | int ade7913_sync(oid_t *device, const char *cs, int devcnt, int snap); 33 | 34 | int ade7913_get_sampling_rate(oid_t *device, int cs, int *freq_hz); 35 | int ade7913_set_sampling_rate(oid_t *device, int cs, int freq_hz); 36 | 37 | int ade7913_version(oid_t *device, int cs); 38 | int ade7913_ready(oid_t *device, int cs); 39 | 40 | int ade7913_sample_lost(oid_t *device, int cs); 41 | int ade7913_sample_regs_read(oid_t *device, int cs, ade7913_burst_reg_t *reg); 42 | 43 | int ade7913_lock(oid_t *device, int cs); 44 | int ade7913_unlock(oid_t *device, int cs); 45 | 46 | int ade7913_emi(oid_t *device, int cs, uint8_t val); 47 | 48 | int ade7913_enable(oid_t *device, int cs); 49 | int ade7913_disable(oid_t *device, int cs); 50 | 51 | int ade7913_temperature(oid_t *device, int cs); 52 | int ade7913_voltage(oid_t *device, int cs); 53 | 54 | int ade7913_reset_soft(oid_t *device, int cs); 55 | int ade7913_reset_hard(oid_t *device, int cs); 56 | 57 | #endif /* ADE7913_H */ 58 | -------------------------------------------------------------------------------- /multi/imxrt-multi/cm4/lib/Makefile.ext: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for libm4 3 | # 4 | # ARMv7 (Cortex-M4) 5 | # 6 | # Copyright 2021 Phoenix Systems 7 | # 8 | 9 | CROSS ?= arm-none-eabi- 10 | CC = $(CROSS)gcc 11 | AR = $(CROSS)ar 12 | 13 | TOPDIR := $(CURDIR) 14 | PREFIX_BUILD ?= ../_build/$(TARGET) 15 | PREFIX_BUILD := $(abspath $(PREFIX_BUILD)) 16 | BUILD_DIR ?= $(PREFIX_BUILD)/$(notdir $(TOPDIR)) 17 | BUILD_DIR := $(abspath $(BUILD_DIR)) 18 | 19 | # build artifacts dir 20 | CURR_SUFFIX := $(patsubst $(TOPDIR)/%,%,$(abspath $(CURDIR))/) 21 | PREFIX_O := $(BUILD_DIR)/$(CURR_SUFFIX) 22 | 23 | # target install paths, can be provided exterally 24 | PREFIX_A ?= $(PREFIX_BUILD)/lib/ 25 | PREFIX_H ?= $(PREFIX_BUILD)/include/ 26 | PREFIX_PROG ?= $(PREFIX_BUILD)/prog/ 27 | PREFIX_PROG_STRIPPED ?= $(PREFIX_BUILD)/prog.stripped/ 28 | 29 | CFLAGS += -Wall -Wstrict-prototypes -g -nostartfiles -nostdlib\ 30 | -mthumb -fomit-frame-pointer -ffreestanding -mno-unaligned-access\ 31 | -fstack-usage -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -O2 32 | 33 | OBJS = $(addprefix $(PREFIX_O), crt0.o _startc.o cm4.o gpio.o string.o interrupt.o mu.o) 34 | HEADERS = $(addprefix $(PREFIX_H), gpio.h cm4.h string.h interrupt.h mu.h) 35 | 36 | $(PREFIX_O)%.o: %.c 37 | @mkdir -p $(@D) 38 | $(SIL)$(CC) -c $(CFLAGS) $< -o "$@" 39 | 40 | $(PREFIX_O)%.o: %.S 41 | @mkdir -p $(@D) 42 | $(SIL)$(CC) -c $(CFLAGS) $< -o "$@" 43 | 44 | $(PREFIX_A)libcm4.a: $(OBJS) 45 | $(SIL)$(AR) -r $@ $^ 2>/dev/null 46 | 47 | $(PREFIX_H)%.h: %.h 48 | $(SIL)mkdir -p $(@D) 49 | cp -pR "$<" "$@" 50 | 51 | all: $(PREFIX_A)libcm4.a $(HEADERS) 52 | 53 | clean: 54 | rm -f $(PREFIX_O)*.o $(PREFIX_O)*.su $(PREFIX_A)libcm4.a $(HEADERS) 55 | -------------------------------------------------------------------------------- /sdio/common/sdio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * SDIO driver header 5 | * 6 | * Copyright 2022 Phoenix Systems 7 | * Author: Artur Miller 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _PHOENIX_SDIO_H 15 | #define _PHOENIX_SDIO_H 16 | 17 | #include 18 | #include 19 | 20 | 21 | /* SDIO interrupt events */ 22 | #define SDIO_EVENT_CARD_IN 0 /* card inserted */ 23 | #define SDIO_EVENT_CARD_OUT 1 /* card removed */ 24 | #define SDIO_EVENT_CARD_IRQ 2 /* card requested interrupt */ 25 | 26 | typedef enum { 27 | sdio_read, 28 | sdio_write 29 | } sdio_dir_t; 30 | 31 | 32 | /* interrupt event handler pointer */ 33 | typedef void (*sdio_event_handler_t)(void *arg); 34 | 35 | 36 | /* Enables SDIO module */ 37 | extern int sdio_init(void); 38 | 39 | 40 | /* Configures hardware module */ 41 | extern int sdio_config(uint32_t freq, uint16_t blocksz); 42 | 43 | 44 | /* Disables SDIO module */ 45 | extern void sdio_free(void); 46 | 47 | 48 | /* Transfers a single byte of data */ 49 | extern int sdio_transferDirect(sdio_dir_t dir, uint32_t address, uint8_t area, uint8_t *data); 50 | 51 | 52 | /* Transfers to/from device synchronously */ 53 | extern int sdio_transferBulk(sdio_dir_t dir, int blockMode, uint32_t address, uint8_t area, 54 | uint8_t *data, size_t len); 55 | 56 | 57 | /* Registers an interrupt event handler */ 58 | extern int sdio_eventRegister(uint8_t event, sdio_event_handler_t handler, void *arg); 59 | 60 | 61 | /* Sets interrupt event detector state */ 62 | extern int sdio_eventEnable(uint8_t event, int enabled); 63 | 64 | 65 | #endif /* _PHOENIX_SDIO_H */ 66 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/libmulti/include/libmulti/libspi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Multidrv-lib: STM32L4 SPI driver 5 | * 6 | * Copyright 2018, 2020 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef LIBSPI_H_ 16 | #define LIBSPI_H_ 17 | 18 | 19 | #include 20 | #include 21 | #include "libmulti/libdma.h" 22 | 23 | 24 | typedef struct { 25 | #if defined(__CPU_STM32L4X6) 26 | volatile uint16_t *base; 27 | #elif defined(__CPU_STM32N6) 28 | volatile uint32_t *base; 29 | #endif 30 | unsigned int spiNum; 31 | 32 | unsigned char *ibuff; 33 | const unsigned char *obuff; 34 | size_t cnt; 35 | 36 | const struct libdma_per *per; 37 | } libspi_ctx_t; 38 | 39 | 40 | #define SPI_ADDRSHIFT 3 41 | #define SPI_ADDRMASK 0x3 42 | 43 | 44 | /* clang-format off */ 45 | enum { spi1 = 0, spi2, spi3, spi4, spi5, spi6 }; 46 | 47 | 48 | enum { spi_cmd = 0x1, spi_dummy = 0x2, /* 3-bits for SPI_ADDR* ,*/ spi_addrlsb = 0x20 }; 49 | 50 | 51 | enum { spi_dir_read = 0, spi_dir_write, spi_dir_readwrite }; 52 | 53 | 54 | enum { spi_bdiv_2 = 0, spi_bdiv_4, spi_bdiv_8, spi_bdiv_16, spi_bdiv_32, spi_bdiv_64, spi_bdiv_128, spi_bdiv_256, spi_bdiv_1 }; 55 | /* clang-format on */ 56 | 57 | 58 | int libspi_transaction(libspi_ctx_t *ctx, int dir, unsigned char cmd, unsigned int addr, unsigned char flags, 59 | unsigned char *ibuff, const unsigned char *obuff, size_t bufflen); 60 | 61 | 62 | int libspi_configure(libspi_ctx_t *ctx, char mode, char bdiv, int enable); 63 | 64 | 65 | int libspi_init(libspi_ctx_t *ctx, unsigned int spi, int useDma); 66 | 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /sensors/common/sim/simsensor_reader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Simsensor reader reads and parses data form special scenario file 5 | * than it pushes it to event_queue 6 | * 7 | * Copyright 2023 Phoenix Systems 8 | * Author: Piotr Nieciecki 9 | * 10 | * This file is part of Phoenix-RTOS. 11 | * 12 | * %LICENSE% 13 | */ 14 | 15 | #ifndef SIMSENSOR_READER_H 16 | #define SIMSENSOR_READER_H 17 | 18 | #include 19 | #include 20 | 21 | #include "event_queue.h" 22 | 23 | #define READER_STOP_EVENT 0 24 | 25 | 26 | typedef struct { 27 | FILE *scenarioFile; 28 | ssize_t headerLen; 29 | sensor_type_t sensorTypes; 30 | 31 | time_t timeHorizon; 32 | 33 | char *lineBuf; /* Buffer for storing line from file */ 34 | size_t bufLen; 35 | 36 | time_t timeLast; 37 | long long timeOffset; 38 | } simsens_reader_t; 39 | 40 | 41 | /* 42 | * Initiates `simsens_reader_t` structure. 43 | * `path` specifies file with test scenario 44 | * `sensorType` tells what types of readings are parsed from test file. Argument can be a logical or of different types 45 | * `timeHorizon` - max difference between first and last reader timestamp in single `reader_read` execution 46 | * 47 | * Successful open initialises timeline of sensor reader 48 | */ 49 | extern int reader_open(simsens_reader_t *rd, const char *path, sensor_type_t sensorTypes, time_t timeHorizon); 50 | 51 | 52 | /* Frees elements form `reader` */ 53 | extern void reader_close(simsens_reader_t *reader); 54 | 55 | 56 | /* Parses the file. Stores results in `queue`. On success returns 0, on error returns -1. */ 57 | extern int reader_read(simsens_reader_t *rd, event_queue_t *queue); 58 | 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /storage/imxrt-flash/flashdrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT Flash driver 5 | * 6 | * Copyright 2019, 2020, 2023 Phoenix Systems 7 | * Author: Hubert Buczynski, Gerard Swiderski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _IMXRT_FLASH_H_ 16 | #define _IMXRT_FLASH_H_ 17 | 18 | #include 19 | 20 | #define FLASH_EXT_DATA_ADDRESS (FLEXSPI1_AHB_ADDR) 21 | #define FLASH_INTERNAL_DATA_ADDRESS (FLEXSPI2_AHB_ADDR) 22 | 23 | 24 | typedef struct { 25 | uint32_t size; 26 | uint32_t page_size; 27 | uint32_t sector_size; 28 | const char *pVendor; 29 | } flash_properties_t; 30 | 31 | 32 | typedef struct { 33 | flash_properties_t properties; 34 | flexspi_t fspi; 35 | uint8_t port; 36 | uint8_t isDirty; 37 | 38 | uint32_t address; 39 | time_t timeout; 40 | 41 | uint32_t prevAddr; 42 | 43 | uint8_t *buff; 44 | } flash_context_t; 45 | 46 | 47 | ssize_t flash_directRead(flash_context_t *ctx, uint32_t offset, void *buff, size_t size); 48 | 49 | 50 | ssize_t flash_directWrite(flash_context_t *ctx, uint32_t offset, const void *buff, size_t size); 51 | 52 | 53 | ssize_t flash_bufferedRead(flash_context_t *ctx, uint32_t srcAddr, void *dstPtr, size_t size); 54 | 55 | 56 | ssize_t flash_bufferedWrite(flash_context_t *ctx, uint32_t offset, const void *buff, size_t size); 57 | 58 | 59 | int flash_sync(flash_context_t *ctx); 60 | 61 | 62 | int flash_chipErase(flash_context_t *ctx); 63 | 64 | 65 | int flash_sectorErase(flash_context_t *ctx, uint32_t offset); 66 | 67 | 68 | int flash_init(flash_context_t *ctx); 69 | 70 | 71 | void flash_contextDestroy(flash_context_t *ctx); 72 | 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /storage/virtio-blk/vblk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * VirtIO block device driver 5 | * 6 | * Copyright 2024 Phoenix Systems 7 | * Author: Lukasz Leczkowski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _VBLK_H_ 15 | #define _VBLK_H_ 16 | 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | 23 | struct _storage_devCtx_t { 24 | /* Device data */ 25 | virtio_dev_t vdev; /* VirtIO device */ 26 | virtqueue_t vq; /* Device virtqueue */ 27 | unsigned int sectorsz; /* Device sector size */ 28 | unsigned long long size; /* Device storage size */ 29 | 30 | struct _virtioblk_req_t *req; /* Request buffers */ 31 | handle_t lock; 32 | }; 33 | 34 | 35 | /* clang-format off */ 36 | #define LOG(fmt, ...) do { (void)fprintf(stdout, "virtio-blk: " fmt "\n", ##__VA_ARGS__); } while (0) 37 | #define LOG_ERROR(fmt, ...) do { (void)fprintf(stderr, "virtio-blk:%s:%d: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__); } while (0) 38 | #define TRACE(fmt, ...) do { if (0) { (void)fprintf(stdout, "virtio-blk:%s:%d: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__); } } while (0) 39 | /* clang-format on */ 40 | 41 | 42 | /* Opens request context */ 43 | struct _virtioblk_req_t *vblk_open(void); 44 | 45 | 46 | /* Closes request context */ 47 | void vblk_close(struct _virtioblk_req_t *rctx); 48 | 49 | 50 | const storage_blkops_t *vblk_getBlkOps(void); 51 | 52 | 53 | /* Initializes device context */ 54 | int vblk_ctxInit(struct _storage_devCtx_t **ctx, virtio_dev_t *vdev); 55 | 56 | 57 | /* Destroys device context */ 58 | void vblk_ctxDestroy(struct _storage_devCtx_t *ctx); 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /sensors/common/sim/event_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Queue for buffering sensor event data from reader to simsensors 5 | * 6 | * Copyright 2023 Phoenix Systems 7 | * Author: Piotr Nieciecki 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef EVENT_QUEUE_H 15 | #define EVENT_QUEUE_H 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | 23 | typedef struct { 24 | sensor_event_t *queue; 25 | unsigned int capacity; /* queue max length */ 26 | unsigned int len; /* current length of queue */ 27 | 28 | sensor_event_t *head; 29 | sensor_event_t *tail; 30 | } event_queue_t; 31 | 32 | 33 | /* Initiates `q` as an event queue. If succeeded returns 0. In other case -1. */ 34 | extern int eventQueue_init(event_queue_t *q, unsigned int cnt); 35 | 36 | 37 | /* Deallocates queue pointed by `q` */ 38 | extern void eventQueue_free(event_queue_t *q); 39 | 40 | 41 | /* Adds new sensor event to queue. If succeeded returns 0. In other case -1. */ 42 | extern int eventQueue_enqueue(event_queue_t *q, const sensor_event_t *event); 43 | 44 | 45 | /* Returns information if the queue `q` is full. If `q` is NULL, then the behaviour is undefined. */ 46 | extern bool eventQueue_full(const event_queue_t *q); 47 | 48 | 49 | /* Returns information if the queue `q` is empty. If `q` is NULL, then the behaviour is undefined. */ 50 | extern bool eventQueue_empty(const event_queue_t *q); 51 | 52 | 53 | /* Removes the last element from queue `q` and saves it into `event`. Returns 0 on success, or -1 if queue is empty */ 54 | extern int eventQueue_dequeue(event_queue_t *q, sensor_event_t *event); 55 | 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /multi/imxrt-multi/helpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * i.MX RT helper macros 5 | * 6 | * Copyright 2024 Phoenix Systems 7 | * Author: Daniel Sawka 8 | * 9 | * %LICENSE% 10 | */ 11 | 12 | #ifndef _HELPERS_H_ 13 | #define _HELPERS_H_ 14 | 15 | #define CONCAT2(x, y) x##y 16 | #define CONCAT3(x, y, z) x##y##z 17 | 18 | #define PIN2MUX(x) CONCAT2(pctl_mux_gpio_, x) 19 | #define PIN2PAD(x) CONCAT2(pctl_pad_gpio_, x) 20 | 21 | /* 22 | These macros should only be used in `#if` and `#elif` directives, because undefined identifiers expand to 0 there. 23 | Otherwise there will be "use of undefined identifier" errors (an exception: identifier is first checked for 24 | existence with e.g. `#ifdef`). 25 | 26 | Anything that expands to a numerical expression (or to an empty value) is fine. String literals don't work. 27 | */ 28 | 29 | /* True if X expands to a non-zero value. Also works with undefined and empty identifiers. */ 30 | #define ISTRUTHY(X) ((X + 0) != 0) 31 | 32 | /* 33 | These macros produce a logically correct result only if X is defined. You may use `#ifdef` or `defined()` 34 | for this purpose. Unfortunately, `defined()` cannot be conveniently put inside a macro as this is undefined 35 | behavior (see -Wexpansion-to-defined for details), so you have to use it directly on the spot, for example: 36 | `#if defined(PERIPH1) && !ISEMPTY(PERIPH1) 37 | // Use PERIPH1 38 | #endif` 39 | */ 40 | 41 | /* True if X is empty (has no value). The result in #if is valid only if defined(X) is true */ 42 | #define ISEMPTY(X) ((0 - X - 1) == 1 && (X + 0) != -2) 43 | /* True if X is either 0 or 1. The result in #if is valid only if defined(X) is true */ 44 | #define ISBOOLEAN(X) (!ISEMPTY(X) && ((X + 0) == 0 || (X + 0) == 1)) 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/rcc_l4.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 reset and clock controller driver 5 | * 6 | * Copyright 2017, 2018, 2020 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "common.h" 22 | #include "rtc.h" 23 | 24 | 25 | struct { 26 | volatile unsigned int *base; 27 | volatile unsigned int *pwr; 28 | 29 | handle_t lock; 30 | } rcc_common; 31 | 32 | 33 | enum { cr = 0, icscr, cfgr, cir, ahbrstr, apb2rstr, apb1rstr, ahbenr, apb2enr, 34 | apb1enr, ahblpenr, apb2lpenr, apb1lpenr, csr }; 35 | 36 | 37 | enum { pwr_cr1 = 0, pwr_cr2, pwr_cr3, pwr_cr4, pwr_sr1, pwr_sr2, pwr_scr, pwr_pucra, pwr_pdcra, pwr_pucrb, 38 | pwr_pdcrb, pwr_pucrc, pwr_pdcrc, pwr_pucrd, pwr_pdcrd, pwr_pucre, pwr_pdcre, pwr_pucrf, pwr_pdcrf, 39 | pwr_pucrg, pwr_pdcrg, pwr_pucrh, pwr_pdcrh, pwr_pucri, pwr_pdcri }; 40 | 41 | 42 | static inline void _pwr_lock(void) 43 | { 44 | *(rcc_common.pwr + pwr_cr1) &= ~(1 << 8); 45 | } 46 | 47 | 48 | static inline void _pwr_unlock(void) 49 | { 50 | *(rcc_common.pwr + pwr_cr1) |= 1 << 8; 51 | } 52 | 53 | 54 | void pwr_lock(void) 55 | { 56 | mutexLock(rcc_common.lock); 57 | _pwr_lock(); 58 | mutexUnlock(rcc_common.lock); 59 | } 60 | 61 | 62 | void pwr_unlock(void) 63 | { 64 | mutexLock(rcc_common.lock); 65 | _pwr_unlock(); 66 | mutexUnlock(rcc_common.lock); 67 | } 68 | 69 | 70 | int rcc_init(void) 71 | { 72 | rcc_common.base = RCC_BASE; 73 | rcc_common.pwr = PWR_BASE; 74 | 75 | mutexCreate(&rcc_common.lock); 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /tty/uart16550/uarthw-pc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * UART 16550 device driver 5 | * 6 | * Hardware abstracion layer (ia32-generic) 7 | * 8 | * Copyright 2020-2022 Phoenix Systems 9 | * Author: Julia Kosowska, Pawel Pisarczyk 10 | * 11 | * This file is part of Phoenix-RTOS. 12 | * 13 | * %LICENSE% 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #include "uart16550.h" 21 | 22 | 23 | typedef struct { 24 | void *base; 25 | unsigned int irq; 26 | } uarthw_ctx_t; 27 | 28 | 29 | uint8_t uarthw_read(void *hwctx, unsigned int reg) 30 | { 31 | return inb(((uarthw_ctx_t *)hwctx)->base + reg); 32 | } 33 | 34 | 35 | void uarthw_write(void *hwctx, unsigned int reg, uint8_t val) 36 | { 37 | outb(((uarthw_ctx_t *)hwctx)->base + reg, val); 38 | } 39 | 40 | 41 | char *uarthw_dump(void *hwctx, char *s, size_t sz) 42 | { 43 | snprintf(s, sz, "base=%p irq=%u", ((uarthw_ctx_t *)hwctx)->base, ((uarthw_ctx_t *)hwctx)->irq); 44 | return s; 45 | } 46 | 47 | 48 | unsigned int uarthw_irq(void *hwctx) 49 | { 50 | return ((uarthw_ctx_t *)hwctx)->irq; 51 | } 52 | 53 | 54 | int uarthw_init(unsigned int uartn, void *hwctx, size_t hwctxsz, unsigned int *fclk) 55 | { 56 | static struct { 57 | void *base; 58 | unsigned int irq; 59 | } uarts[] = { { (void *)0x3f8, 4 }, { (void *)0x2f8, 3 }, { (void *)0x3e8, 4 }, { (void *)0x2e8, 3 } }; 60 | 61 | if (hwctxsz < sizeof(uarthw_ctx_t)) { 62 | return -EINVAL; 63 | } 64 | 65 | if (uartn >= 4) { 66 | return -ENODEV; 67 | } 68 | 69 | ((uarthw_ctx_t *)hwctx)->base = uarts[uartn].base; 70 | ((uarthw_ctx_t *)hwctx)->irq = uarts[uartn].irq; 71 | 72 | /* Detect device presence */ 73 | if (uarthw_read(hwctx, REG_IIR) == 0xff) { 74 | return -ENODEV; 75 | } 76 | 77 | *fclk = 115200 * 16; 78 | 79 | return EOK; 80 | } 81 | -------------------------------------------------------------------------------- /gpio/zynq7000-gpio/zynq7000-gpio-msg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Zynq-7000 GPIO message interface 5 | * 6 | * Copyright 2022 Phoenix Systems 7 | * Author: Lukasz Kosinski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _ZYNQ7000_GPIO_MSG_H_ 15 | #define _ZYNQ7000_GPIO_MSG_H_ 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | 23 | enum { 24 | gpio_devctl_read_pin = 0, /* input: - */ 25 | gpio_devctl_write_pin, /* input: val */ 26 | gpio_devctl_read_port, /* input: - */ 27 | gpio_devctl_write_port, /* input: val, mask */ 28 | gpio_devctl_read_dir, /* input: - */ 29 | gpio_devctl_write_dir, /* input: val, mask */ 30 | }; 31 | 32 | 33 | typedef union { 34 | struct { 35 | unsigned int type; /* Devctl type */ 36 | uint32_t val; /* Pin state(s) */ 37 | uint32_t mask; /* Pin mask */ 38 | } i; 39 | 40 | struct { 41 | uint32_t val; /* Returned value */ 42 | } o; 43 | } __attribute__((packed)) gpio_devctl_t; 44 | 45 | 46 | /* Returns GPIO pin state (0 - low, 1 - high) */ 47 | extern int gpiomsg_readPin(oid_t *pin, uint32_t *val); 48 | 49 | 50 | /* Sets GPIO pin state (0 - low, 1 - high) */ 51 | extern int gpiomsg_writePin(oid_t *pin, uint32_t val); 52 | 53 | 54 | /* Returns GPIO pins state (0 - low, 1 - high) */ 55 | extern int gpiomsg_readPort(oid_t *port, uint32_t *val); 56 | 57 | 58 | /* Sets GPIO pins state (0 - low, 1 - high) */ 59 | extern int gpiomsg_writePort(oid_t *port, uint32_t val, uint32_t mask); 60 | 61 | 62 | /* Returns GPIO pins direction (0 - input, 1 - output) */ 63 | extern int gpiomsg_readDir(oid_t *dir, uint32_t *val); 64 | 65 | 66 | /* Sets GPIO pins direction (0 - input, 1 - output) */ 67 | extern int gpiomsg_writeDir(oid_t *dir, uint32_t val, uint32_t mask); 68 | 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /sensors/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Phoenix-RTOS sensor manager 3 | # 4 | # Copyright 2022 Phoenix Systems 5 | # 6 | 7 | LOCAL_PATH := $(call my-dir) 8 | 9 | # Sensors Server Library 10 | # FIXME: need platform specific dependency of libzynq7000-gpio-msg 11 | NAME := libsensors 12 | LOCAL_HEADERS_DIR := server-include 13 | SRCS := $(wildcard $(LOCAL_PATH)common/*/*.c) $(LOCAL_PATH)locsensor.c 14 | DEPS := libsensorsclient 15 | include $(static-lib.mk) 16 | 17 | # Sensor Client API 18 | # Separated for use on host applications 19 | NAME := libsensorsclient 20 | LOCAL_HEADERS_DIR := client-include 21 | include $(static-lib.mk) 22 | 23 | # Sensors application 24 | SENSORHUB_COMMON_DEPS := libsensors libsensorsclient 25 | SENSORHUB_DRIVERS_ALL := 26 | 27 | ALL_SENSOR_MAKES := $(shell find . -mindepth 2 -name sensors.mk -not -path '*/.*') 28 | include $(ALL_SENSOR_MAKES) 29 | 30 | # This is the default sensors list. It is supposed to be overwritten on per-project basis. 31 | SENSORHUB_DRIVERS_ENABLED ?= baro_sim imu_sim mag_sim gps_sim 32 | 33 | SENSORHUB_DRIVERS_INTERNAL := $(filter $(SENSORHUB_DRIVERS_ENABLED), $(SENSORHUB_DRIVERS_ALL)) 34 | SENSORHUB_DRIVERS_EXTERNAL := $(filter-out $(SENSORHUB_DRIVERS_INTERNAL), $(SENSORHUB_DRIVERS_ENABLED)) 35 | $(info sensors enabled (internal [external]): $(SENSORHUB_DRIVERS_INTERNAL) [$(SENSORHUB_DRIVERS_EXTERNAL)]) 36 | 37 | 38 | # Select correct PSP directory and 39 | SENSORS_PSP_DIR := $(LOCAL_PATH)psp/$(TARGET_FAMILY)-$(TARGET_SUBFAMILY) 40 | 41 | ifeq ("$(wildcard $(SENSORS_PSP_DIR))","") 42 | SENSORS_PSP_DIR := $(LOCAL_PATH)psp/generic 43 | endif 44 | 45 | include $(SENSORS_PSP_DIR)/psp.mk 46 | 47 | NAME := sensors 48 | SRCS := $(LOCAL_PATH)sensors.c $(SENSORS_PSP_DIR)/psp.c 49 | DEP_LIBS := $(SENSORHUB_COMMON_DEPS) $(SENSORHUB_DRIVERS_INTERNAL) $(PSP_DEP_LIBS) 50 | LIBS := $(SENSORHUB_DRIVERS_EXTERNAL) 51 | include $(binary.mk) 52 | -------------------------------------------------------------------------------- /tty/libtty/libtty_disc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Operating system kernel 5 | * 6 | * TTY abstraction layer - line discipline 7 | * THIS IS AN INTERNAL HEADER 8 | * 9 | * Copyright 2018 Phoenix Systems 10 | * Author: Marek Białowąs 11 | * 12 | * This file is part of Phoenix-RTOS. 13 | * 14 | * %LICENSE% 15 | */ 16 | 17 | #ifndef _LIBTTY_DISC_H_ 18 | #define _LIBTTY_DISC_H_ 19 | 20 | #include "libtty.h" 21 | #include "fifo.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | /* termios comparison macro's. */ 28 | #define CMP_CC(v, c) (tty->term.c_cc[v] != _POSIX_VDISABLE && \ 29 | tty->term.c_cc[v] == (c)) 30 | #define CMP_FLAG(field, opt) (tty->term.c_##field##flag & (opt)) 31 | 32 | /* Character is a control character. */ 33 | #define CTL_VALID(c) ((c) == 0x7f || (unsigned char)(c) < 0x20) 34 | 35 | 36 | /* maximum amount of chars outputed by libttydisc_write_oproc */ 37 | #define LIBTTYDISC_WRITE_OPROC_MAXLEN 8 38 | 39 | /* internal interface - line discipline */ 40 | int libttydisc_write_oproc(libtty_common_t *tty, char c); 41 | 42 | ssize_t libttydisc_read_canonical(libtty_common_t *tty, char *data, size_t size, unsigned mode, libtty_read_state_t *st); 43 | ssize_t libttydisc_read_raw(libtty_common_t *tty, char *data, size_t size, unsigned mode, libtty_read_state_t *st); 44 | 45 | 46 | static inline int libttydisc_is_breakchar(libtty_common_t *tty, char c) 47 | { 48 | for (char *breakc = tty->breakchars; *breakc; ++breakc) 49 | if (c == *breakc) 50 | return 1; 51 | 52 | return 0; 53 | } 54 | 55 | static inline int libttydisc_rx_have_breakchar(libtty_common_t *tty) 56 | { 57 | char *breakc = tty->breakchars; 58 | while (*breakc) { 59 | if (fifo_has_char(tty->rx_fifo, *breakc)) 60 | return 1; 61 | 62 | ++breakc; 63 | } 64 | 65 | return 0; 66 | } 67 | 68 | 69 | #endif /* _LIBTTY_DISC_H_ */ 70 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * STM32L4 multidriver common 5 | * 6 | * Copyright 2017, 2018 Phoenix Systems 7 | * Author: Aleksander Kaminski 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | #ifndef _COMMON_H_ 15 | #define _COMMON_H_ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #if defined(__CPU_STM32L4X6) 22 | #include "stm32l4x6_base.h" 23 | #include 24 | #elif defined(__CPU_STM32N6) 25 | #include "stm32n6_base.h" 26 | #include 27 | #else 28 | #error "Unknown platform" 29 | #endif 30 | 31 | 32 | #define NELEMS(x) (sizeof(x) / sizeof(x[0])) 33 | 34 | 35 | #define max(a, b) ({ \ 36 | __typeof__ (a) _a = (a); \ 37 | __typeof__ (b) _b = (b); \ 38 | _a > _b ? _a : _b; \ 39 | }) 40 | 41 | 42 | #define min(a, b) ({ \ 43 | __typeof__ (a) _a = (a); \ 44 | __typeof__ (b) _b = (b); \ 45 | _a > _b ? _b : _a; \ 46 | }) 47 | 48 | 49 | #ifdef NDEBUG 50 | #define DEBUG(format, ...) 51 | #else 52 | #define DEBUG(format, ...) printf("%s: "format, drvname, ##__VA_ARGS__) 53 | #endif 54 | 55 | 56 | static inline void dataBarier(void) 57 | { 58 | __asm__ volatile ("dmb"); 59 | } 60 | 61 | 62 | static inline int devClk(int dev, int state) 63 | { 64 | int ret; 65 | platformctl_t pctl; 66 | 67 | pctl.action = pctl_set; 68 | pctl.type = pctl_devclk; 69 | pctl.devclk.dev = dev; 70 | pctl.devclk.state = state; 71 | #if defined(__CPU_STM32N6) 72 | pctl.devclk.lpState = state; 73 | #endif 74 | 75 | ret = platformctl(&pctl); 76 | 77 | return ret; 78 | } 79 | 80 | 81 | static inline unsigned int getCpufreq(void) 82 | { 83 | platformctl_t pctl; 84 | 85 | pctl.action = pctl_get; 86 | pctl.type = pctl_cpuclk; 87 | platformctl(&pctl); 88 | 89 | return pctl.cpuclk.hz; 90 | } 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /multi/stm32l4-multi/stm32l4x6_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Phoenix-RTOS 3 | * 4 | * Multidrv-lib: Peripheral base address definitions for STM32L4x6 5 | * 6 | * Copyright 2025 Phoenix Systems 7 | * Author: Jacek Maksymowicz 8 | * 9 | * This file is part of Phoenix-RTOS. 10 | * 11 | * %LICENSE% 12 | */ 13 | 14 | 15 | #ifndef _STM32L4X6_BASE_H_ 16 | #define _STM32L4X6_BASE_H_ 17 | 18 | #define ADC_BASE ((void *)0x50040000) 19 | #define AES_BASE ((void *)0x50060000) 20 | #define DMA1_BASE ((void *)0x40020000) 21 | #define DMA2_BASE ((void *)0x40020400) 22 | #define EXTI_BASE ((void *)0x40010400) 23 | #define FLASH_BASE ((void *)0x40022000) 24 | #define GPIOA_BASE ((void *)0x48000000) 25 | #define GPIOB_BASE ((void *)0x48000400) 26 | #define GPIOC_BASE ((void *)0x48000800) 27 | #define GPIOD_BASE ((void *)0x48000c00) 28 | #define GPIOE_BASE ((void *)0x48001000) 29 | #define GPIOF_BASE ((void *)0x48001400) 30 | #define GPIOG_BASE ((void *)0x48001800) 31 | #define GPIOH_BASE ((void *)0x48001c00) 32 | #define GPIOI_BASE ((void *)0x48002000) 33 | #define HASH_BASE ((void *)0x50060400) 34 | #define I2C1_BASE ((void *)0x40005400) 35 | #define I2C2_BASE ((void *)0x40005800) 36 | #define I2C3_BASE ((void *)0x40005c00) 37 | #define I2C4_BASE ((void *)0x40008400) 38 | #define PWR_BASE ((void *)0x40007000) 39 | #define RCC_BASE ((void *)0x40021000) 40 | #define RNG_BASE ((void *)0x50060800) 41 | #define RTC_BASE ((void *)0x40002800) 42 | #define SPI1_BASE ((void *)0x40013000) 43 | #define SPI2_BASE ((void *)0x40003800) 44 | #define SPI3_BASE ((void *)0x40003c00) 45 | #define SYSCFG_BASE ((void *)0x40010000) 46 | #define USART1_BASE ((void *)0x40013800) 47 | #define USART2_BASE ((void *)0x40004400) 48 | #define USART3_BASE ((void *)0x40004800) 49 | #define UART4_BASE ((void *)0x40004c00) 50 | #define UART5_BASE ((void *)0x40005000) 51 | 52 | #endif /* _STM32L4X6_BASE_H_ */ 53 | --------------------------------------------------------------------------------