EasyManua.ls Logo

Great Scott Gadgets HackRF - Page 102

Great Scott Gadgets HackRF
104 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
HackRF
25.1.1 Jiggle SGPIO Pins From GPIO Mode
My first test was to ensure I had the right pin(s) hooked up to my scope:
// Jiggle one of the SGPIO pins in GPIO mode, to make sure
// I'm looking at the right pin on the scope.
scu_pinmux(9, 0, MD_PLN_FAST, 0);
GPIO_SetDir(4, 1L << 12, 1);
while(1) {
volatile int i;
GPIO_SetValue(4, 1L << 12);
for(i=0; i<1000; i++);
GPIO_ClearValue(4, 1L << 12);
for(i=0; i<1000; i++);
}
25.1.2 Jiggle Pins from SGPIO Mode
You can also control SGPIO pins, GPIO-style, from within the SGPIO peripheral. This helped me understand the
basics of operating the SGPIO output mux.
// Set pin to SGPIO mode, toggle output using SGPIO
// peripheral registers.
scu_pinmux(9, 0, MD_PLN_FAST, 6); // SGPIO0
// P_OUT_CFG = 4, gpio_out
// P_OE_CFG = X
LPC_SGPIO->OUT_MUX_CFG[0] = (0L << 4) | (4L << 0);
LPC_SGPIO->GPIO_OENREG |= (1L << 0);
while(1) {
volatile int i;
LPC_SGPIO->GPIO_OUTREG |= (1L << 0);
for(i=0; i<1000; i++);
LPC_SGPIO->GPIO_OUTREG &= ~(1L << 0);
for(i=0; i<1000; i++);
}
25.1.3 Serializing Data With Slice Clock Source
My first full-on SGPIO experiment involved serializing a data pattern from slice A, using slice D to generate a SG-
PIO_CLK/2 data rate. I derived the code from examples that configured the SGPIO as I2S interfaces:
// Disable all counters during configuration
LPC_SGPIO->CTRL_ENABLED = 0;
// Configure pin functions.
scu_pinmux(9, 0, MD_PLN_FAST, 6); // SGPIO0
scu_pinmux(2, 3, MD_PLN_FAST, 0); // SGPIO12
(continues on next page)
96 Chapter 25. LPC4350 SGPIO Experimentation

Table of Contents