Professional Documents
Culture Documents
REVISION
ORIGINATOR
0.1.0
SCR
REV DATE
April 24, 2014
Guangzhou FriendlyARM
Computer Tech Co., Ltd
Guangzhou, China
Copyright@2013
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
-1-
COPYRIGHT STATEMENT
The content (content being images, text, programs and scripts) of this English
manual is copyright Guangzhou FriendlyARM Computer Tech Co., Ltd. All
rights expressly reserved.
Any content of the manual printed or downloaded may not be sold, licensed,
transferred, copied or reproduced in whole or in part in any manner or in or on
any media to any person without the prior written consent of Guangzhou
FriendlyARM Computer Tech Co., Ltd including but not limited to:
transmission by any method
storage in any medium, system or program
display in any form
performance
hire, lease, rental or loan
Requests for permission to reproduce material from this manual should be
addressed to Guangzhou FriendlyARM Computer Tech Co., Ltd.
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
-2-
Index
1 INTRODUCTION................................................................................................................................................... - 5 2 SET UP ANDROID DEVELOPMENT ENVIRONMENT ............................................................................................ - 5 2.1 INSTALL JDK (JAVA SE DEVELOPMENT KIT) ........................................................................................ - 5 2.2. INSTALL ADT AND ANDROID SDK......................................................................................................... - 8 2.2.1 Download Android SDK .................................................................................................................. - 9 2.2.2 Start ADT Development Environment (Android Developer Tools) ........................................... - 10 2.3 SET UP ANDROID SIMULATOR ............................................................................................................... - 12 2.4 CREATE ANDROID APPLICATION .......................................................................................................... - 14 2.4.1 Create HelloWorld ..................................................................................................................... - 14 2.4.2 Run Android Application in Simulator ........................................................................................ - 16 2.5 SET UP TINY4412 DEBUG ENVIRONMENT ............................................................................................ - 18 2.5.1 Install USB ADB Driver................................................................................................................. - 18 2.5.2 ADB Testing .................................................................................................................................... - 19 2.5.2.1 Add ADB to PATH............................................................................................................... - 19 2.5.2.2 Testing ADB Functions ....................................................................................................... - 21 2.5.3 Run Applications on Tiny4412 in ADB......................................................................................... - 21 2.5.4 Debug Android Applications on Tiny4412 ................................................................................... - 24 3 ACCESS AND CONTROL HARDWARE COMPONENTS........................................................................................ - 24 3.1 HOW TO USE LIBRARY(LIBFRIENDLYARM-HARDWARE.SO) ................................................................ - 25 3.2 LIBRARY (LIBFRIENDLYARM-HARDWARE.SO) API .............................................................................. - 27 3.2.1 General File Operation APIs ......................................................................................................... - 27 3.2.2 Serial Port APIs .............................................................................................................................. - 29 3.2.3 LED APIs ........................................................................................................................................ - 31 3.2.4 PWM APIs ...................................................................................................................................... - 31 3.2.5 ADC APIs ........................................................................................................................................ - 32 3.2.6 I2C APIs .......................................................................................................................................... - 33 3.2.7 SPI APIs .......................................................................................................................................... - 35 3.2.8 GPIO APIs ...................................................................................................................................... - 39 3.3 CODE SAMPLES ..................................................................................................................................... - 43 3.3.1 LED ................................................................................................................................................. - 43 3.3.2 GPIO ............................................................................................................................................... - 43 3.3.2.1 Run Adroids Application as System................................................................................... - 43 3.3.2.2 Disable Kernel LED Driver ................................................................................................ - 45 3.3.2.3 Get GPIO LED Pin ............................................................................................................. - 45 3.3.2.4 Control LED via GPIO ....................................................................................................... - 46 3.3.3 Serial Port Communication ........................................................................................................... - 48 Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
-3-
3.3.4 PWM ............................................................................................................................................... - 49 3.3.5 A/D Conversion .............................................................................................................................. - 50 3.3.6 I2C & EEPROM ............................................................................................................................ - 51 3.4 IMPORT PROJECT IN ADT..................................................................................................................... - 52 -
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
-4-
1 Introduction
This document is created based on the Tiny4412 board and gives basic ideas on how
to develop applications on Android. Although it was created for the Tiny4412 it is a
good reference for all our boards including 4412, NanoPC, 210 and 6410 that can run
Android.
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
-5-
On the pop-up window please check the Accept License Agreement box
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
-6-
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
-7-
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
-8-
-9-
On the window please click on Install 4 packages and check the Accept License
option on the Choose Packages to Install dialog and click on Install.
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 10 -
When you start it you will be asked to set the workspace path where you will save
your projects source code. After finish you will see the following window
Actually ADT is built with Eclipse and is Eclipse + Android + SDK + ADT Plugin. In
the following sections we will use ADT
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 11 -
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 12 -
Select a simulator and click on Start and Launch on the Launch Option dialog
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 13 -
After the New Android Project dialog pops up please type the following info
1) Application name: HelloWorld
2) Project name: HelloWorld
3) Package name: com.example.helloworld
4) Build target: API 17: Android 4.2(Jelly Bean)
5) Target SDK: API 17: Android 4.2(Jelly Bean)
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 14 -
Click on Next all the way till Finish to complete the project.
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 15 -
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 16 -
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 17 -
After the installation is done please turn on the Tiny4412. After Android is fully
loaded please connect the board to a PC via a USB cable and follow the Windows 7
prompt to install the USB driver.
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 18 -
If the installation fails please go to Device Manager and right click on Tiny4412
to update its driver.
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 19 -
To test ADB commands please lauch the Windows command line utility, type adb
and enter. If you observe the following messages you will be able to work with ADB
successfully.
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 20 -
- 21 -
automatically opened.
Please go to Package Explore, right click on HelloWorld and select Propertities,
click on Run/Debug Settings, select HelloWorld and click on Edit
On the Edit Configuration window click on Target and check Always prompt to
pick device on the Deployment Target Selection Mode tab
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 22 -
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 23 -
When ADT asks whether you want to trace logcat messages you can choose Yes
and select debug
- 24 -
In
- 25 -
.java
files
under
tools/libfriendlyarm-hardware/java/com/friendlyarm/AndroidSDK
to
your
3) Please
open
DVD
and
copy
all
the
src\com\friendlyarm\AndroidSDK
After all these steps are done please start ADT, select your project on the left and
refresh it you will see the list shown below
All the major interfaces are in HardwareControler. You need to import them before
you can use them
import com.friendlyarm.AndroidSDK.HardwareControler;
import com.friendlyarm.AndroidSDK.SPIEnum;
import com.friendlyarm.AndroidSDK.GPIOEnum;
import com.friendlyarm.AndroidSDK.FileCtlEnum;
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 26 -
Comment
Open device
ioctl operation
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 27 -
return -1
int write (int fd, byte[] data) fd: file descriptor;
int len)
or file
read
operation
will
return 0
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 28 -
int select (int fd, int sec, int fd: file descriptor;
Check
usec)
whether
file
Close a device
return value: no
Comment
int
openSerialPortEx
include:
serial
port
device
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 29 -
long
baud,
int /dev/s3c2410_serial2,
dataBits,
int
stopBits,
String
parityBit,
String
/dev/s3c2410_serial3,
/dev/ttyUSB0,
flowCtrl)
/dev/ttyUSB1,
/dev/ttyUSB2,
/dev/ttyUSB3,
baud: baud rate,
dataBits: data bits,
stopBits: stop bits
parityBit: parity bit (0 means even, E
means odd and N means no parity bit),
flowCtrl:
flow
control(H
means
- 30 -
select to inquiry whether there are data coming. If the deivce receives data you can call
read to read them. You can call write to write data to a serial device. After
operations are done please call close to close it.
int setLedState (int ledID, ledID: ID of an LED which Turn on / off an LED
int ledState)
will be operated,
ledState: 1 means on and 0
mean off,
Return value: if it succeeds
it will return 0 otherwise it
will return -1
PWMPlay
frequency)
frequency
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 31 -
int readADC ()
int
readADCWithChannel channel:
(int channel)
specified
ADC result
ADC Read
channel
specified
ADC
channels result
multiple
ADC
channels results
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 32 -
Set
int timeout)
I2C_TIMEOUT)
timeout
(ioctl
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 33 -
will return -1
int setI2CRetries (int fd, int fd: I2C device descriptor,
retries)
I2C_RETRIES)
wait_ms)
period
wait
time
in
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 34 -
mini-seconds,
If it succeeds if will return
0 otherwise it will return -1
Comment
int
spi_fd: SPI device descriptor, Set the number of bits per word
to
(ioctl
SPI_IOC_WR_BITS_PER_WO
RD)
int
spi_fd: SPI device descriptor, Set the number of bits per word
setSPIReadBitsPerW
(ioctl
SPI_IOC_RD_BITS_PER_WO
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 35 -
order:
SPIEnum.MSBFIRST
or
SPIEnum.LSBFIRST,
Return value: if it succeeds it
will return 0 otherwise it will
return a negative number.
int
setSPIClockDivider
(int
spi_fd,
int SPIEnum.SPI_CLOCK_DIV
divider)
128,
Return value: if it succeeds it
will return 0 otherwise it will
return a negative number.
int
include
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 36 -
SPIEnum.SPI_MODE0
SPIEnum.SPI_MODE3,
Return value: if it succeeds it
will return 0 otherwise it will
return a negative number.
int
SPItransferOneByte
(int
spi_fd,
byteData,
int
spi_delay,
int
spi_speed,
int
transmission
speed,
spi_bits)
spi_bits: number of bits per
word,
Return value: if it succeeds it
will return 0 otherwise it will
return a negative number.
int
(int
writeData,
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 37 -
readBuff,
spi_delay,
int
spi_speed,
int
transmission
spi_bits)
speed,
spi_bits: number of bits per
word,
Return value: if it succeeds it
will return 0 otherwise it will
return a negative number.
int writeBytesToSPI spi_fd: SPI device descriptor, Write multiple bytes of data to
(int
spi_fd,
writeData,
spi_delay,
int
spi_speed,
int
transmission
spi_bits)
speed,
spi_bits: number of bits per
word,
Return value: if it succeeds it
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 38 -
readBytesFromSPI
(int
spi_fd,
byte[]
readBuff,
int
spi_delay,
int
spi_speed,
int
transmission
speed,
spi_bits)
- 39 -
API Name
Parameter
and Comment
Return Value
int
exportGPIOPin
pin)
(int pin:
GPIO
number,
it
will
return 0 otherwise it
will
return
negative number.
int unexportGPIOPin (int pin:
pin)
GPIO
number,
it
pin
>
will /sys/class/gpio/unexport
return 0 otherwise it
will
return
negative number.
int setGPIOValue (int pin, pin:
int value)
GPIO
number,
value:
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 40 -
GPIOEnum.LOW or
GPIOEnum.HIGH,
Return value: if it
succeeds
it
will
return 0 otherwise it
will
return
negative number.
int getGPIOValue (int pin) pin:
GPIO
number,
Return value: if it
succeeds
it
return
will
either
GPIOEnum.LOW or
GPIOEnum.HIGH
otherwise
it
return
negative
will
number.
int setGPIODirection (int pin:
pin, int direction)
GPIO
number,
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 41 -
direction:
GPIOEnum.IN
or
GPIOEnum.OUT
Return value: if it
succeeds
it
will
return 0 otherwise it
will
return
negative number.
int getGPIODirection (int pin:
pin)
GPIO
number,
Return value: if it
succeeds
it
return
will
either
GPIOEnum.IN
or
GPIOEnum.OUT
otherwise
it
return
negative
will
number.
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 42 -
3.3.2 GPIO
This code sample can work with external LEDs. It directly accesses LEDs via GPIOs
without accessing LED drivers. It requires disabling Linux kernels LED driver first and
then runs this code
- 43 -
We take the first one: compile our code in Android source code directory and put the
GPIO_LED_Demo directory to packages/apps. For instance if you have mounted
Tiny4412 DVD A to /mnt/iso please follow the steps below.
Go to Android 4.2.2 source code directory
# cd /opt/FriendlyARM/tiny4412/android-4.2.2_r1/
Set Android environment variables
# . setenv
Copy GPIO_LED_Demo to packages/apps
# cd packages/apps
# cp /mnt/iso/Android/examples/GPIO_LED_Demo . a
Run mm to compile the project
#cd GPIO_LED_Demo
# mm
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 44 -
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 45 -
GPM4 corresponds to 79 and each LED has an offset therefore LED1 is 79 + 0 (79)
and LED 4 is 79 + 3 (82)
- 46 -
step = STEP_INIT_GPIO_DIRECTION;
timer.schedule(init_task, 100, 100);
When users click on the CheckBox the corresponding LED pin will be set to
OUTPUT and HIGH
HardwareControler.setGPIOValue(79+led.code,led.isSelected() ? GPIOEnum.LOW:GPIOEnum.HIGH)
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 47 -
If users want to set flow control and parity bit you can call the following function
devfd = HardwareControler.openSerialPortEx( devName, speed, dataBits, stopBits, parityBit, flowCtrl );
During serial port communications we need to poll a serial port and check whether it
receives data and needs to show them if there are any. We add a timer such that the
function will check a serial port every 500 ms.
private final int BUFSIZE = 512;
private byte[] buf = new byte[BUFSIZE];
if (HardwareControler.select(devfd, 0, 0) == 1) {
int retSize = HardwareControler.read(devfd, buf, BUFSIZE);
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 48 -
3.3.4 PWM
This code sample shows how the PWM beeper will be called to beep
HardwareControler.PWMPlay(1000);
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 49 -
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 50 -
The 4412s EEPROM can store up to 256 bytes therefore the range of the read/write
position is 0 ~ 255. Each time it can only read/write one byte and there is a time interval
between two read/write operations. Usually the time interval is 10ms which is specified
in writeByteToI2C.
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 51 -
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 52 -
Address: Room 1705,Block A1, Longyuan Plaza, Longkouxi Road, Guangzhou, China, 510640
Website: http://www.arm9.net
Sales:
+86-20-85201025
Tech Support: +86-13719442657
Fax:
+86-20-85261505
Email for Business and Cooperation: capbily@163.com
Email for Tech Support: dev_friendlyarm@163.com
- 53 -