How to get started with Eclipse and AVR
UBUNTU_MENUPROXY= ./eclipse
Тахометр на Attiny.Продолжаем знакомство с AVR.
AVR ASM:
http://we.easyelectronics.ru/AVR/assemblernye-vstavki-v-avr-gcc.html
http://embedderslife.wordpress.com/2012/02/19/avr-gcc-asm-and-c/
http://www-leland.stanford.edu/class/ee281/projects/aut2002/yingzong-mouse/media/GCCAVRInlAsmCB.pdf
2013-09-06
2013-08-30
Android USB HOWTO
Manual:
http://developer.android.com/guide/topics/connectivity/usb/index.html
http://developer.android.com/reference/android/hardware/usb/UsbManager.html
http://developer.android.com/tools/adk/index.html
http://developer.android.com/tools/adk/adk2.html
http://source.android.com/accessories/custom.html
Example:
http://code.google.com/p/usb-serial-for-android/
http://code.google.com/p/usb-serial-for-android/source/browse/#git%2FUsbSerialExamples
Не так давно Google открыл API для работы Android устройств с USB. Сегодня пришло время пощупать что же это такое и узнать какие возможности нам открываются.http://habrahabr.ru/post/123361/
Discussion:
http://stackoverflow.com/questions/3803871/android-apps-communicating-with-a-device-plugged-in-the-usb-port
http://stackoverflow.com/questions/11337852/android-usb-application
Одной из самых интересных новинок, представленных на Google I/O 2011, можно считать анонс полноценной работы Android устройств с USB.
Новый Android поддерживает два USB режима — хост (Host mode) и устройство (Accessory mode).http://habrahabr.ru/post/119208/
http://habrahabr.ru/post/181996/
Собираем CarPC на Android: недостроенный долгострой
Android эмулятор Genimotion
Java USB HOWTO
?jUSB and JSR 80 but both seem to be dead projects (at least for Windows).
we had to build our own custom C wrappers to the USB drivers and communicate with them through JNI
libusb-win32 requires you to install their
generic driver, which then makes a USB device available to you. I'm
not sure that it's possible to do driver-less access of an USB device
unless the device belongs to one of several standard classes (storage
and HID, in particular).
There is a Java wrapper for libusb-win32 which might work for you. I haven't used it myself, though.
See the Libusb java binding on github alternativly there is usb4java from which The low-level part is based on the native libusb 0.1 http://stackoverflow.com/questions/3803871/android-apps-communicating-with-a-device-plugged-in-the-usb-port https://today.java.net/pub/a/today/2006/07/06/java-and-usb.html http://www.ibm.com/developerworks/library/j-usb/index.html
The only USB API I could find for Windows is here. Seems as if it has limited functionality, but it might suit your needs. A more complete UNIX API is also available.
ETA: Found a link to the official Java USB implementation, but looks like the windows version is still in alpha. The above link to javax-usb.org is dead. However I found these two: javax.usb (This seems to be the official one) and javax-usb-libusb1 The native code API I referred to was the Windows DDK, i.e. the Driver Development Kit. The modern version seem to be called Windows Driver Kit, so google for Windows WDK :) There should be a few C samples on how to communicate with USB devices, and it should be pretty straightforward to write a JNI wrapper from those. found this page that explains how to perform a communication between a microcontroller and a java application: http://javausbapi.blogspot.com/ http://www.math.ucla.edu/~anderson/JAVAclass/JavaInterface/JavaInterface.html |
2013-08-29
AVR USB HOWTO
How to compile a C program with libusbx-1.0 support
gcc cmdClient.c -ocmdClient -O -Wall -I/usr/local/include/libusb-1.0 -L/usr/local/lib -lusb-1.0 -ludev -lrt
[root@localhost cmdClient]# ./cmdClient
./cmdClient: symbol lookup error: ./cmdClient: undefined symbol: libusb_get_port_numbers
########## The first thing you want to check is whether your program is actually using the libusbx library or libusb. If libusb is installed as a system library and hasn't been replaced, there's a good chance your application is using libusb rather than libusbx, and if it does, you will get errors for the function calls that are only present in libusbx. You may want to try to call libusb_get_version() and print the data (see the end of examples/xusb.c for how to do that), to confirm that you are actually using libusbx 1.0.15 and not libusb. ############
gcc cmdClient.c -ocmdClient -O -Wall -I./libusb -L/usr/local/lib -lusb-1.0 ./cmdClient
./cmdClient: error while loading shared libraries: libusb-1.0.so.0: cannot open shared object file: No such file or directory find /usr -name "*libusb-1.0.so.0*" /usr/local/lib/libusb-1.0.so.0 /usr/local/lib/libusb-1.0.so.0.1.0
Solution 1:
gcc cmdClient.c -ocmdClient -O -Wall -I/usr/local/include/libusb-1.0 -L/usr/local/lib -lusb-1.0 -Wl,-rpath -Wl,/usr/local/lib
[root@localhost cmdClient]# ./cmdClient
Using libusbx v1.0.16.10774
Solution 2:
strace ./cmdClient
open("/usr/lib/libusb-1.0.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
ln -s /usr/local/lib/libusb-1.0.so.0 /usr/lib/libusb-1.0.so.0
gcc cmdClient.c -ocmdClient -O -Wall -I/usr/local/include/libusb-1.0 -L/usr/local/lib -lusb-1.0
or
gcc cmdClient.c -ocmdClient -O -Wall -I./libusb -L./libusb -lusb-1.0
[root@localhost cmdClient]# ./cmdClient
Using libusbx v1.0.16.10774
###########################
linux tools:
file
locate
ldd /usr/local/lib/libusb-1.0.so.0
http://sourceforge.net/projects/libusbx/
http://libusbx.sourceforge.net/api-1.0/modules.html
##############################
Final result:
#include stdio.h
#include stdint.h
#include stdlib.h
#include string.h
#include stdarg.h
#include unistd.h
#include "libusb.h"
uint16_t VID, PID;
static int test_device_on_off(int i_usb_led_on)
{
libusb_device_handle *handle;
int i, r;
printf("Opening device %04X:%04X...\n", VID, PID);
handle = libusb_open_device_with_vid_pid(NULL, VID, PID);
if (handle == NULL) {
printf(" Failed.\n");
return -1;
}
unsigned char data[256];
r = libusb_control_transfer(handle,LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, i_usb_led_on, 0, 0, (unsigned char *)data,sizeof(data), 5000);
if (r < 0) {
printf("F0 error %d\n", r);
}
if ((unsigned int) r < sizeof(data)) {
printf( "short read (%d)\n", r);
}
printf("F0 data:");
for (i = 0; i < sizeof(data); i++)
printf("%02x ", data[i]);
printf("\n");
printf("Closing device...\n");
libusb_close(handle);
}
int main(void)
{
const struct libusb_version* version;
int r;
// Default to generic, expecting VID:PID
VID = 0x16c0;
PID = 0x05dc;
version = libusb_get_version();
printf("Using libusbx v%d.%d.%d.%d\n\n", version->major, version->minor, version->micro, version->nano);
r = libusb_init(NULL);
if (r < 0)
return r;
libusb_set_debug(NULL, 0?LIBUSB_LOG_LEVEL_DEBUG:LIBUSB_LOG_LEVEL_INFO);
usleep(500000);
test_device_on_off(0);
usleep(500000);
test_device_on_off(1);
libusb_exit(NULL);
return 0;
}
http://we.easyelectronics.ru/electro-and-pc/usb-dlya-avr-chast-1-vvodnaya.html
http://codeandlife.com/2012/01/22/avr-attiny-usb-tutorial-part-1/
##########################################################
avrdude -P /dev/ttyACM0 -p m8 -c avr910 -U flash:r:flash.hex:i
http://www.rogerclark.net/updating-firmware-on-usbasp-bought-from-ebay/
http://habrahabr.ru/post/208470/ Нестандартное использование USBasp
http://rootadmin.livejournal.com/10824.html Программатор AVR910 под Linux
http://www.gaw.ru/html.cgi/txt/app/micr os/avr/AVR309.htm
gcc cmdClient.c -ocmdClient -O -Wall -I/usr/local/include/libusb-1.0 -L/usr/local/lib -lusb-1.0 -ludev -lrt
[root@localhost cmdClient]# ./cmdClient
./cmdClient: symbol lookup error: ./cmdClient: undefined symbol: libusb_get_port_numbers
########## The first thing you want to check is whether your program is actually using the libusbx library or libusb. If libusb is installed as a system library and hasn't been replaced, there's a good chance your application is using libusb rather than libusbx, and if it does, you will get errors for the function calls that are only present in libusbx. You may want to try to call libusb_get_version() and print the data (see the end of examples/xusb.c for how to do that), to confirm that you are actually using libusbx 1.0.15 and not libusb. ############
gcc cmdClient.c -ocmdClient -O -Wall -I./libusb -L/usr/local/lib -lusb-1.0 ./cmdClient
./cmdClient: error while loading shared libraries: libusb-1.0.so.0: cannot open shared object file: No such file or directory find /usr -name "*libusb-1.0.so.0*" /usr/local/lib/libusb-1.0.so.0 /usr/local/lib/libusb-1.0.so.0.1.0
Solution 1:
gcc cmdClient.c -ocmdClient -O -Wall -I/usr/local/include/libusb-1.0 -L/usr/local/lib -lusb-1.0 -Wl,-rpath -Wl,/usr/local/lib
[root@localhost cmdClient]# ./cmdClient
Using libusbx v1.0.16.10774
Solution 2:
strace ./cmdClient
open("/usr/lib/libusb-1.0.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
ln -s /usr/local/lib/libusb-1.0.so.0 /usr/lib/libusb-1.0.so.0
gcc cmdClient.c -ocmdClient -O -Wall -I/usr/local/include/libusb-1.0 -L/usr/local/lib -lusb-1.0
or
gcc cmdClient.c -ocmdClient -O -Wall -I./libusb -L./libusb -lusb-1.0
[root@localhost cmdClient]# ./cmdClient
Using libusbx v1.0.16.10774
###########################
linux tools:
file
locate
ldd /usr/local/lib/libusb-1.0.so.0
http://sourceforge.net/projects/libusbx/
http://libusbx.sourceforge.net/api-1.0/modules.html
##############################
Final result:
#include stdio.h
#include stdint.h
#include stdlib.h
#include string.h
#include stdarg.h
#include unistd.h
#include "libusb.h"
uint16_t VID, PID;
static int test_device_on_off(int i_usb_led_on)
{
libusb_device_handle *handle;
int i, r;
printf("Opening device %04X:%04X...\n", VID, PID);
handle = libusb_open_device_with_vid_pid(NULL, VID, PID);
if (handle == NULL) {
printf(" Failed.\n");
return -1;
}
unsigned char data[256];
r = libusb_control_transfer(handle,LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE, i_usb_led_on, 0, 0, (unsigned char *)data,sizeof(data), 5000);
if (r < 0) {
printf("F0 error %d\n", r);
}
if ((unsigned int) r < sizeof(data)) {
printf( "short read (%d)\n", r);
}
printf("F0 data:");
for (i = 0; i < sizeof(data); i++)
printf("%02x ", data[i]);
printf("\n");
printf("Closing device...\n");
libusb_close(handle);
}
int main(void)
{
const struct libusb_version* version;
int r;
// Default to generic, expecting VID:PID
VID = 0x16c0;
PID = 0x05dc;
version = libusb_get_version();
printf("Using libusbx v%d.%d.%d.%d\n\n", version->major, version->minor, version->micro, version->nano);
r = libusb_init(NULL);
if (r < 0)
return r;
libusb_set_debug(NULL, 0?LIBUSB_LOG_LEVEL_DEBUG:LIBUSB_LOG_LEVEL_INFO);
usleep(500000);
test_device_on_off(0);
usleep(500000);
test_device_on_off(1);
libusb_exit(NULL);
return 0;
}
http://we.easyelectronics.ru/electro-and-pc/usb-dlya-avr-chast-1-vvodnaya.html
http://codeandlife.com/2012/01/22/avr-attiny-usb-tutorial-part-1/
##########################################################
avrdude -P /dev/ttyACM0 -p m8 -c avr910 -U flash:r:flash.hex:i
http://www.rogerclark.net/updating-firmware-on-usbasp-bought-from-ebay/
http://habrahabr.ru/post/208470/ Нестандартное использование USBasp
http://rootadmin.livejournal.com/10824.html Программатор AVR910 под Linux
http://www.gaw.ru/html.cgi/txt/app/micr
Subscribe to:
Posts (Atom)