Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
en:c1_tinkering [2015/04/30 16:09] codewalker |
en:c1_tinkering [2016/04/15 13:10] john1117 created |
||
---|---|---|---|
Line 2: | Line 2: | ||
{{http://dn.odroid.com/homebackup/C-Breadboard1H.jpg?500|}} | {{http://dn.odroid.com/homebackup/C-Breadboard1H.jpg?500|}} | ||
- | You're probably itching to make some fun embedded computer projects with **ODROID-C1**. What you need is an add on prototyping T-breakout board, which can break out all those tasty power, GPIO, I2C, ADC pins from the 40 pin header onto a solderless breadboard. This set will make "cobbling together" prototypes with the **ODROID-C1** super easy. | + | You're probably itching to make some fun embedded computer projects with **ODROID-C**. What you need is an add on prototyping T-breakout board, which can break out all those tasty power, GPIO, I2C, ADC pins from the 40 pin header onto a solderless breadboard. This set will make "cobbling together" prototypes with the **ODROID-C** super easy. |
This kit comes with below many items. | This kit comes with below many items. | ||
Line 21: | Line 21: | ||
[[http://www.hardkernel.com/main/products/prdt_info.php?g_code=G141637532784|Where to buy]] | [[http://www.hardkernel.com/main/products/prdt_info.php?g_code=G141637532784|Where to buy]] | ||
- | ===== DIY light level meter project ===== | + | ====== DIY light level meter project ====== |
+ | Configuration tinkering kit such as below schematic. | ||
- | ==== Linux ==== | + | Please refer to below links for ODROID-C2 user or details related to gpio mapping. |
- | 1. Configuration tinkering kit such as below schematic.\\ | + | |
- | Light Level Meter schematic | + | [[en:c1_hardware#expansion_connectors | C1 Expansion Connectors]]\\ |
+ | [[en:c2_hardware#expansion_connectors | C2 Expansion Connectors]] | ||
{{:en:c1:tinkering.jpg?500|}} | {{:en:c1:tinkering.jpg?500|}} | ||
- | 2. Get the wiringPi library compatible **ODROID-C1** | + | ===== Linux ===== |
- | <code> | + | ==== C example ==== |
- | # git clone https://github.com/hardkernel/wiringPi | + | 1. Get the wiringPi library compatible **ODROID** |
- | </code> | + | |
+ | git clone https://github.com/hardkernel/wiringPi | ||
+ | |||
+ | 2. Build the library | ||
+ | |||
+ | cd wiringPi | ||
+ | ./build | ||
+ | |||
+ | 3. Compile and run the example source code. | ||
+ | |||
+ | {{http://dn.odroid.com/source_peripherals/ctinkeringkit/example-led.c|example-led.c}} | ||
+ | wget http://dn.odroid.com/source_peripherals/ctinkeringkit/example-led.c | ||
+ | gcc -o example-led example-led.c -lwiringPi -lwiringPiDev -lpthread | ||
+ | sudo ./example-led | ||
+ | |||
+ | ==== Python example ==== | ||
+ | |||
+ | * [[https://github.com/hardkernel/WiringPi2-Python|WiringPi2-Python repository for ODROID]] | ||
+ | |||
+ | **Prerequisites**: You must have //**python-dev**// and //**python-setuptools**// installed If you manually rebuild the bindings with swig-python wiringpi.i | ||
+ | |||
+ | sudo apt-get install python-dev python-setuptools | ||
+ | |||
+ | 1. Get/setup WiringPi 2 for Python repository | ||
- | 3. Build the library | ||
<code> | <code> | ||
- | # cd wiringPi | + | git clone https://github.com/hardkernel/WiringPi2-Python.git |
- | # ./build | + | cd WiringPi2-Python |
+ | git submodule init | ||
+ | git submodule update | ||
</code> | </code> | ||
- | 4. Compile and run the example source code. | + | 2. Build & install |
+ | sudo python setup.py install | ||
- | <file c example-led.c> | + | 3. Get/Run the example source code |
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | // | + | {{http://dn.odroid.com/source_peripherals/ctinkeringkit/example-led.py|example-led.py}} |
- | // ODROID-C GPIO(LED) / ADC Test Application. | + | wget http://dn.odroid.com/source_peripherals/ctinkeringkit/example-led.py |
- | // | + | sudo python example-led.py |
- | // Defined port number is wiringPi port number. | + | |
- | // | + | |
- | // Compile : gcc -o <create excute file name> <source file name> -lwiringPi -lwiringPiDev -lpthread | + | |
- | // Run : sudo ./<created excute file name> | + | |
- | // | + | |
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | #include <stdio.h> | + | |
- | #include <stdlib.h> | + | |
- | #include <stdint.h> | + | |
- | + | ||
- | #include <unistd.h> | + | |
- | #include <string.h> | + | |
- | #include <time.h> | + | |
- | + | ||
- | #include <wiringPi.h> | + | |
- | #include <wiringPiI2C.h> | + | |
- | #include <wiringSerial.h> | + | |
- | #include <lcd.h> | + | |
- | + | ||
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | // | + | |
- | // Global handle Define | + | |
- | // | + | |
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | + | ||
- | #define DATA_UPDATE_PERIOD 100 // 100ms | + | |
- | + | ||
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | // | + | |
- | // ADC: | + | |
- | // | + | |
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | #define PORT_ADC1 0 // ADC.AIN0 | + | |
- | + | ||
- | static int adcValue = 0; | + | |
- | + | ||
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | // | + | |
- | // LED: | + | |
- | // | + | |
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | static int ledPos = 0; | + | |
- | + | ||
- | const int ledPorts[] = { | + | |
- | 24, // GPIOX.BIT0(#97) | + | |
- | 23, // GPIOX.BIT11(#108) | + | |
- | 22, // GPIOX.BIT3(#100) | + | |
- | 21, // GPIOX.BIT4(#101) | + | |
- | 14, // GPIOX.BIT8(#105) | + | |
- | 13, // GPIOX.BIT9(#106) | + | |
- | 12, // GPIOX.BIT10(#107) | + | |
- | 3, // GPIOX.BIT18(#115) | + | |
- | 2, // GPIOX.BIT19(#116) | + | |
- | 0, // GPIOY.BIT8(#88) | + | |
- | 7, // GPIOY.BIT3(#83) | + | |
- | + | ||
- | 1, // GPIOY.BIT7(#87) | + | |
- | 4, // GPIOX.BIT7(#104) | + | |
- | 5, // GPIOX.BIT5(#102) | + | |
- | 6, // GPIOX.BIT6(#103) | + | |
- | 10, // GPIOX.BIT20(#117) | + | |
- | 26, // GPIOX.BIT2(#99) | + | |
- | 11, // GPIOX.BIT21(#118) | + | |
- | 27, // GPIOX.BIT1(#98) | + | |
- | }; | + | |
- | + | ||
- | #define MAX_LED_CNT sizeof(ledPorts) / sizeof(ledPorts[0]) | + | |
- | + | ||
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | // | + | |
- | // system init | + | |
- | // | + | |
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | int system_init(void) | + | |
- | { | + | |
- | int i; | + | |
- | + | ||
- | // GPIO Init(LED Port ALL Output) | + | |
- | for(i = 0; i < MAX_LED_CNT; i++) pinMode (ledPorts[i], OUTPUT); | + | |
- | + | ||
- | return 0; | + | |
- | } | + | |
- | + | ||
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | // | + | |
- | // board data update | + | |
- | // | + | |
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | void boardDataUpdate(void) | + | |
- | { | + | |
- | int i; | + | |
- | + | ||
- | // adc value read | + | |
- | if((adcValue = analogRead (PORT_ADC1))) { | + | |
- | ledPos = (adcValue * MAX_LED_CNT * 1000) / 1024; | + | |
- | ledPos = (MAX_LED_CNT - (ledPos / 1000)); | + | |
- | } | + | |
- | else | + | |
- | ledPos = 0; | + | |
- | + | ||
- | // LED Control | + | |
- | for(i = 0; i < MAX_LED_CNT; i++) digitalWrite (ledPorts[i], 0); // LED All Clear | + | |
- | for(i = 0; i < ledPos; i++) digitalWrite (ledPorts[i], 1); // LED On | + | |
- | } | + | |
- | + | ||
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | // | + | |
- | // Start Program | + | |
- | // | + | |
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | int main (int argc, char *argv[]) | + | |
- | { | + | |
- | static int timer = 0 ; | + | |
- | + | ||
- | wiringPiSetup (); | + | |
- | + | ||
- | if (system_init() < 0) | + | |
- | { | + | |
- | fprintf (stderr, "%s: System Init failed\n", __func__); return -1; | + | |
- | } | + | |
- | + | ||
- | for(;;) { | + | |
- | usleep(100000); | + | |
- | if (millis () < timer) continue ; | + | |
- | + | ||
- | timer = millis () + DATA_UPDATE_PERIOD; | + | |
- | + | ||
- | // All Data update | + | |
- | boardDataUpdate(); | + | |
- | } | + | |
- | + | ||
- | return 0 ; | + | |
- | } | + | |
- | + | ||
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | //------------------------------------------------------------------------------------------------------------ | + | |
- | </file> | + | |
- | ==== Android ==== | + | ===== Android ===== |
This process explains how to make an Android app which can access IO ports.\\ | This process explains how to make an Android app which can access IO ports.\\ | ||
Line 411: | Line 300: | ||
</code> | </code> | ||
- | wiringPi의 "/dev/mem"을 open 하여 mmap을 사용하는 방식으로 만들려고 하였으니 "/dev/mem"은 root가 아니면 접근을 제한하도록 되어 있어서 불가능합니다. | + | Korean: wiringPi의 "/dev/mem"을 open 하여 mmap을 사용하는 방식으로 만들려고 하였으니 "/dev/mem"은 root가 아니면 접근을 제한하도록 되어 있어서 불가능합니다. |
jni의 library에는 root 권한을 줄 방법이 없습니다. | jni의 library에는 root 권한을 줄 방법이 없습니다. | ||
- | + | English: It was impossible to access the /dev/mem in the Android platform because only root can access it. | |
+ | There is no way to add a root permission to the JNI library. | ||