so I was hoping someone could help me out, pretty much I am using a raspberry pi pico with visual studio to program it in c++. I need to send a 4 digit hex value (16bits) using SPI, this can be done by either two 8 bit words or one 16 bit word. The library being used is "hardware/spi.h", I can get it to send 8 bits, for example if I want to send 0x2100, I can see the first 8 bits but nothing after.
Does anyone know a way or a different library to send the full 0x2100 as either 1 send or two 8 bit sends to have the full 0x2100.
Please see my code below, any help with this would be greatly appreciated.
#include "pico/stdlib.h"
#include <stdio.h>
#include <iostream>
#include <string.h>
#include "hardware/spi.h"
#define MOSI 3
#define SCK 2
#define CS 5
#define SPI_PORT spi0
using namespace std;
int main(){
stdio_init_all();
// 29-31 is setting up the SPI and SPI modes
spi_init(SPI_PORT, 5000000);
gpio_set_function(MOSI, GPIO_FUNC_SPI);
gpio_set_function(SCK, GPIO_FUNC_SPI);
//Config Chip Select
gpio_init(CS); // Initialise CS Pin
gpio_set_dir(CS, GPIO_OUT); // Set as output
gpio_put(CS, 1);
gpio_init(25);
gpio_set_dir(25, GPIO_OUT);
while (1){
gpio_put(1, 1);
uint16_t data [2];
uint8_t data1 [2]; //testing
data[0] = 0x2100;
gpio_put(CS, 0);
spi_write16_blocking(SPI_PORT, data, 1);
// spi_write_blocking(SPI_PORT, data1, 1);
gpio_put(CS, 1);
sleep_ms(10);
gpio_put(25, 1);
}
}