Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Goal

Facilitate hardware triggering firmware actions.

E.g.

  • Read ADC

  • Interact with GPIO

  • SPI

  • I2C

  • UART

  • CAN messages

  • PWM - later

Requirements

MVP

  • Python library to be accessed via python shell

  • Call functions like

gpio_set/get(port, pin) -> bool # re-init pin every time this is called
adc_read_raw/converted(gpio_address) -> int
spi_exchange(spi_port, mode, tx: list, rx_len, baudrate=None, cs=None) -> rx: list # re-init spi for given port every call
i2c_write(i2c_port, addr, tx: list, reg=None) -> None
i2c_read(i2c_port, addr, rx_len, reg=None) -> rx: list
can_send_raw(id, data: list) -> None
load_dbc(path) -> None  # could be auto-loaded in 'make babydriver'
can_send_msg(msg_name, *data) -> None  # auto checks based on dbc if valid

Details

Two components: python library, and firmware project

Generic status message:

  • timeout

  • success

  • add as we need

Flow for gpio:

  • register rx handler for gpio_set message

  • handler inits gpio port with output and given state

Example: gpio_set CAN message could look like:

id: gpio_set
data:
uint8 port,
uint8 pin,
bool state

Flow for spi:

metadata msg 1:
uint16 port, mode, tx_len, rx_len
metadata msg 2:
uint32 baudrate
uint8 cs_port, cs_pin
expect enough messages to cover tx_len bytes (8 * uint8)
then, return messages:
listen for enough messages to cover rx_len (8 * uint8)

so, messages required:
- spi_metadata_1
- spi_metadata_2
- babydriver_data_tx
- babydriver_data_rx

Task list

  • setup project structure

    • make new C project

      • init CAN, write main() method, other setup (not registering specific rx handlers)

    • includes a scripts folder with python script

    • setup makefile to allow make babydriver

      • program babydriver

      • puts you in a python shell with baby driver library loaded

  • write simple CAN abstraction layer

    • sending message, waiting for message, initializing CAN

    • have simple representation of can message

    • the pack() function takes in a list of tuples (len_in_bytes, val)

  • setup gpio functions in python

    • refer to this doc for details on flow

  • setup gpio functions in C and create CAN message in codegen-tooling

    • refer to this doc for details

  • etc. for other python and C implementations of firmware functions

  • No labels