Skip to content
Snippets Groups Projects
Commit 4b15cc63 authored by Kaspar Schleiser's avatar Kaspar Schleiser
Browse files

cpu: stm32f4: use periph_common SPI functions

parent fa00154f
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,7 @@ export CPU_ARCH = cortex-m4f
# use hwtimer compatibility module
USEMODULE += hwtimer_compat
# use common periph functions
USEMODULE += periph_common
include $(RIOTCPU)/Makefile.include.cortexm_common
......@@ -90,6 +90,14 @@ typedef enum {
*/
void gpio_init_af(gpio_t pin, gpio_af_t af);
/**
* @brief declare needed generic SPI functions
* @{
*/
#define PERIPH_SPI_NEEDS_TRANSFER_BYTES
#define PERIPH_SPI_NEEDS_TRANSFER_REG
#define PERIPH_SPI_NEEDS_TRANSFER_REGS
/** @} */
#ifdef __cplusplus
}
......
......@@ -350,66 +350,6 @@ int spi_transfer_byte(spi_t dev, char out, char *in)
return 1;
}
int spi_transfer_bytes(spi_t dev, char *out, char *in, unsigned int length)
{
int trans_bytes = 0;
for (unsigned int i = 0; i < length; i++) {
char in_temp;
int trans_ret;
if (out) {
trans_ret = spi_transfer_byte(dev, out[i], &in_temp);
}
else {
trans_ret = spi_transfer_byte(dev, 0, &in_temp);
}
if (trans_ret < 0) {
return -1;
}
if (in != NULL) {
in[i] = in_temp;
}
trans_bytes++;
}
return trans_bytes++;
}
int spi_transfer_reg(spi_t dev, uint8_t reg, char out, char *in)
{
int trans_ret;
trans_ret = spi_transfer_byte(dev, reg, in);
if (trans_ret < 0) {
return -1;
}
trans_ret = spi_transfer_byte(dev, out, in);
if (trans_ret < 0) {
return -1;
}
return 1;
}
int spi_transfer_regs(spi_t dev, uint8_t reg, char *out, char *in, unsigned int length)
{
int trans_ret;
trans_ret = spi_transfer_byte(dev, reg, in);
if (trans_ret < 0) {
return -1;
}
trans_ret = spi_transfer_bytes(dev, out, in, length);
if (trans_ret < 0) {
return -1;
}
return trans_ret;
}
void spi_transmission_begin(spi_t dev, char reset_val)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment