-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrl78com.c
73 lines (59 loc) · 1.86 KB
/
rl78com.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* rl78console
* Copyright (C) 2013 Florent de Lamotte <florent.lamotte@univ-ubs.fr>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <usb.h>
#include "rl78com.h"
struct ctrl_char {
int size;
char data [10];
};
struct ctrl_char ctrl_init [] = {
{2, {0x03, 0x01}},
{2, {0x01, 0x03}},
{6, {0x00, 0x00, 0x96, 0x00, 0x00, 0x01}},
{2, {0x04, 0x00, 0x00}},
{2, {0x01, 0x03}},
{3, {0x02, 0x11, 0x13}},
{0, {0}}
};
struct usb_dev_handle * find_rl78 () {
struct usb_bus *busses;
struct usb_bus *bus;
struct usb_device *mydev;
usb_init();
usb_find_busses();
usb_find_devices();
busses = usb_get_busses();
for (bus = busses; bus; bus = bus->next) {
struct usb_device *dev;
for (dev = bus->devices; dev; dev = dev->next) {
if (dev->descriptor.idVendor == 0x045b && dev->descriptor.idProduct == 0x0212) {
mydev = dev;
}
}
}
return (mydev != NULL) ? usb_open(mydev) : NULL;
}
void configure_rl78 (struct usb_dev_handle *myhandle) {
usb_clear_halt(myhandle, BULKOUT);
usb_clear_halt(myhandle, BULKIN);
/* sending configuration */
int i;
for (i=0; ctrl_init[i].size != 0; i++)
usb_control_msg(myhandle, 'S', 2, 0, 0, ctrl_init[i].data, ctrl_init[i].size, 100);
}