Do we have any update on when GPIO support will be provided for the Lime Mini?
I have spent the morning building the switching interface that I am going to use with the GPIO to switch transmit amplifiers in my Digital (DVB-S/S2) TV Transmitter, and soldering it to my Lime Mini (high stress activity!), then the last 2 hours trying to work out why my code did not work.
It’s a little frustrating when the example code provided by Myriad RF does not work - and there is no warning that it will not!
Yes - I saw the message, but I thought that it was the way that I had called it that was not supported - not the function itself.
A more useful error message might be “Command not yet implemented”
Do we know when it might be available? A number of Raspberry Pi + LimeSDR TV transmitter
(the Portsdown transmitter here: Portsdown Transmitter Wiki) users have asked me to implement the switching - and we were thinking of designing some custom hardware for the interface.
GPIO read-write is in FPGA. You can copy-modify code from LimeSDR-USB gateware and play with FPGA build tools, not a easy task or you can wait for official support. Unfortunatelly Ham radio it’s not interesting from commercial point of view so we must be patient.
If you were comfortable modifying the NIOS firmware one really quick and nasty way to do it with really minimal modification and understanding of the command system is the following:
Assuming you don’t ever want to be able to set the VCTCXO DAC to 0 or 1, which is unlikely, you could add a if statement to the firmware in the place where the DAC is updated with the new value over SPI and in the case that it is 0 or 1, dont update the DAC and toggle the GPIO accordingly.
You could then flash this image to your fpga. On the PC call LMS_WriteVCTCXO(0) or LMS_WriteVCTCXO(1) to set the GPIO to 0 or 1 from your C++ code.
Its very horrible but if you need it fast it would work and only require the insertion of a single if statement into the NIOS fw.
Thanks both for the suggestions. I’m not going to play with the FPGA images yet - I’m having enough trouble making sure that the stock ones behave!
A shame about the the low priority for hobby usage when I had understood that it was the hobbyist buzz that was a major factor in reaching the early crowdfunding targets. However, it is a great piece of kit for Digital Amateur TV transmission, so I won’t complain too loudly!
GPIO commands are currently not implemented in NIOS firmware (like for LimeSDR-USB or LimeSDR-PCIe) for LimeSDR-Mini. However it should be possible to control GPIO by writting to FPGA registers. I have made a commit that turns API GPIO commands into FPGA register writes/reads for LimeSDR-Mini.
2 GPIO pins on the edge can also be controlled and I have updated LimeSuite to allow control. You will need to use two bytes in GPIO commands to access them though.
LimeSDR GPIO control example that deals with 8 GPIO pins can be found:
@IgnasJ Thanks so much, will give it a try if i find some time this weekend.
Just came 2 mind, the underpopulated LED2 (bottom) could also be used as register controlled GPIO? Or is it just a mirror of the top LED both connected to B9/D8 for Red and Green.
And if i may suggest a feature request for the next FPGA gateway release, please consider implementing I2C as option next to just GPIO if possible. That would open up the possibility for users to connect a lot of slower speed devices (GPIO extender, I2C ADC for power/swr measurements, OLED display, etc)
Been trying to get this working with limited success up until now.
What i got working is outputs on the 8 pins, just like Dave. As well as some other output combinations. These seem to work fine from both: the cpp GPIO example and the LimeSuiteGui board control(selected LIME-USB instead LIME-MINI) @DaveG8GKQ have you tested input as well?
All tough when set to input i always get a HIGH value on all 8 pins, the measured voltage is 0V on the pin and the input value stays high regardless of me pulling the pin to GND or 3V3.
Found some useful registry documentation on github under: Register description of periphcfg module.
For quick testing i used the LimeSuiteGui SPI Module. This allows control of the 8 GPIO’s, 2 EGPIO’s, the LED and the FAN pins. Albeit still just as outputs.
For input still no luck
0x00C2 stays at 03FF (all high)
0x00C4 is set to 0000 (all input)
0x00C6 tried both 0000 and 03FF (no difference)
Limesdr Mini V1.1 GW 1.27
LimeSuite 18.10.0 build from source 2018-11-11
I can confirm that LMS_GPIODirWrite and LMS_GPIOWrite work with both LimeSDR Mini and LimeSDR USB. I am using the commands to set the GPIOs to achieve band switching between different (narrow-band) Power Amplifiers after the LimeSDR. My code fragment:
// Set up GPIOs for output
uint8_t gpio_dir = 0x8F; // set the 4 LSBs and the MSB to write
if (LMS_GPIODirWrite(device, &gpio_dir, 1) != 0)
{
fprintf(stderr, "LMS_SetupStream() : %s\n", LMS_GetLastErrorMessage());
return 1;
}
// Set band - gpio_band declared and set earlier
if (LMS_GPIOWrite(device, &gpio_band, 1)!=0)
{
fprintf(stderr, "LMS_SetupStream() : %s\n", LMS_GetLastErrorMessage());
return 1;
}
I have tried to read from the GPIOs but not succeeded; however I do not need this for my application.