|
| 1 | +.. _peripheral_preparation: |
| 2 | + |
| 3 | +Peripheral Preparation |
| 4 | +====================== |
| 5 | + |
| 6 | +This is a quick manual helping you to connect your peripheral modules with your embARC boards. |
| 7 | + |
| 8 | +MUX Controller Setting |
| 9 | +###################### |
| 10 | +On most of embARC boards, pins are multiplexed for various usages: uart, i2c, spi, etc. One pin can not be accessed by different usage simultaneously, that's where MUX controller comes in. |
| 11 | +We will take PMOD interface as example to explain the setting method. Other interfaces (Andruino, MikroBUS, etc.) can take PMOD as reference, and use the same method for setting. |
| 12 | + |
| 13 | +1. You need to find mux controller code at ``embarc_osp/board/[board_type]/drivers/mux``. |
| 14 | +One exception is board `The ARC IoT Development Kit (IoTDK) <https://www.synopsys.com/dw/ipdir.php?ds=arc_iot_development_kit>`_ which has fixed pin assignment and does **NOT** have mux controller. |
| 15 | + |
| 16 | +2. If you are using EMSK, go to mux.c and find ``io_mux_init()`` function, you will see it calls ``set_pmod_mux()`` with MUX options as parameters. |
| 17 | +MUX options are defined in mux.h and you could change them as you see fit. |
| 18 | + |
| 19 | +For example, You want to connect your EMSK with two i2c sensor modules. By default setting you only have PM2 as i2c interface. |
| 20 | +So now you have to check mux.h or EMSK manual to see if it support one more i2c interface. |
| 21 | +Notice that there is a ``PM3_I2C_GPIO_D`` macro in mux.h meaning that PM3 support i2c interface. Now all you need to do is to replace the default PM3 setting in ``set_pmod_mux()`` to ``PM3_I2C_GPIO_D``. |
| 22 | +Now your code should be like this: |
| 23 | + |
| 24 | +.. code-block:: c |
| 25 | +
|
| 26 | + set_pmod_mux(PM1_UR_UART_0 | PM1_LR_SPI_S \ |
| 27 | + | PM2_I2C_HRI \ |
| 28 | + | PM3_I2C_GPIO_D \ |
| 29 | + | PM4_I2C_GPIO_D \ |
| 30 | + | PM5_UR_SPI_M1 | PM5_LR_GPIO_A \ |
| 31 | + | PM6_UR_SPI_M0 | PM6_LR_GPIO_A ); |
| 32 | +
|
| 33 | +.. note:: Notice that **UR** means Upper Layer of Pmod interface and **LR** means Lower Layer of Pmod |
| 34 | + |
| 35 | +3. If you are using HSDK, go to mux.c and find ``io_mux_init()`` function, you will see it calls ``creg_hsdc_set_gpio_mux()`` with paramater array ``gpio_mux_config`` as MUX options. |
| 36 | +By default all pins are set to GPIO, other MUX options are defined in ``PINMUX_TYPE`` in ``embarc_osp/device/inc/dev_pinmux.h`` |
| 37 | + |
| 38 | +.. note:: To learn what interface your board has, please go to :ref:`board_bsp` |
| 39 | + |
| 40 | +PMOD Modules |
| 41 | +############ |
| 42 | + |
| 43 | +PMOD WiFi Modules |
| 44 | +****************** |
| 45 | +`Pmod WiFi <https://reference.digilentinc.com/reference/pmod/pmodwifi/start>`_ : Primary IC type is MRF24WG, use **SPI** and a few **GPIO** pins for data changing and controlling. |
| 46 | +Driver code at ``embarc_osp/device/peripheral/wifi/mrf24g``. |
| 47 | + |
| 48 | +RW009 WiFi : This type of module also uses **SPI** and **GPIO** pins for data changing and controlling. |
| 49 | +Driver code at ``embarc_osp/device/peripheral/wifi/rw009``. |
| 50 | + |
| 51 | + |
| 52 | +PMOD Temperature Module |
| 53 | +*********************** |
| 54 | +`Pmod TMP2 <https://reference.digilentinc.com/reference/pmod/pmodtmp2/start>`_ : sensor chip type is ADT7420, use **I2C** for data collection. |
| 55 | +Driver code at ``embarc_osp/device/peripheral/sensor/temperature/adt7420``. |
| 56 | + |
| 57 | +`Pmod TMP3 <https://reference.digilentinc.com/reference/pmod/pmodtmp3/start>`_ : sensor chip type is TCN75A, use **I2C** for data collection. |
| 58 | +Driver code at ``embarc_osp/device/peripheral/sensor/temperature/tcn75``. |
| 59 | + |
| 60 | +Other PMOD or Compatible Modules |
| 61 | +******************************** |
| 62 | +`Pmod AD2 <https://reference.digilentinc.com/reference/pmod/pmodad2/start>`_ : ADC type is AD7991, use **I2C** for data collection. |
| 63 | +Driver code at ``embarc_osp/device/peripheral/adc/ad7991``. |
| 64 | + |
| 65 | +`ESP01\/ESP01S <http://wiki.ai-thinker.com/esp8266/docs>`_ : Primary IC type is ESP8266, use **UART** interface for data changing and controlling. |
| 66 | +Driver code at ``embarc_osp/device/peripheral/wifi/slip_esp``. |
| 67 | + The ESP01/ESP01S module is not originally a PMOD module, however it is PMOD campatible, which means you could wire it to PMOD interface on board. You need to connect GCC(embARC) to GCC(ESP) , 3.3V(embARC) to VCC, RXD(embARC) to TXD(ESP), and TXD(embARC) to RXD(ESP), respectively. Please take reference from datasheet of `ESP01\/ESP01S <http://wiki.ai-thinker.com/esp8266/docs>`_ and UART (type 4A) part of `Digilent Pmod Spec <https://www.digilentinc.com/Pmods/Digilent-Pmod_%20Interface_Specification.pdf>`_ for pin layout. |
0 commit comments