implementing swd with spi on stm32f3
I have a working bit-banged implementation of swd, now I want to use the spi device. The protocol is a bit odd in requiring some short input sequences. Essentially, I'm using the spi device for everything that's a nice multiple of 8 bits (disabling the MOSI pin for input), but I need to bit-bang a couple of input bits. I've successfully seized the clock, but I can't seem to read the data from the MOSI or MISO pins reconfigured as input. The key bit of code follows. The clock banging works fine, but no joy on the input. Using a logic analyzer I can see that the correct bits are coming from the SWD slave, but I'm reading all high on the input:
.ExternalClass55FF5732FB374BD098B03B2D208DE3CF p.p1 {margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Menlo;background-color:#fff8d4;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF p.p2 {margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Menlo;background-color:#fff8d4;min-height:15.0px;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF span.s1 {;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF p.p1 {margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Menlo;color:#cb3bff;background-color:#fff8d4;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF p.p2 {margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Menlo;color:#2f9f23;background-color:#fff8d4;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF p.p3 {margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Menlo;background-color:#fff8d4;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF p.p4 {margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Menlo;background-color:#fff8d4;min-height:15.0px;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF p.p5 {margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Menlo;color:#5934ff;background-color:#fff8d4;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF span.s1 {;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF span.s2 {color:#000000;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF span.s3 {color:#2f9f23;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF span.s4 {color:#5934ff;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF span.s5 {color:#c2981e;} .ExternalClass55FF5732FB374BD098B03B2D208DE3CF span.s6 {color:#cb3bff;}tatic
inline
uint32_t
SWDIO_IN
(){
uint8_t
b
;
LL_GPIO_ResetOutputPin(tgt_SWDCLK_GPIO_Port, tgt_SWDCLK_Pin);
b = LL_GPIO_IsInputPinSet(tgt_SWDIO_GPIO_Port, tgt_SWDIO_Pin);
delay();
LL_GPIO_SetOutputPin(tgt_SWDCLK_GPIO_Port, tgt_SWDCLK_Pin);
return
b;
}
static
void
_SetSWDIOasOutput
(){
LL_GPIO_SetPinMode(tgt_SWDIO_GPIO_Port, tgt_SWDIO_Pin, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinMode(tgt_SWDCLK_GPIO_Port, tgt_SWDCLK_Pin, LL_GPIO_MODE_ALTERNATE);
}
static
void
_SetSWDIOasInput
(){
LL_GPIO_SetPinMode(tgt_SWDIO_GPIO_Port, tgt_SWDIO_Pin, LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinMode(tgt_SWDCLK_GPIO_Port, tgt_SWDCLK_Pin, LL_GPIO_MODE_OUTPUT);
}
