SparkFun will be closing on Monday for Memorial Day (5/28). Orders placed after 2pm MT on Friday (5/25) will process and ship out on Tuesday (5/29).


Member Since: November 21, 2011

Country: United States

  • (sorry for the formatting, don’t know how to post properly on this forum) Yep, i finally sorted it out … Note that the following is for the SPI1 port, but can be easily modified to match the SPI2 or SPI3 port if available …

    • In “_spi.h”, include the “stdint.h” and remove the “pins_arduino.h”

    • In “spi.c”, include headers “Spi.h”, “libmaple.h”, “spi.h”, “wirish.h”

    • In “spi.c”, declare the pins as follow: void SpiDevice::initPins() { pinMode(BOARD_SPI1_MOSI_PIN, OUTPUT_AF_PP); pinMode(BOARD_SPI1_MISO_PIN, INPUT); pinMode(BOARD_SPI1_SCK_PIN, OUTPUT_AF_PP); pinMode(_selectPin, OUTPUT);
      deselect(); }
    • You have to create the “OUTPUT_AF_PP” case in “wirish_digital.cpp” and “io.h” like this: case OUTPUT_AF_PP: outputMode = GPIO_AF_OUTPUT_PP; pwm = false; break;
    • In “spi.c”, to initialize (based on spi_init and spi_reconfigure taken from spi.c): void SpiDevice::initSpi() { rcc_clk_enable(SPI1->clk_id); rcc_reset_dev(SPI1->clk_id); //Disable spi_irq_disable(SPI1, SPI_INTERRUPTS_ALL); spi_peripheral_disable(SPI1); //Mode hardware (to manually drive the NSS pin with the select/deselect functions) //SC16IS750 supports 4 Mbit/s maximum SPI clock speed means this can theorically handle the SPI_BAUD_PCLK_DIV_32 (2.25 MHz) divider … //speed = SPI_BAUD_PCLK_DIV_64 = 1.125 MHz //speed = SPI_BAUD_PCLK_DIV_32 = 2.25 MHz //speed = SPI_BAUD_PCLK_DIV_16 = 4.5 MHz SPI1->regs->CR1 = SPI_CR1_SPE | SPI_BAUD_PCLK_DIV_32 | SPI_FRAME_MSB | SPI_DFF_8_BIT | SPI_CR1_MSTR | SPI_MODE_0; SPI1->regs->CR2 = SPI_CR2_SSOE; //enable spi_peripheral_enable(SPI1); //clear registers by reading them int clr = 0; clr = SPI1->regs->SR; clr = SPI1->regs->DR; clr = SPI1->regs->CR1; clr = SPI1->regs->CR2; //flush select(); while((SPI1->regs->SR & SPI_SR_BSY) == SPI_SR_BSY); deselect(); }
    • In “_spi.c”, the transfer function became: byte SpiDevice::transfer(volatile byte data) { // Start the transmission SPI1->regs->DR = data; // Wait for the end of the transmission while((SPI1->regs->SR & SPI_SR_TXE) != SPI_SR_TXE); // Wait for the end of the reception while((SPI1->regs->SR & SPI_SR_RXNE) != SPI_SR_RXNE); // Return the received byte return (SPI1->regs->DR); }
    • i also had to rename the “ring_buffer” variable in parsedstream because it conflict with a maple variable.
    • if debugging is activated (i.e ERROR_LEVEL > 0 in debug.h), think about replacing “serial.print” by “SerialUSB.print”)
  • Does anyone succeeded in modifying the library for use with the Maple?

No public wish lists :(