1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

cpu: saml21: use periph_common SPI functions

This commit is contained in:
Kaspar Schleiser 2015-08-13 15:20:39 +02:00
parent 0a859b91ee
commit 21c774fd82
3 changed files with 12 additions and 35 deletions

View File

@ -6,4 +6,7 @@ export CFLAGS += -DDONT_USE_CMSIS_INIT
# use the hwtimer compatibility module
USEMODULE += hwtimer_compat
# use common periph functions
USEMODULE += periph_common
include $(RIOTCPU)/Makefile.include.cortexm_common

View File

@ -87,6 +87,15 @@ typedef enum {
*/
void gpio_init_mux(gpio_t dev, gpio_mux_t mux);
/**
* @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
}
#endif

View File

@ -219,41 +219,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 transfered = 0;
int ret = 0;
DEBUG("out*: %p out: %x length: %x\n", out, *out, length);
while (length--) {
if ((ret = spi_transfer_byte(dev, *out, in)) < 0) {
return ret;
}
transfered += ret;
if (out) {
out++;
}
if (in) {
in++;
}
}
return transfered;
}
int spi_transfer_reg(spi_t dev, uint8_t reg, char out, char *in)
{
spi_transfer_byte(dev, reg, NULL);
return spi_transfer_byte(dev, out, in);
}
int spi_transfer_regs(spi_t dev, uint8_t reg, char *out, char *in, unsigned int length)
{
spi_transfer_byte(dev, reg, NULL);
return spi_transfer_bytes(dev, out, in, length);
}
void spi_poweron(spi_t dev)
{
SercomSpi* spi_dev = spi[dev].dev;