cpu: stm32f3: use periph_common SPI functions
This commit is contained in:
parent
6c185655c8
commit
fa00154f2a
@ -3,4 +3,7 @@ export CPU_ARCH = cortex-m4f
|
|||||||
# use hwtimer compatibility module
|
# use hwtimer compatibility module
|
||||||
USEMODULE += hwtimer_compat
|
USEMODULE += hwtimer_compat
|
||||||
|
|
||||||
|
# includ common periph module
|
||||||
|
USEMODULE += periph_common
|
||||||
|
|
||||||
include $(RIOTCPU)/Makefile.include.cortexm_common
|
include $(RIOTCPU)/Makefile.include.cortexm_common
|
||||||
|
|||||||
@ -79,6 +79,15 @@ typedef enum {
|
|||||||
GPIO_AF15 /**< use alternate function 14 */
|
GPIO_AF15 /**< use alternate function 14 */
|
||||||
} gpio_af_t;
|
} gpio_af_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -334,62 +334,6 @@ int spi_transfer_byte(spi_t dev, char out, char *in)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int spi_transfer_bytes(spi_t dev, char *out, char *in, unsigned int length)
|
|
||||||
{
|
|
||||||
int i, trans_ret, trans_bytes = 0;
|
|
||||||
char in_temp;
|
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
|
||||||
if (out != NULL) {
|
|
||||||
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)
|
void spi_transmission_begin(spi_t dev, char reset_val)
|
||||||
{
|
{
|
||||||
if (dev < SPI_NUMOF) {
|
if (dev < SPI_NUMOF) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user