I would like to use LB365 for driving different peripheral devices, as those MCUs are pretty flexible and their pins can have a multitude of purposes I wold like to know if there is an inventory of available interfaces and GPIO pins or if somebody can share some insight of what is actually available in the current hardware incarnation, specifically:
- The setup is: on LB365 with the 5Mp sensor module, USB and Ethernet interfaces are used, on DVI or LCD is used.
In this case:
1) Is the SPI interface available, where is located on the board connectors and what software configuration is necessary ?
2) Is the I2C interface available, where is located on the board connectors, what software configuration is necessary to activate/access it and
if there is a map of the I2C devices already attached to this bus to avoid address conflicts ?
3) What other GPIO resources are available, where are they on the connectors and what need to be done to configure and access them ?
IMHO this should be an integral part of the documentation, if there is ready such a chapter please kindly direct me to it.
Thank you for your help and cheers,
Maybe it should be part of the documentation but the DM365 is a pretty complicated chip and there are a lot of options for the pin functions, so it would be a lot of work for someone...
On the Leopardboard they provide the J8 connector. You will need to get the schematic for the Leopardboard and look at that. Then trace back the connections to the DM365 pins, and figure out what they are capable of. Just looking, it seems that via J8 you should be able to get a combination of GPIO, SPI, I2C, UART1, SD1(MMC) and perhaps other stuff depending on your application. We have discrete I/O's working (we use them for PTZ camera), we did not yet try out much else, but I'm sure all the functions can work. We will be using UART1 at some point to support RS485 PTZ camera control via Pelco-D protocol, please see my related post in the forum.
Find the TI document sprufg5a.pdf. This has details about the pin multiplexers (PINMUX) in the DM365. By setting those registers, you can change the operating mode of the various pins joined to the J8 connector. For example, if you wanted to use J8 expansion pin 1 as a GPIO, the schematic tells you it is wired to the DM365 pin GIO38/SD1_DATA0/EM_A15, and the guide tells you that you have to set PINMUX4 bits 22-23 to 0 to make it behave as a GPIO.
Now you have to change the pin multiplexer assignments in the kernel. So open the file arch/arm/mach-davinci/dm365.c in your kernel. There you will see stuff like MUX_CFG(DM365,<name>,<n>,<b>,<w>,<v>,false). The <name> elements are #defined in the file arch/arm/mach-davinci/include/mach/mux.h where there is an enumeration list specially for the DM365. If you want to add new elements, I suggest you add them at the end of the list, doing otherwise may require you to recompile the whole kernel from clean, as the make system doesn't seem to pick up modifications to the include file. For example, you could add DM365_GPIO38 there at the end of the enum list and you should be okay. The MUX_CFG is a macro and the fields have the following meanings: <name> is just an enumeration in mux.h, <n> is the pinmux number to control, <b> is the bit offset of the field you want to set, <w> is its width e.g. 1 means 1 bit, 3 means 2 bits, 7 means 3 bits etc., and v is the value you want to set into the bitfield e.g. 0-3 if it's a 2-bit-wide field. So, if we want to enable the GPIO38, declare DM365_GPIO38 in the mux.h then we have to do: MUX_CFG(DM365,GPIO38,4, 22, 3,0,false). That is, set PINMUX4 bits 22-23 to 0.
Note that each pin mux field should only be set once. So if you see there are other MUX_CFG with the same <n> and <b> values, you should comment them out. It's only necessary to have one MUX_CFG per bitfield, if there's more only the last one will have effect.
For GPIO's I like to use the sysfs interface of Linux to control them easily, especially if speed is not an issue. But that needs to be configured in the BSP. You could do this in the main BSP. Edit arch/arm/mach-davinci/board-dm365-leopard.c and add some lines into dm365_leopard_init, for example davinci_cfg_reg(DM365_GPIO38); gpio_request(38,"GPIO38_J8_PIN1" );gpio_direction_output(38,0);gpio_export(38,1);. Next, you have to enable the sysfs interface in the kernel configuration. So do 'make config', and enable the Kernel config/Drivers/GPIO Support setting '/sys/class/gpio/... (sysfs interface)' . Now after rebuilding your kernel and rebooting, when you do 'ls /sys/class' you will see a gpio directory /sys/class/gpio/gpio38. Now you can read and write values just by doing stuff like 'cat /sys/class/gpio/gpio38/value' and 'echo "1" >/sys/class/gpio/gpio38/value'.
There are a couple of LED's on the Leopardboard and you can use those to test your GPIO configuring skills. Those are on GPIO 57 and 58. My dm365.c file has MUX_CFG(DM365,GPIO58,2,6,1,0, false) to enable those. Note this pinmux field disables an entire external memory bus (which is not used anyway on Leopardboard) and makes all of GPIO57-64 enabled, so really it's not just GPIO58. I actually added MUX_CFG(DM365,GPIO57,2,6,1,0, false) in the file as well, it's redundant but harmless.
Hope this is not too obscure :)
Mark Lesha, ANSTO