Skip to content

Commit

Permalink
PWM setup & diagnostics (#5)
Browse files Browse the repository at this point in the history
This PR adds a library for controlling the am335x ehrpwm module. This is
a work-in-progress, having demonstrated how to configure the basic
settings and see a functional PWM output. This PR also demonstrates a
failure to make PWM interrupt generation work for the PRU.

Will post a forum question using this content.

See comments in lib/pwm/am335x/pwm-am335x.c.
  • Loading branch information
jmacd authored Mar 3, 2024
1 parent 61f8cc1 commit d352b8c
Show file tree
Hide file tree
Showing 127 changed files with 2,436 additions and 609 deletions.
7 changes: 4 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ build --spawn_strategy=standalone
build:pru0 --crosstool_top=//tools/toolchain:clpru_suite
build:pru0 --cpu=pru
build:pru0 --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
build:pru0 --platforms //tools/toolchain:real_pru
build:pru0 --platforms //tools/toolchain:real_pru0
build:pru0 --copt='-DSUPRUGLUE_AM335X'
build:pru1 --copt='-DSUPRUGLUE_PRU_NUM=0'
build:pru0 --copt='-DSUPRUGLUE_PRU_NUM=0'
build:pru0 --copt='--opt_level=4'
build:pru0 --copt='--opt_for_speed=0'


build:pru1 --crosstool_top=//tools/toolchain:clpru_suite
build:pru1 --cpu=pru
build:pru1 --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
build:pru1 --platforms //tools/toolchain:real_pru
build:pru1 --platforms //tools/toolchain:real_pru1
build:pru1 --copt='-DSUPRUGLUE_AM335X'
build:pru1 --copt='-DSUPRUGLUE_PRU_NUM=1'
build:pru1 --copt='--opt_level=4'
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "kernel/ti-linux-kernel-dev"]
path = kernel/ti-linux-kernel-dev
url = git@github.com:RobertCNelson/ti-linux-kernel-dev.git
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,17 @@ achieve success.
In 2021, after nearly twenty years working for Big Tech companies I
moved to the Mendocino coast and became the owner/operator of the
Caspar, California community water system. With a background in
open-source software and specializing in telemetry systems, you
guessed it--

I'm writing Supruglue as the foundation for an open-source SCADA
system.
open-source software and specializing in telemetry systems, I'm
writing Supruglue as the foundation for an open-source SCADA system.

### WORK IN PROGRESS

This repository is under development.

The next steps are:

- Time support: timestamps, sleep & timer functions
- Carveout support: setup regions for bulk data transfer
- Interrupt controller logic
- Drivers: eCAP, PWM, DMA, etc.
- Drivers: i2c, eCAP, PWM, DMA, etc.
- Multi-PRU coordination.

Sample application goals:
Expand Down Expand Up @@ -70,15 +65,17 @@ To cross-compile for the Beaglebone ARM:
bazel build --config=arm ...
```

### Example
### Examples

#### Two LEDs

The example will alternatingly flash two LEDs on pins `P9_23` and `P9_25`.

```
bazel build --config=pru0 //examples:example_pru0
bazel build --config=pru0 //examples/two_leds:example_pru0
```

The firmware is located in `bazel-out/pru-fastbuild/bin/examples/example_pru0`
The firmware is located in `bazel-out/pru-fastbuild/bin/examples/two_leds/example_pru0`

To build the Supruglue command-line interface,

Expand Down
14 changes: 7 additions & 7 deletions arch/ti-pruss-intr.csv
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Event Number,Signal Name,Source,MII RT Signal Name
12,latch0_in,PRU-ICSS IEP,PRU-ICSS0 Internal Interrupts
13,sync1_out_pend,PRU-ICSS IEP,PRU-ICSS0 Internal Interrupts
14,sync0_out_pend,PRU-ICSS IEP,PRU-ICSS0 Internal Interrupts
15,pr1_ecap_intr_req,PRU-ICSS eCAP,PRU-ICSS0 Internal Interrupts
15,pr1_pru_ecap_intr_req,PRU-ICSS eCAP,PRU-ICSS0 Internal Interrupts
16,pr1_pru_mst_intr[0]_intr_req,pru0 or pru1,PRU-ICSS0 Internal Interrupts
17,pr1_pru_mst_intr[1]_intr_req,pru0 or pru1,PRU-ICSS0 Internal Interrupts
18,pr1_pru_mst_intr[2]_intr_req,pru0 or pru1,PRU-ICSS0 Internal Interrupts
Expand All @@ -34,18 +34,18 @@ Event Number,Signal Name,Source,MII RT Signal Name
32,nirq,UART1,PRU-ICSS0 PRU0_RX_ERR
33,mcasp_x_intr[0]_pend,McASP1,Tx PRU-ICSS0 PRU0_RX_ERR32
34,mcasp_r_intr[0]_pend,McASP1,Rx PRU-ICSS0 PRU0_RX_SFD
35,ecap_intr[0]_intr_pend,eCAP1,PRU-ICSS0 PRU0_RX_SOF
36,ecap_intr[1]_intr_pend,eCAP2,PRU-ICSS0 PRU0_RX_CRC
37,epwm_intr[0]_intr_pend,eHRPWM2,PRU-ICSS0 PRU0_RX_NIBBLE_ODD
35,ecap1_intr_pend,eCAP1,PRU-ICSS0 PRU0_RX_SOF
36,ecap2_intr_pend,eCAP2,PRU-ICSS0 PRU0_RX_CRC
37,epwm2_intr_pend,eHRPWM2,PRU-ICSS0 PRU0_RX_NIBBLE_ODD
38,dcan_uerr,DCAN0,PRU-ICSS0 PRU0_RX_OVERFLOW
39,dcan_int1,DCAN0,PRU-ICSS0 PORT0_TX_UNDERFLOW
40,dcan_intr,DCAN0,PRU-ICSS0 PORT0_TX_OVERFLOW
41,POINTRPEND,I2C0,PRU-ICSS0 MDIO_MII_LINK[0]
42,ecap_intr[2]_intr_pend,eCAP0,PRU-ICSS0 PRU0_RX_EOF
43,epwm_intr[1]_intr_pend,eHRPWM0,(pr1_mii0_col & pr1_mii0_txen) (external)
42,ecap0_intr_pend,eCAP0,PRU-ICSS0 PRU0_RX_EOF
43,epwm0_intr_pend,eHRPWM0,(pr1_mii0_col & pr1_mii0_txen) (external)
44,SINTERRUPTN,McSPI0,PRU-ICSS0 PRU1_RX_ERR
45,eqep_intr_intr_pend,eQEP0,PRU-ICSS0 PRU1_RX_ERR32
46,epwm_intr[2]_intr_pend,eHRPWM1,PRU-ICSS0 PRU1_RX_SFD
46,epwm1_intr_pend,eHRPWM1,PRU-ICSS0 PRU1_RX_SFD
47,c0_misc_pend,3PGSW (GEMAC),PRU-ICSS0 PRU1_RX_SOF
48,c0_tx_pend,3PGSW (GEMAC),PRU-ICSS0 PRU1_RX_CRC
49,c0_rx_pend,3PGSW (GEMAC),PRU-ICSS0 PRU1_RX_NIBBLE_ODD
Expand Down
46 changes: 0 additions & 46 deletions examples/BUILD

This file was deleted.

158 changes: 0 additions & 158 deletions examples/example.c

This file was deleted.

45 changes: 45 additions & 0 deletions examples/led_outin/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- Mode: Python -*-
cc_binary(
name = "led_outin",
srcs = [
"led_outin.c",
":irqgen",
],
additional_linker_inputs = [
"//tools/toolchain/am335x:linker_cmd",
],
linkopts = [
"$(location //tools/toolchain/am335x:linker_cmd)",
"--stack_size=0x1000",
],
deps = [
"//lib/coroutine",
"//lib/gpio",
"//lib/initproc",
"//lib/intc:service",
"//lib/log/daemon",
"//lib/rpmsg",
"//lib/time:process",
"//lib/resource",
"//tools/toolchain/am335x",
],
)

genrule(
name = "irqgen",
srcs = [
# Order is important: args[0] is all events
# Remaining args define arriving system events.
# (Only) one should set the host.
"//arch:sysevts",
"//lib/rpmsg/am335x:irq",
"//lib/time/am335x:iep_tim_cap_cmp_pend",
],
outs = [
"irq.c",
],
cmd = "./$(location //tools/cmd/irqgen:irqgen) $(SRCS) > $@",
tools = [
"//tools/cmd/irqgen",
],
)
1 change: 1 addition & 0 deletions examples/led_outin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This example flashes a LED on pin P9_25 and reads the value on P9_23.
Loading

0 comments on commit d352b8c

Please sign in to comment.