void SPIClass::begin() { /* Set the pin mux, for the SCK, MOSI and MISO pins ONLY * * Leave the SS pin in GPIO mode (the application will control it) * but set it's direction to output and initially high */ system("echo on > /sys/devices/pci0000:00/0000:00:07.1/power/control"); //disables SPI power management pinMode(SPI_SS_GPIO_PIN, OUTPUT); digitalWrite(SPI_SS_GPIO_PIN, HIGH); muxSelectSpi(1); if(fd <= 0) { this->fd = open(LINUX_SPIDEV, O_RDWR); if (this->fd < 0) { trace_error("Failed to open SPI device\n"); return; } } /* Load default/last configuration */ this->setClockDivider(this->clkDiv); this->setBitOrder(this->bitOrder); this->setDataMode(this->mode); }
void SPIClass::begin() { /* Set the pin mux, for the SCK, MOSI and MISO pins ONLY * * Leave the SS pin in GPIO mode (the application will control it) * but set it's direction to output and initially high */ muxSelectDigitalPin(SPI_SS_GPIO_PIN); pinMode(SPI_SS_GPIO_PIN, OUTPUT); digitalWrite(SPI_SS_GPIO_PIN, HIGH); muxSelectSpi(1); this->fd = open(LINUX_SPIDEV, O_RDWR); if (this->fd < 0) { trace_error("Failed to open SPI device\n"); return; } /* Load default/last configuration */ this->setBitOrder(this->bitOrder); this->setClockDivider(this->clkDiv); this->setDataMode(this->mode); }