You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2018/11/23 16:16:39 UTC
[mynewt-core] 07/26: hw/hal: Add hal_spi_init_hw
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit e1ccfe3412f2a8a68ac354c8c3c89bc07c84ab10
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Nov 8 17:27:36 2018 +0100
hw/hal: Add hal_spi_init_hw
This adds init function which gets generic structure as a parameter as
opposed to hal_spi_init which requires MCU-specific structure. This is
to make it compatible with latest similar addition to I2C HAL.
---
hw/hal/include/hal/hal_spi.h | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/hw/hal/include/hal/hal_spi.h b/hw/hal/include/hal/hal_spi.h
index 092cbf7..af987ba 100644
--- a/hw/hal/include/hal/hal_spi.h
+++ b/hw/hal/include/hal/hal_spi.h
@@ -60,6 +60,14 @@ extern "C" {
/* Prototype for tx/rx callback */
typedef void (*hal_spi_txrx_cb)(void *arg, int len);
+/** SPI controller hardware settings */
+struct hal_spi_hw_settings {
+ uint8_t pin_sck;
+ uint8_t pin_mosi;
+ uint8_t pin_miso;
+ uint8_t pin_ss;
+};
+
/**
* since one spi device can control multiple devices, some configuration
* can be changed on the fly from the hal
@@ -89,6 +97,20 @@ struct hal_spi_settings {
int hal_spi_init(int spi_num, void *cfg, uint8_t spi_type);
/**
+ * Initialize SPI controller
+ *
+ * This initializes SPI controller hardware before 1st use. Shall be called
+ * only once.
+ *
+ * @param spi_num Number of SPI controller
+ * @param cfg Configuration
+ *
+ * @return 0 on success, non-zero error code on failure
+ */
+int hal_spi_init_hw(uint8_t spi_num, uint8_t spi_type,
+ const struct hal_spi_hw_settings *cfg);
+
+/**
* Configure the spi. Must be called after the spi is initialized (after
* hal_spi_init is called) and when the spi is disabled (user must call
* hal_spi_disable if the spi has been enabled through hal_spi_enable prior