pwm period is now 200us instead of the default 20ms veml6040 config is now AF_BIT | TRIG_BIT
Dependencies: mbed MMA8451Q USBDevice WakeUp vt100
Fork of afero_node_suntory_2017_06_15 by
Diff: spi/mbedSPI.cpp
- Revision:
- 0:20bce0dcc921
- Child:
- 1:b2a9a6f2c30e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/spi/mbedSPI.cpp Tue Dec 20 01:51:02 2016 +0000 @@ -0,0 +1,48 @@ +#include "mbedSPI.h" +#include "BitOrder.h" + +mbedSPI::mbedSPI() : spi(SPI_MOSI,SPI_MISO,SPI_SCLK), cs(SPI_CS_ASR_1,SPI_CS_DEASSERT) +{ + spi.format(SPI_NUM_BITS_PER_FRAME, SPI_MODE_0); + spi.frequency(SPI_FREQ); +#if defined (TARGET_KL25Z) + #ifndef SPI0_C1 + #define SPI0_C1 (*(uint8_t *)0x40076000) + #endif + SPI0_C1 |= 0x01 ; /* LSB First */ +#elif defined (TARGET_TEENSY3_1) + #define SPI0_CTAR0 ((uint32_t *)0x04002C00C) + #define LSBFE_MASK 0x01000000 + *SPI0_CTAR0 |= LSBFE_MASK ; +#endif +} + +void mbedSPI::begin() +{ +} + +void mbedSPI::beginSPI() /* settings are in this class */ +{ + cs = SPI_CS_ASSERT; + wait_us(1); +} + +void mbedSPI::endSPI() +{ + cs = SPI_CS_DEASSERT; +} + +void mbedSPI::transfer(char *bytes,int len) +{ + int i = 0; + + for(;i<len;++i) + { +#if defined (TARGET_KL25Z) || (TARGET_TEENSY3_1) + bytes[i] = spi.write(bytes[i]) ; +#else + char c = spi.write(BitOrder::flip(bytes[i])); + bytes[i] = BitOrder::flip(c); +#endif + } +} \ No newline at end of file