TS-7400 V2 DIO: Difference between revisions

From embeddedTS Manuals
No edit summary
(Update CPU manual URL)
 
(16 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This board uses CPU DIO, typically there are 4 functions associated with each physical pin (I2C, PWM, SPI, DIO, etc).  See the [http://cache.freescale.com/files/dsp/doc/ref_manual/MCIMX28RM.pdf CPU manual] for the complete listing and for information on how to control these DIO.<br><br>
This board uses CPU DIO, typically there are 4 functions associated with each physical pin (I2C, PWM, SPI, DIO, etc).  See the [https://www.nxp.com/docs/en/reference-manual/MCIMX28RM.pdf CPU manual] for the complete listing and for information on how to control these DIO.<br><br>
Note that most of the pins start in their "Function" mode and must be set to DIO mode to be able to be used as DIO.  Be aware that doing this on a running system may have adverse effects if there are kernel drivers trying to use specific pins in their peripheral mode(s).<br><br>
Note that most of the pins start in their "Function" mode and must be set to DIO mode to be able to be used as DIO.  Be aware that doing this on a running system may have adverse effects if there are kernel drivers trying to use specific pins in their peripheral mode(s).<br><br>
DIO numbers are referenced in bank_pin notation in the table below.  This makes associating pins with DIO registers much simpler when looking at the manual.  The example code below is also based around using the bank and pin notation.<br>
DIO numbers are referenced in <source inline><bank>_<pin></source> notation in the table below.  This makes associating pins with DIO registers much simpler when looking at the manual.  The example code below is also based around using the bank and pin notation.
 
DIO can be directly manipulated with <source inline>tshwctl</source>, for example:
<source lang=bash>
tshwctl --setdio 3_25 #Set pin 1 of the 26 pin header high
tshwctl --clrdio 0_17 #Turn on the red LED by setting the pin low
tshwctl --getdio 1_16,1_17 #Get the input state of pin 1 and 3 of the 44 pin header
</source>
See the end of this section for example software to manipulate DIO pins.
<br>
<br>
<br>


==Upper header pin-out (26-pin)==
===Upper header pin-out (26-pin)===
{|
|
{| class="zebra wikitable sortable"
{| class="zebra wikitable sortable"
! Pin #
! Pin #
Line 15: Line 26:
|-
|-
| 2
| 2
| SD_BOOT#
| M0_SW_CLK
| Boot mode pin (SD or NAND)
| Reserved
|-
|-
| 3
| 3
Line 23: Line 34:
|-
|-
| 4
| 4
| GND
| M0_SW_DIO
| Ground
| Reserved
|-
|-
| 5
| 5
| FPGA_DIO_0
| CPU DIO1_7
| DIO (Will change in next rev)
| [[#DIO|CPU DIO1_7]]
|-
|-
| 6
| 6
Line 44: Line 55:
| 9
| 9
| SPI_MISO <ref name="spiconn">These two SPI ports are electrically connected and are the same interface</ref>
| SPI_MISO <ref name="spiconn">These two SPI ports are electrically connected and are the same interface</ref>
| [[#DIO|CPU DIO2_04]] or [[#SPI|SPI MISO]]
| [[#DIO|CPU DIO2_4]] or [[#SPI|SPI MISO]]
|-
|-
| 10
| 10
| 3.3V
| AUX 3.3V
| 3.3V Output
| 3.3V Output
|-
|-
| 11
| 11
| FPGA_DIO_1
| CPU DIO1_8
| DIO (Will change in next rev)
| [[#DIO|CPU DIO1_8]]
|-
|-
| 12
| 12
Line 59: Line 70:
|-
|-
| 13
| 13
| FPGA_DIO_2
| CPU DIO1_9
| DIO (Will change in next rev)
| [[#DIO|CPU DIO1_9]]
|-
|-
| 14
| 14
Line 72: Line 83:
| 16
| 16
| HARD_REBOOT#
| HARD_REBOOT#
| External reset input
| External reset switch input
|-
|-
| 17
| 17
| FPGA_DIO_3
| CPU DIO1_10
| DIO (Will change in next rev)
| [[#DIO|CPU DIO1_10]]
|-
|-
| 18
| 18
Line 91: Line 102:
|-
|-
| 21
| 21
| FPGA_DIO_04
| CPU DIO1_11
| DIO (Will change in next rev)
| [[#DIO|CPU DIO1_11]]
|-
|-
| 22
| 22
| USB_OTG_P
| USB_OTG_P
| i.MX286 USB OTG data
| i.MX286 USB OTG data (host mode only)
|-
|-
| 23
| 23
| FPGA_DIO_5
| CPU DIO1_12
| DIO (Will change in next rev)
| [[#DIO|CPU DIO1_12]]
|-
|-
| 24
| 24
| USB_OTG_M
| USB_OTG_M
| i.MX286 USB OTG data
| i.MX286 USB OTG data (host mode only)
|-
|-
| 25
| 25
| DIO_25
| DIO_25
| [[#DIO|CPU DIO1_25]]
| [[#DIO|CPU DIO1_25]](1.6v)
|-
|-
| 26
| 26
| USB_SW_5V
| USB_SW_5V
| Switched USB 5V power
| Switched USB 5V power
|}
| [[File:TS-7400_V2_26_Pin.png|400px]]
|}
|}


==Lower header pin-put (40-pin)==
===Lower header pin-put (40-pin)===
{|
|
{| class="zebra wikitable sortable"
{| class="zebra wikitable sortable"
! Pin #
! Pin #
Line 171: Line 186:
| 13
| 13
| CAN_RX0
| CAN_RX0
| [[#DIO|CPU DIO3_13]] or [[#CAN|CAN RX0]]
| [[#DIO|CPU DIO0_23]] or [[#CAN|CAN RX0]] / [[#DIO|CPU DIO2_21]]
|-
|-
| 14
| 14
| CAN_RX1
| CAN_RX1
| [[#DIO|CPU DIO3_15]] or [[#CAN|CAN RX1]]
| [[#DIO|CPU DIO0_19]] or [[#CAN|CAN RX1]] / [[#DIO|CPU DIO3_02]]
|-
|-
| 15
| 15
| CAN_TX0
| CAN_TX0
| [[#DIO|CPU DIO3_12]] or [[#CAN|CAN TX0]]
| [[#DIO|CPU DIO0_22]] or [[#CAN|CAN TX0]] / [[#DIO|CPU DIO2_20]]
|-
|-
| 16
| 16
| CAN_TX1
| CAN_TX1
| [[#DIO|CPU DIO3_14]] or [[#CAN|CAN TX1]]
| [[#DIO|CPU DIO0_18]] or [[#CAN|CAN TX1]] / [[#DIO|CPU DIO3_03]]
|-
|-
| 17
| 17
Line 226: Line 241:
|-
|-
| 27
| 27
| ADC0
| LRADC_ADC1
| [[#ADC|i.MX286 ADC0]]
| [[#ADC|i.MX28 LRADC 1]]
|-
|-
| 28
| 28
| ADC1
| LRADC_ADC2
| [[#ADC|i.MX286 ADC1]]
| [[#ADC|i.MX28 LRADC 2]]
|-
|-
| 29
| 29
| ADC2
| LRADC_ADC3
| [[#ADC|i.MX286 ADC2]]
| [[#ADC|i.MX28 LRADC 3]]
|-
|-
| 30
| 30
| ADC3
| HSADC
| [[#ADC|i.MX283 ADC3]]
| [[#ADC|i.MX28 HSADC]]
|-
|-
| 31
| 31
Line 281: Line 296:
| [[#DIO|CPU DIO2_07]] or [[#SPI|SPI Clock]]
| [[#DIO|CPU DIO2_07]] or [[#SPI|SPI Clock]]
|}
|}
| [[File:TS-7400_V2_40_Pin.png|400px]]
|}
===Other===
{| class="zebra wikitable sortable"
!Name
!DIO
|-
| GRN_LED#
| [[#DIO|CPU DIO0_28]]
|-
| RED_LED#
| [[#DIO | CPU DIO0_17]]
|-
| EN_ETH_POWER#
| [[#DIO | CPU DIO0_6]]
|-
| EN_USB_5V
| [[#DIO | CPU DIO1_27]]
|-
| EN_CAN#
| [[#DIO | CPU DIO3_30]]
|}


<references/>
<references/>


Example code for DIO manipulation:
Example code for CPU DIO manipulation:
<source lang="c">
<source lang="c">
#include <assert.h>
#include <assert.h>
Line 373: Line 412:
}
}
</source><br>
</source><br>
tsctl can also be used to manipulate the DIO of the TS-7400_V2, a tarball of libtsctl can be found [ftp://ftp.embeddedarm.com/ts-arm-sbc/ts-7670-linux/sources/libtsctl-7400_V2.tar.gz here].  See the [[Tsctl|tsctl]] page for more information.

Latest revision as of 17:14, 29 June 2020

This board uses CPU DIO, typically there are 4 functions associated with each physical pin (I2C, PWM, SPI, DIO, etc). See the CPU manual for the complete listing and for information on how to control these DIO.

Note that most of the pins start in their "Function" mode and must be set to DIO mode to be able to be used as DIO. Be aware that doing this on a running system may have adverse effects if there are kernel drivers trying to use specific pins in their peripheral mode(s).

DIO numbers are referenced in <bank>_<pin> notation in the table below. This makes associating pins with DIO registers much simpler when looking at the manual. The example code below is also based around using the bank and pin notation.

DIO can be directly manipulated with tshwctl, for example:

tshwctl --setdio 3_25 #Set pin 1 of the 26 pin header high
tshwctl --clrdio 0_17 #Turn on the red LED by setting the pin low
tshwctl --getdio 1_16,1_17 #Get the input state of pin 1 and 3 of the 44 pin header

See the end of this section for example software to manipulate DIO pins.

Upper header pin-out (26-pin)

Pin # Name Function
1 I2C_DAT CPU DIO3_25 or I2C Data
2 M0_SW_CLK Reserved
3 GND Ground
4 M0_SW_DIO Reserved
5 CPU DIO1_7 CPU DIO1_7
6 I2C_CLK CPU DIO3_24 or I2C Clock
7 DEBUG_TXD Debug UART TXD
8 DEBUG_RXD Debug UART RX
9 SPI_MISO [1] CPU DIO2_4 or SPI MISO
10 AUX 3.3V 3.3V Output
11 CPU DIO1_8 CPU DIO1_8
12 SPI_MOSI [1] CPU DIO2_06 or SPI MOSI
13 CPU DIO1_9 CPU DIO1_9
14 SPI_CLK [1] CPU DIO2_07 or SPI clock
15 5V 5V regulated power input
16 HARD_REBOOT# External reset switch input
17 CPU DIO1_10 CPU DIO1_10
18 GND Ground
19 DIO_19 CPU DIO1_24
20 GND Ground
21 CPU DIO1_11 CPU DIO1_11
22 USB_OTG_P i.MX286 USB OTG data (host mode only)
23 CPU DIO1_12 CPU DIO1_12
24 USB_OTG_M i.MX286 USB OTG data (host mode only)
25 DIO_25 CPU DIO1_25(1.6v)
26 USB_SW_5V Switched USB 5V power
TS-7400 V2 26 Pin.png

Lower header pin-put (40-pin)

Pin # Name Function
1 DIO_00 CPU DIO1_16
2 3.3V 3.3V Output
3 DIO_01 CPU DIO1_17
4 DIO_02 CPU DIO1_18
5 DIO_03 CPU DIO1_19
6 DIO_04 CPU DIO1_20
7 DIO_05 CPU DIO1_21
8 DIO_06 CPU DIO1_22
9 DIO_07 CPU DIO1_23
10 DIO_08 CPU DIO1_15
11 DIO_09 CPU DIO1_14
12 GND Ground
13 CAN_RX0 CPU DIO0_23 or CAN RX0 / CPU DIO2_21
14 CAN_RX1 CPU DIO0_19 or CAN RX1 / CPU DIO3_02
15 CAN_TX0 CPU DIO0_22 or CAN TX0 / CPU DIO2_20
16 CAN_TX1 CPU DIO0_18 or CAN TX1 / CPU DIO3_03
17 UART3_TXD CPU DIO2_19 or UART3
18 5V 5V regulated power input
19 DIO_15 CPU DIO3_29 or PWM4
20 UART2_RXD CPU DIO2_16 or UART2
21 UART2_TXD CPU DIO2_17 or UART2
22 UART0_TXD CPU DIO3_01 or UART0
23 UART0_RXD CPU DIO3_00 or UART0
24 UART1_RXD CPU DIO3_04 or UART1
25 UART1_TXD CPU DIO3_05 or UART1
26 UART3_RXD CPU DIO2_18 or UART3
27 LRADC_ADC1 i.MX28 LRADC 1
28 LRADC_ADC2 i.MX28 LRADC 2
29 LRADC_ADC3 i.MX28 LRADC 3
30 HSADC i.MX28 HSADC
31 GND Ground
32 I2S_BIT_CLK CPU DIO3_22 or I2S Clock
33 I2S_TXD CPU DIO3_23 or I2S TXD
34 I2S_FRAME CPU DIO3_21 or I2S Frame
35 I2S_MCLK CPU DIO3_20 or I2S MCLK
36 I2S_RXD CPU DIO3_26 or I2S RXD
37 SPI_MOSI [1] CPU DIO2_06 or SPI MOSI
38 SPI_MISO [1] CPU DIO2_04 or SPI MISO
39 SPI_CS# [1] CPU DIO2_05 or SPI Chip select
40 SPI_CLK [1] CPU DIO2_07 or SPI Clock
TS-7400 V2 40 Pin.png

Other

Name DIO
GRN_LED# CPU DIO0_28
RED_LED# CPU DIO0_17
EN_ETH_POWER# CPU DIO0_6
EN_USB_5V CPU DIO1_27
EN_CAN# CPU DIO3_30


  1. 1.0 1.1 1.2 1.3 1.4 1.5 1.6 These two SPI ports are electrically connected and are the same interface

Example code for CPU DIO manipulation:

#include <assert.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#define DIO_Z 2
volatile unsigned int *pinctl = NULL;

/*******************************************************************************
* setdiopin: accepts a DIO register and value to place in that DIO pin.
*   Values can be 0 (low), 1 (high), or 2 (z - high impedance).
*******************************************************************************/
void setdiopin(int bank, int pin, int val)
{
	if(val == 2) {
		pinctl[((0xB00) + (0x10 * bank) + 0x8)/4] = (0x1 << pin);
	} else {
		pinctl[((0x700) + (0x10 * bank) + (0x8 / (val+1)))/4] =
		  (0x1 << pin);
		pinctl[((0xB00) + (0x10 * bank) + 0x4)/4] = (0x1 << pin);
	}	
}
/*******************************************************************************
* getdiopin: accepts a DIO pin number and returns its value.  
*******************************************************************************/
int getdiopin(int bank, int pin)
{
	return (((pinctl[((0x900) + (0x10 * bank))/4]) >> pin) & 0x1);
}

/*******************************************************************************
* Main: accept input from the command line and act accordingly.
*******************************************************************************/
int main(int argc, char **argv)
{
	int devmem = 0;
	int pin, bank, reg = 0, muxpin;
	int val;
	int returnedValue;
         
	// Check for invalid command line arguments
	if ((argc > 4) | (argc < 3)) {
		printf("Usage: %s bank pin [0|1|2]>\n", argv[0]);
		return 1;
	}
   
	// We only want to get val if there are more than 3 command line arguments
	if (argc == 3) {
		bank = strtoul(argv[1], NULL, 0);
		pin = strtoul(argv[2], NULL, 0);
		val = 0;
	}
	else {
		bank = strtoul(argv[1], NULL, 0);
		pin = strtoul(argv[2], NULL, 0);
		val = strtoul(argv[3], NULL, 0);
	}

	assert(bank >= 0 && bank < 5);
	assert(pin >= 0 && pin < 32);
	assert(val >=0 && val < 3);

	devmem = open("/dev/mem", O_RDWR|O_SYNC);
	pinctl = mmap(0, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, devmem, 0x80018000);

	/* We determine what muxsel reg we need, and set the right pin to DIO*/
	if(pin > 15) {
		reg = 1;
		muxpin = pin - 16;
	} else muxpin = pin; 
	pinctl[((0x100) + (0x20 * bank) + (0x10 * reg) + 0x4)/4] = (0x3 << (muxpin * 2));
	
	// Parse through the command line arguments, check for valid inputs, and exec
	if (argc == 3) {
		returnedValue = getdiopin(bank, pin);
		printf("dio_%d_%d=%d\n", bank, pin, returnedValue);
	} else if(argc == 4) {
		setdiopin(bank, pin, val);
	}
	return 0;
}