I am using a Raspberry Pi(Model 1 B+) and an oscilloscope in order to program SPI with C. I am doing this by using direct access to the GPIO register.
The datasheet of BCM2835: https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
The problem is that if I do access the register using a bitwise operation as following :
GPSET0 |= 1 << 8;
it also modifies the GPIO pin 11. I think I heard some of GPIO pins are hard-wired together. Is it because of that? But if I don't use bitwise operation, i.e:
GPSET0 = 1 << 8
It only modifies the GPIO pin 8.
I need advice. Thank you.
P.P.S This is how I initialised GPSET0 and gpiomem is the pointer stored after mapping the memory.
#define GPFSEL0 gpiomem
#define GPFSEL1 gpiomem
#define GPFSEL2 gpiomem
#define GPFSEL3 gpiomem
#define GPSET0 gpiomem
#define GPSET1 gpiomem
#define GPCLR0 gpiomem
#define GPCLR1 gpiomem
#define GPLEV0 gpiomem
#define GPLEV1 gpiomem
#define SEL_FNC(gpfsel, pin, fnc) gpfsel = (gpfsel & (~((0x7)<<(pin*3)))) | (fnc << (pin * 3))
#define SEL_OUTPUT 0x1
#define SEL_INPUT 0x0
extern volatile uint32_t *gpiomem;
While the SPI library offered is precise, it seems rather slow because of the delay between the chip select and the data transmission. a few tens of micro-seconds. (To be precise 33.6us but this doesn't work for me because I need to refresh a 128x160 LCD module using ST7735. Taking account of this alone gives me a calculation of 600ms to refresh a screen, approximately) There is a bit longer delay until next transmission.
Maybe I am doing this wrong. If someone can give me an insight into this, that'd be great.