summaryrefslogtreecommitdiffstats
path: root/watch-library/hardware
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-01-26 22:39:09 -0500
committerJoey Castillo <joeycastillo@utexas.edu>2022-01-26 22:40:49 -0500
commit523a5d2f0b3f0d79b16784470870935313dd5775 (patch)
treeb7631b071432bba90eb14aa9540f97c01c5503ac /watch-library/hardware
parentb2dbc4feeb48697fbbdbb7740b6db552a45b3c02 (diff)
downloadSensor-Watch-523a5d2f0b3f0d79b16784470870935313dd5775.tar.gz
Sensor-Watch-523a5d2f0b3f0d79b16784470870935313dd5775.tar.bz2
Sensor-Watch-523a5d2f0b3f0d79b16784470870935313dd5775.zip
implement SPI flash chip
Diffstat (limited to 'watch-library/hardware')
-rw-r--r--watch-library/hardware/hw/driver_init.c10
-rw-r--r--watch-library/hardware/watch/watch_spi.c16
2 files changed, 12 insertions, 14 deletions
diff --git a/watch-library/hardware/hw/driver_init.c b/watch-library/hardware/hw/driver_init.c
index 3e097a8e..5eec7bcd 100644
--- a/watch-library/hardware/hw/driver_init.c
+++ b/watch-library/hardware/hw/driver_init.c
@@ -90,16 +90,6 @@ void SPI_0_PORT_init(void) {
gpio_set_pin_direction(A1, GPIO_DIRECTION_OUT);
gpio_set_pin_function(A1, PINMUX_PB01C_SERCOM3_PAD3);
-
- gpio_set_pin_level(A3,
- // <y> Initial level
- // <id> pad_initial_level
- // <false"> Low
- // <true"> High
- true);
-
- // Set pin direction to output
- gpio_set_pin_direction(A3, GPIO_DIRECTION_OUT);
}
void SPI_0_CLOCK_init(void) {
diff --git a/watch-library/hardware/watch/watch_spi.c b/watch-library/hardware/watch/watch_spi.c
index df68bbaa..8cdebb08 100644
--- a/watch-library/hardware/watch/watch_spi.c
+++ b/watch-library/hardware/watch/watch_spi.c
@@ -37,10 +37,18 @@ void watch_disable_spi(void) {
spi_io = NULL;
}
-void watch_spi_send(uint8_t *buf, uint16_t length) {
- io_write(spi_io, buf, length);
+bool watch_spi_write(const uint8_t *buf, uint16_t length) {
+ return !!io_write(spi_io, buf, length);
}
-void watch_spi_receive(uint8_t *buf, uint16_t length) {
- io_read(spi_io, buf, length);
+bool watch_spi_read(uint8_t *buf, uint16_t length) {
+ return !!io_read(spi_io, buf, length);
+}
+
+bool watch_spi_transfer(const uint8_t *data_out, uint8_t *data_in, uint16_t length) {
+ struct spi_xfer xfer;
+ xfer.txbuf = (uint8_t *)data_out;
+ xfer.rxbuf = data_in;
+ xfer.size = length;
+ return !!spi_m_sync_transfer(&SPI_0, &xfer);
}