Skip to content

Add support for SPI#442

Draft
ABIbreak wants to merge 2 commits intomainfrom
spi-protocol
Draft

Add support for SPI#442
ABIbreak wants to merge 2 commits intomainfrom
spi-protocol

Conversation

@ABIbreak
Copy link
Contributor

This PR will add support for SPI to sddf in terms of the following deliverables:

  1. Driver for the OpenTitan SPI host device with PULP patches
  2. Virtualiser for SPI
  3. Client for a SPI flash

@ABIbreak ABIbreak self-assigned this Jun 26, 2025
@ABIbreak
Copy link
Contributor Author

ABIbreak commented Jun 26, 2025

Blocking on:

  • Diagnose difference in behavior when enabling CSAAT
  • Extend recieve_data to support slices at arbitrary alignments
  • Write client for SPI flash
  • Create libspi, mirroring libi2c
  • Add support for SPI configuration (CPHA, CPOL, clock frequency) in the config struct

@ABIbreak
Copy link
Contributor Author

ABIbreak commented Jun 26, 2025

Nice-to-haves:

  • Add Javadoc comments for functions
  • Add licenses to files
  • Run clang format
  • Do outstanding TODOs that still exist in the code
  • Update examples/spi/{Makefile, build.zig, build.zig.zon}
  • Write documentation

@ABIbreak ABIbreak requested a review from omeh-a July 3, 2025 08:14
@ABIbreak
Copy link
Contributor Author

ABIbreak commented Jul 3, 2025

In the driver, config.slice_size is set manually; I will update sdfgen to populate this automatically

EDIT: done

@Ivan-Velickovic
Copy link
Collaborator

@ABIbreak does this need to be based on Lesley's I2C branch? For review it would be easier if it was just the SPI changes.

@ABIbreak
Copy link
Contributor Author

ABIbreak commented Jul 4, 2025

No, I'll rebase off of main

@ABIbreak
Copy link
Contributor Author

ABIbreak commented Jul 4, 2025

examples/spi/{Makefile, build.zig, build.zig.zon} were directly copied from the examples/i2c/, I will edit them later

}

LOG_DRIVER_ERR("Polling RX timed out\n");
return -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably use numbered error codes (ETIMEOUT? idk); instead of int returns.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably use numbered error codes (ETIMEOUT? idk); instead of int returns.

This is used internally and there's only one error case in this function, so I don't think this is necessary. We don't have a standard way of going about this though .... probably something we should write into the engineering docs 😳

}

if (poll_rx()) {
return -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above re: error codes.

uint16_t num_cmds;
void *slice_base;
// Request in-progress state
uint8_t cmd_in_progress;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is an index, is it intended that the cmd_in_progress is a smalelr type than num_cmds?

}

LOG_DRIVER_ERR("Polling RX timed out\n");
return -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably use numbered error codes (ETIMEOUT? idk); instead of int returns.

This is used internally and there's only one error case in this function, so I don't think this is necessary. We don't have a standard way of going about this though .... probably something we should write into the engineering docs 😳

Signed-off-by: George Chen <george.j.chen@student.unsw.edu.au>
Signed-off-by: George Chen <george.j.chen@student.unsw.edu.au>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants