You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(13) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(50) |
Feb
(137) |
Mar
(84) |
Apr
(36) |
May
(100) |
Jun
(5) |
Jul
|
Aug
(4) |
Sep
(13) |
Oct
(1) |
Nov
(4) |
Dec
(22) |
2011 |
Jan
(4) |
Feb
(9) |
Mar
(113) |
Apr
(76) |
May
(31) |
Jun
(19) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
(4) |
Feb
|
Mar
(2) |
Apr
(6) |
May
(19) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(2) |
Apr
(22) |
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Jérémie D. <Ba...@us...> - 2010-04-24 14:03:52
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via c30984ce77fc957c1886e457bf46d9f498e622dd (commit) from 802ab74edcacbf12f1ac96637dcf7ef966feabef (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit c30984ce77fc957c1886e457bf46d9f498e622dd Author: Jérémie Dimino <je...@di...> Date: Sat Apr 24 16:03:29 2010 +0200 maximum openning of the grip ----------------------------------------------------------------------- Changes: diff --git a/info/control/driver/driver.ml b/info/control/driver/driver.ml index a684d78..04ec0f2 100644 --- a/info/control/driver/driver.ml +++ b/info/control/driver/driver.ml @@ -242,10 +242,10 @@ struct let grip_open dev = set_ax12 dev [{ aa_id = 2; - aa_position = 610; + aa_position = 650; aa_velocity = 100 }; { aa_id = 3; - aa_position = 50; + aa_position = 0; aa_velocity = 0 }] let grip_close dev = hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2010-04-24 13:54:40
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 802ab74edcacbf12f1ac96637dcf7ef966feabef (commit) from d7e8ecc10266d6a22d6edcece86f38b39b20fd7e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 802ab74edcacbf12f1ac96637dcf7ef966feabef Author: Jérémie Dimino <dim@gaia.(none)> Date: Sat Apr 24 15:54:18 2010 +0200 better openning of the grip ----------------------------------------------------------------------- Changes: diff --git a/info/control/driver/driver.ml b/info/control/driver/driver.ml index d8614ac..a684d78 100644 --- a/info/control/driver/driver.ml +++ b/info/control/driver/driver.ml @@ -245,8 +245,8 @@ struct aa_position = 610; aa_velocity = 100 }; { aa_id = 3; - aa_position = 265; - aa_velocity = 200 }] + aa_position = 50; + aa_velocity = 0 }] let grip_close dev = set_ax12 dev [{ aa_id = 2; hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2010-04-24 13:41:46
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via d7e8ecc10266d6a22d6edcece86f38b39b20fd7e (commit) via 0d417ee0d871d0f4532a29ab82b50db4f0bb6dc4 (commit) from 562055a8eebfe05f07cd1369fe44f608d8044bff (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d7e8ecc10266d6a22d6edcece86f38b39b20fd7e Author: Jérémie Dimino <dim@gaia.(none)> Date: Sat Apr 24 15:40:20 2010 +0200 fix naming of unsafe interfaces commit 0d417ee0d871d0f4532a29ab82b50db4f0bb6dc4 Author: Jérémie Dimino <dim@gaia.(none)> Date: Sat Apr 24 15:28:18 2010 +0200 typo ----------------------------------------------------------------------- Changes: diff --git a/info/control/driver/export_unsafe.ml b/info/control/driver/export_unsafe.ml index 1b34d56..322a4f0 100644 --- a/info/control/driver/export_unsafe.ml +++ b/info/control/driver/export_unsafe.ml @@ -37,5 +37,5 @@ let make_interface get name commands = let interface name get = let interface_commands = List.assoc name commands in match name with - | "card" -> make_interface get "fr.krobot.Card" interface_commands - | dev -> make_interface get ("fr.krobot.Device." ^ Name.caml_case name) interface_commands + | "card" -> make_interface get "fr.krobot.Card.Unsafe" interface_commands + | dev -> make_interface get ("fr.krobot.Device." ^ Name.caml_case name ^ ".Unsafe") interface_commands diff --git a/info/control/lib-krobot/krobot.ml b/info/control/lib-krobot/krobot.ml index ca061d9..ea935d9 100644 --- a/info/control/lib-krobot/krobot.ml +++ b/info/control/lib-krobot/krobot.ml @@ -247,8 +247,8 @@ let unsafe_call command krobot args = | name -> _unsafe_call command - (device krobot (Name.caml_case command.Commands.name)) - ("fr.krobot.Device." ^ Name.caml_case command.Commands.name) + (device krobot (Name.caml_case command.Commands.section)) + ("fr.krobot.Device." ^ Name.caml_case command.Commands.section ^ ".Unsafe") args (* +-----------------------------------------------------------------+ @@ -294,7 +294,7 @@ struct _unsafe_call command (card krobot c) - "fr.krobot.Card" + "fr.krobot.Card.Unsafe" args | _ -> failwith "use Krobot.unsafe_call for calls on a device" diff --git a/info/control/protocol/commands.ml b/info/control/protocol/commands.ml index 4904c0b..6a063c3 100644 --- a/info/control/protocol/commands.ml +++ b/info/control/protocol/commands.ml @@ -63,7 +63,7 @@ let register cmd = send = dynamic cmd.send; recv = dynamic cmd.recv; } :: !members; - cmd + { cmd with section = !current_interface } let make_interface name = let members = ref [] in hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2010-04-24 13:11:28
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 562055a8eebfe05f07cd1369fe44f608d8044bff (commit) from 472b6224cc6f218dc102bfe27673972931f82adf (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 562055a8eebfe05f07cd1369fe44f608d8044bff Author: Jérémie Dimino <dim@gaia.(none)> Date: Sat Apr 24 15:10:37 2010 +0200 fix distance computation ----------------------------------------------------------------------- Changes: diff --git a/info/control/lib-krobot/krobot_move.ml b/info/control/lib-krobot/krobot_move.ml index 69840f3..8b03520 100644 --- a/info/control/lib-krobot/krobot_move.ml +++ b/info/control/lib-krobot/krobot_move.ml @@ -38,7 +38,7 @@ let add_edge (a, b) graph = let square x = x * x -let distance a b = truncate (sqrt (float_of_int (square (a.vx - b.vy) + square (a.vy - b.vy)))) +let distance a b = truncate (sqrt (float_of_int (square (a.vx - b.vx) + square (a.vy - b.vy)))) let angle a b = truncate (atan2 (float_of_int (b.vy - a.vy)) (float_of_int (b.vx - a.vx)) *. 180. /. 3.14159265) - 90 type vertex_search_info = { hooks/post-receive -- krobot |
From: Xavier L. <Ba...@us...> - 2010-04-23 21:19:33
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 472b6224cc6f218dc102bfe27673972931f82adf (commit) from fdc1fc04aeff5c9fb8333b33e8a092a90aa14329 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 472b6224cc6f218dc102bfe27673972931f82adf Author: Xavier Lagorce <Xav...@cr...> Date: Fri Apr 23 23:18:45 2010 +0200 Better speed control parameters (a little...) ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.h index db9000f..b97ea45 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.h @@ -6,9 +6,9 @@ #ifndef HEADER__SPEEDCONTROL #define HEADER__SPEEDCONTROL -#define K_P 15 +#define K_P 17 #define K_I 1 -#define Tcomp 30 // speed will be computed on a Tcomp timesample +#define Tcomp 15 // speed will be computed on a Tcomp timesample #define Te 50 #define K_v (1000/Tcomp) hooks/post-receive -- krobot |
From: Xavier L. <Ba...@us...> - 2010-04-23 21:05:46
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via fdc1fc04aeff5c9fb8333b33e8a092a90aa14329 (commit) from 506f9cebb8e3e989f41976316e16444e696b3496 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fdc1fc04aeff5c9fb8333b33e8a092a90aa14329 Author: Xavier Lagorce <Xav...@cr...> Date: Fri Apr 23 23:05:19 2010 +0200 The serial monitor is back ! ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ch.ld b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ch.ld index f80c32a..196da88 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ch.ld +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ch.ld @@ -27,8 +27,8 @@ /* * ST32F103 memory setup. */ -__main_stack_size__ = 0x0800; -__process_stack_size__ = 0x0800; +__main_stack_size__ = 0x0400; +__process_stack_size__ = 0x0400; __stacks_total_size__ = __main_stack_size__ + __process_stack_size__; MEMORY diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/cpu_load.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/cpu_load.c index 1f47c0f..728d495 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/cpu_load.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/cpu_load.c @@ -63,7 +63,11 @@ void CPULoadInit(void) { tp = chThdSelf(); chThdCreateFromHeap(NULL, 256, LOWPRIO+1, ThreadCount, NULL); - chThdCreateFromHeap(NULL, 256, HIGHPRIO, ThreadLoad, NULL); + chThdCreateFromHeap(NULL, 256, HIGHPRIO-1, ThreadLoad, NULL); chSchGoSleepS(THD_STATE_SUSPENDED); } + +uint16_t getCPUload(void) { + return CPUload; +} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/cpu_load.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/cpu_load.h index 7ea87b2..96bbaed 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/cpu_load.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/cpu_load.h @@ -10,8 +10,6 @@ #include "chthreads.h" #include "chtypes.h" -extern volatile uint16_t CPUload; - void CPULoadInit(void); - +uint16_t getCPUload(void); #endif diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/main.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/main.c index b3a188e..46724fa 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/main.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/main.c @@ -87,14 +87,14 @@ static msg_t Thread1(void *arg) { static void TimerHandler(eventid_t id) { (void)id; - /*if (palReadPad(IOPORT1, GPIOA_BUTTON)) { + if (palReadPad(IOPORT1, GPIOA_BUTTON)) { cputs("Coucou !\r"); if (TIM_GetCounter(TIM3) == 0) cputs("c'est nul !\r"); else cputs("ca marche (peut etre...)\r"); fflush(stdout); - }*/ + } } /* @@ -120,12 +120,12 @@ int main(int argc, char **argv) { /* * Activates the serial driver 2 using the driver default configuration. */ - //sdStart(&SD2, NULL); + sdStart(&SD2, NULL); /* * Initialise the monitor */ - //monitorInit(); + monitorInit(); /* * Initialise the speed controller diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c index 586e8dd..e3159f5 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c @@ -42,7 +42,7 @@ void loadHandler(BaseChannel *chp, int argc, char* argv[]) { shellPrintLine(chp, "Usage : load."); return; } - load = CPUload; + load = getCPUload(); iprintf("charge CPU : %d%d%d%d%d\r\n", (load/10000)%10, (load/1000)%10, (load/100)%10, @@ -121,7 +121,7 @@ void setSpeedHandler(BaseChannel *chp, int argc, char* argv[]) { void getSpeedHandler(BaseChannel *chp, int argc, char* argv[]) { - int speed; + int32_t speed; if (argc != 1) { shellPrintLine(chp, "Usage : getSpeed numMoteur."); @@ -142,11 +142,11 @@ void getSpeedHandler(BaseChannel *chp, int argc, char* argv[]) { return; } - iprintf("vitesse : %d%d%d%d%d\r\n", (speed/10000)%10, - (speed/1000)%10, - (speed/100)%10, - (speed/10)%10, - (speed)%10); + iprintf("vitesse : %ld%ld%ld%ld%ld\r\n", (speed/10000)%10, + (speed/1000)%10, + (speed/100)%10, + (speed/10)%10, + (speed)%10); } @@ -169,6 +169,6 @@ static const ShellConfig shellConfig = { void monitorInit(void) { shellInit(); - shellCreate(&shellConfig, THD_WA_SIZE(256), NORMALPRIO); + shellCreate(&shellConfig, THD_WA_SIZE(512), NORMALPRIO); cdtp = chThdCreateFromHeap(NULL, THD_WA_SIZE(128), NORMALPRIO + 1, consoleThread, NULL); } diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.c index 3dae739..9ae4b91 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.c @@ -9,7 +9,7 @@ #define MIN(x,y) ((x) > (y) ? (y) : (x)) int32_t ref_speeds[3] = {0, 0, 0}; -int32_t cur_speeds[3] = {0, 0, 0}; +volatile int32_t cur_speeds[3] = {0, 0, 0}; /* * Speed controller thread hooks/post-receive -- krobot |
From: Xavier L. <Ba...@us...> - 2010-04-23 20:37:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 506f9cebb8e3e989f41976316e16444e696b3496 (commit) from 53011d40f475d331129d27c4494e551dffac308a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 506f9cebb8e3e989f41976316e16444e696b3496 Author: Xavier Lagorce <Xav...@cr...> Date: Fri Apr 23 22:31:27 2010 +0200 Update to the Firmware for KrobotJr : * Update ChibiOS to 1.5.5 * Corrected the double initialization of ChibiOS * Corrected the PWM interrupt handler which was hanging the system... * Modified the speed computation to use a different sample rate from the controller. * Maybe other things... The current firmwares seems to be stable (ran for 30 minutes without crashing !) ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/Makefile b/elec/boards/MotherBoard_KrobotJr2010/Firmware/Makefile index c6ef472..62b5e6c 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/Makefile +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/Makefile @@ -60,7 +60,7 @@ CHIBIOS = chibios include $(CHIBIOS)/boards/OLIMEX_STM32_P103/board.mk include $(CHIBIOS)/os/hal/platforms/STM32/platform.mk include $(CHIBIOS)/os/hal/hal.mk -include $(CHIBIOS)/os/ports/GCC/ARMCM3/port.mk +include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F10x/port.mk include $(CHIBIOS)/os/kernel/kernel.mk include $(CHIBIOS)/test/test.mk include $(CHIBIOS)/ext/fatfs/fatfs.mk @@ -110,7 +110,7 @@ TCPPSRC = # List ASM source files here ASMSRC = $(PORTASM) \ - $(CHIBIOS)/os/ports/GCC/ARMCM3/STM32F103/vectors.s + $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F10x/vectors.s INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ $(HALINC) $(PLATFORMINC) $(BOARDINC) \ @@ -185,7 +185,8 @@ DLIBS = # # List all user C define here, like -D_DEBUG=1 -UDEFS = +#UDEFS = -DCH_DBG_ENABLE_STACK_CHECK=1 -DCH_DBG_FILL_THREADS=1 +UDEFS = # Define ASM defines here UADEFS = diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ch.ld b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ch.ld index 196da88..f80c32a 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ch.ld +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ch.ld @@ -27,8 +27,8 @@ /* * ST32F103 memory setup. */ -__main_stack_size__ = 0x0400; -__process_stack_size__ = 0x0400; +__main_stack_size__ = 0x0800; +__process_stack_size__ = 0x0800; __stacks_total_size__ = __main_stack_size__ + __process_stack_size__; MEMORY diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1114/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1114/board.c new file mode 100644 index 0000000..79a2f79 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1114/board.c @@ -0,0 +1,60 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "ch.h" +#include "hal.h" + +/* + * Early initialization code. + * This initialization is performed just after reset before BSS and DATA + * segments initialization. + */ +void hwinit0(void) { + + lpc111x_clock_init(); +} + +/* + * Late initialization code. + * This initialization is performed after BSS and DATA segments initialization + * and before invoking the main() function. + */ +void hwinit1(void) { + + /* + * HAL initialization. + */ + halInit(); + + /* + * Extra, board-specific, initializations. + * NOTE: PIO1_2 is associated also to the JTAG, if you need to use JTAG + * you must comment that line first. + */ + LPC_IOCON->PIO0_7 = 0xC0; /* Disables pull-up on LED2 output. */ + LPC_IOCON->JTAG_nTRST_PIO1_2 = 0xC1; /* Disables pull-up on LED3B output + and makes it GPIO1_2. */ + LPC_IOCON->PIO1_9 = 0xC0; /* Disables pull-up on LED3R output.*/ + LPC_IOCON->PIO1_10 = 0xC0; /* Disables pull-up on LED3G output.*/ + + /* + * ChibiOS/RT initialization. + */ + chSysInit(); +} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1114/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1114/board.h new file mode 100644 index 0000000..9c0a616 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1114/board.h @@ -0,0 +1,85 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _BOARD_H_ +#define _BOARD_H_ + +/* + * Setup for Embedded Artists LPCXpresso Base Board with LPC1114 daughter + * board. + */ + +/* + * Board identifiers. + */ +#define BOARD_EA_BB_LPC1114 +#define BOARD_NAME "Embedded Artists LPCXpresso Base Board + LPC1114" + +/* + * Board frequencies. + */ +#define SYSOSCCLK 12000000 + +/* + * GPIO 0 initial setup. + * Bit7 - LPCxpresso LED, initially output at low level. + */ +#define VAL_GPIO0DIR PAL_PORT_BIT(GPIO0_LED2) +#define VAL_GPIO0DATA 0x00000000 + +/* + * GPIO 1 initial setup. + */ +#define VAL_GPIO1DIR PAL_PORT_BIT(GPIO1_LED3B) | \ + PAL_PORT_BIT(GPIO1_LED3R) | \ + PAL_PORT_BIT(GPIO1_LED3G) +#define VAL_GPIO1DATA 0x00000000 + +/* + * GPIO 2 initial setup. + */ +#define VAL_GPIO2DIR 0x00000000 +#define VAL_GPIO2DATA 0x00000000 + +/* + * GPIO 3 initial setup. + */ +#define VAL_GPIO3DIR 0x00000000 +#define VAL_GPIO3DATA 0x00000000 + +/* + * Pin definitions. + */ +#define GPIO0_SW3 1 +#define GPIO0_LED2 7 + +#define GPIO1_LED3B 2 +#define GPIO1_SW4 4 +#define GPIO1_LED3R 9 +#define GPIO1_LED3G 10 + +#ifdef __cplusplus +extern "C" { +#endif + void hwinit(void); +#ifdef __cplusplus +} +#endif + +#endif /* _BOARD_H_ */ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1114/board.mk b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1114/board.mk new file mode 100644 index 0000000..affca2d --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1114/board.mk @@ -0,0 +1,5 @@ +# List of all the board related files. +BOARDSRC = ${CHIBIOS}/boards/EA_LPCXPRESSO_BB_1114/board.c + +# Required include directories +BOARDINC = ${CHIBIOS}/boards/EA_LPCXPRESSO_BB_1114 diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1343/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1343/board.c new file mode 100644 index 0000000..fa2ab83 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1343/board.c @@ -0,0 +1,60 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "ch.h" +#include "hal.h" + +/* + * Early initialization code. + * This initialization is performed just after reset before BSS and DATA + * segments initialization. + */ +void hwinit0(void) { + + LPC13xx_clock_init(); +} + +/* + * Late initialization code. + * This initialization is performed after BSS and DATA segments initialization + * and before invoking the main() function. + */ +void hwinit1(void) { + + /* + * HAL initialization. + */ + halInit(); + + /* + * Extra, board-specific, initializations. + * NOTE: PIO1_2 is associated also to the JTAG, if you need to use JTAG + * you must comment that line first. + */ + LPC_IOCON->PIO0_7 = 0xC0; /* Disables pull-up on LED2 output. */ + LPC_IOCON->JTAG_nTRST_PIO1_2 = 0xC1; /* Disables pull-up on LED3B output + and makes it GPIO1_2. */ + LPC_IOCON->PIO1_9 = 0xC0; /* Disables pull-up on LED3R output.*/ + LPC_IOCON->PIO1_10 = 0xC0; /* Disables pull-up on LED3G output.*/ + + /* + * ChibiOS/RT initialization. + */ + chSysInit(); +} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1343/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1343/board.h new file mode 100644 index 0000000..4516cbc --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1343/board.h @@ -0,0 +1,85 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _BOARD_H_ +#define _BOARD_H_ + +/* + * Setup for Embedded Artists LPCXpresso Base Board with LPC1343 daughter + * board. + */ + +/* + * Board identifiers. + */ +#define BOARD_EA_BB_LPC1343 +#define BOARD_NAME "Embedded Artists LPCXpresso Base Board + LPC1343" + +/* + * Board frequencies. + */ +#define SYSOSCCLK 12000000 + +/* + * GPIO 0 initial setup. + * Bit7 - LPCxpresso LED, initially output at low level. + */ +#define VAL_GPIO0DIR PAL_PORT_BIT(GPIO0_LED2) +#define VAL_GPIO0DATA 0x00000000 + +/* + * GPIO 1 initial setup. + */ +#define VAL_GPIO1DIR PAL_PORT_BIT(GPIO1_LED3B) | \ + PAL_PORT_BIT(GPIO1_LED3R) | \ + PAL_PORT_BIT(GPIO1_LED3G) +#define VAL_GPIO1DATA 0x00000000 + +/* + * GPIO 2 initial setup. + */ +#define VAL_GPIO2DIR 0x00000000 +#define VAL_GPIO2DATA 0x00000000 + +/* + * GPIO 3 initial setup. + */ +#define VAL_GPIO3DIR 0x00000000 +#define VAL_GPIO3DATA 0x00000000 + +/* + * Pin definitions. + */ +#define GPIO0_SW3 1 +#define GPIO0_LED2 7 + +#define GPIO1_LED3B 2 +#define GPIO1_SW4 4 +#define GPIO1_LED3R 9 +#define GPIO1_LED3G 10 + +#ifdef __cplusplus +extern "C" { +#endif + void hwinit(void); +#ifdef __cplusplus +} +#endif + +#endif /* _BOARD_H_ */ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1343/board.mk b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1343/board.mk new file mode 100644 index 0000000..da59e98 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/EA_LPCXPRESSO_BB_1343/board.mk @@ -0,0 +1,5 @@ +# List of all the board related files. +BOARDSRC = ${CHIBIOS}/boards/EA_LPCXPRESSO_BB_1343/board.c + +# Required include directories +BOARDINC = ${CHIBIOS}/boards/EA_LPCXPRESSO_BB_1343 diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/GENERIC_SPC563/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/GENERIC_SPC563/board.c new file mode 100644 index 0000000..63e8828 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/GENERIC_SPC563/board.c @@ -0,0 +1,63 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "ch.h" +#include "hal.h" + +/* + * Early initialization code. + * This initialization is performed just after reset before BSS and DATA + * segments initialization. + */ +void hwinit0(void) { + + spc563_clock_init(); +} + +/* + * Late initialization code. + * This initialization is performed after BSS and DATA segments initialization + * and before invoking the main() function. + */ +void hwinit1(void) { + + /* + * Various initialization (temporary code). + */ + SIU.PCR[GPIO_LED1].R = 0x0300; /* OBE | IBE. */ + SIU.PCR[GPIO_LED2].R = 0x0300; /* OBE | IBE. */ + SIU.PCR[GPIO_LED3].R = 0x0300; /* OBE | IBE. */ + SIU.PCR[GPIO_LED4].R = 0x0300; /* OBE | IBE. */ + SIU.PCR[GPIO_BUTTON1].R = 0x0100; /* IBE. */ + SIU.PCR[GPIO_BUTTON2].R = 0x0100; /* IBE. */ + SIU.PCR[GPIO_BUTTON3].R = 0x0100; /* IBE. */ + SIU.PCR[GPIO_BUTTON4].R = 0x0100; /* IBE. */ + SIU.PCR[GPIO_SCI_A_TX].R = 0x0500; /* Primary | IBE. */ + SIU.PCR[GPIO_SCI_A_RX].R = 0x0500; /* Primary | IBE. */ + + /* + * HAL initialization. + */ + halInit(); + + /* + * ChibiOS/RT initialization. + */ + chSysInit(); +} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/GENERIC_SPC563/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/GENERIC_SPC563/board.h new file mode 100644 index 0000000..78213a1 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/GENERIC_SPC563/board.h @@ -0,0 +1,65 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _BOARD_H_ +#define _BOARD_H_ + +/* + * Setup for a generic SPC563 proto board. + */ + +/* + * Board identifiers. + */ +#define BOARD_GENERIC_SPC563 +#define BOARD_NAME "Generic SPC563" + +/* + * Board frequencies. + */ +#if !defined(EXTCLK) +#define EXTCLK 8000000 +#endif + +/* + * I/O definitions. + */ +#define GPIO_SCI_A_TX 89 +#define GPIO_SCI_A_RX 90 + +#define GPIO_BUTTON1 179 +#define GPIO_BUTTON2 181 +#define GPIO_BUTTON3 183 +#define GPIO_BUTTON4 187 + +#define GPIO_LED1 188 +#define GPIO_LED2 189 +#define GPIO_LED3 190 +#define GPIO_LED4 191 + +#ifdef __cplusplus +extern "C" { +#endif + void hwinit0(void); + void hwinit1(void); +#ifdef __cplusplus +} +#endif + +#endif /* _BOARD_H_ */ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/GENERIC_SPC563/board.mk b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/GENERIC_SPC563/board.mk new file mode 100644 index 0000000..78b2364 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/GENERIC_SPC563/board.mk @@ -0,0 +1,5 @@ +# List of all the board related files. +BOARDSRC = ${CHIBIOS}/boards/GENERIC_SPC563/board.c + +# Required include directories +BOARDINC = ${CHIBIOS}/boards/GENERIC_SPC563 diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.c index e7b8fca..cf2ced8 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.c @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ch.h" diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.h index e1667f5..70df97e 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,31 +10,25 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _BOARD_H_ #define _BOARD_H_ /* - * Setup for the Olimex LCP-P2148 proto board. + * Setup for the Olimex AVR-CAN proto board. */ /* * Board identifier. */ #define BOARD_OLIMEX_AVR_CAN +#define BOARD_NAME "Olimex AVR-CAN" /* * All inputs with pullups. diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.c index c8f5f1b..9f126c8 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.c @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ch.h" diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.h index c574410..16ccdf2 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,31 +10,25 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _BOARD_H_ #define _BOARD_H_ /* - * Setup for the Olimex LCP-P2148 proto board. + * Setup for the Olimex AVR-MT-128 proto board. */ /* * Board identifier. */ #define BOARD_OLIMEX_AVR_MT_128 +#define BOARD_NAME "Olimex AVR-MT-128" /* PA7 RLY DS B5 B4 B3 B2 B1 * IN OUT IN IN IN IN IN IN diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.c index c0cb482..a1ffef7 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.c @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ch.h" diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.h index 5dfab1a..3408f95 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _BOARD_H_ @@ -35,6 +28,7 @@ * Board identifier. */ #define BOARD_OLIMEX_LCP_P2148 +#define BOARD_NAME "Olimex LCP-P2148" /* * The following values are implementation dependent. You may change them in diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.c index 32b808e..9d55c0a 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.c @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.h index 1e13aa7..fcfd191 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _BUZZER_H_ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.c index 6504dc0..8bfb066 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.c @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <signal.h> diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.h index 0922d9c..34d6259 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _BOARD_H_ @@ -35,6 +28,7 @@ * Board identifier. */ #define BOARD_OLIMEX_MSP430_P1611 +#define BOARD_NAME "Olimex MSP430-P1611" /* * Clock constants. diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_SAM7_EX256/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_SAM7_EX256/board.c index ff0744e..c2a4603 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_SAM7_EX256/board.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_SAM7_EX256/board.c @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ch.h" diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_SAM7_EX256/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_SAM7_EX256/board.h index 9056bc7..259855f 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_SAM7_EX256/board.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_SAM7_EX256/board.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _BOARD_H_ @@ -35,6 +28,7 @@ * Board identifier. */ #define BOARD_OLIMEX_SAM7_EX256 +#define BOARD_NAME "Olimex SAM7-EX256" /* * Select your platform by modifying the following line. diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_STM32_P103/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_STM32_P103/board.c index 5903313..77f9581 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_STM32_P103/board.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_STM32_P103/board.c @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "ch.h" diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_STM32_P103/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_STM32_P103/board.h index 032d575..3cad240 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_STM32_P103/board.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_STM32_P103/board.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _BOARD_H_ @@ -35,6 +28,7 @@ * Board identifier. */ #define BOARD_OLIMEX_STM32_P103 +#define BOARD_NAME "Olimex STM32-P103" /* * Board frequencies. diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/RAISONANCE_REVA_STM8S/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/RAISONANCE_REVA_STM8S/board.c new file mode 100644 index 0000000..9d27cc6 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/RAISONANCE_REVA_STM8S/board.c @@ -0,0 +1,67 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "ch.h" +#include "hal.h" + +/* + * TIM 2 clock after the prescaler. + */ +#define TIM2_CLOCK (SYSCLK / 16) +#define TIM2_ARR ((TIM2_CLOCK / CH_FREQUENCY) - 1) + +/* + * TIM2 interrupt handler. + */ +CH_IRQ_HANDLER(13) { + + CH_IRQ_PROLOGUE(); + + chSysLockFromIsr(); + chSysTimerHandlerI(); + chSysUnlockFromIsr(); + + TIM2_SR1 = 0; + + CH_IRQ_EPILOGUE(); +} + +/* + * Board initialization code. + */ +void hwinit(void) { + + /* + * HAL initialization. + */ + halInit(); + + /* + * TIM2 initialization as system tick. + */ + CLK_PCKENR1 |= 32; /* PCKEN15, TIM2 clock source.*/ + TIM2_PSCR = 4; /* Prescaler divide by 2^4=16.*/ + TIM2_ARRH = TIM2_ARR >> 8; + TIM2_ARRL = TIM2_ARR; + TIM2_CNTRH = 0; + TIM2_CNTRL = 0; + TIM2_SR1 = 0; + TIM2_IER = 1; /* UIE */ + TIM2_CR1 = 1; /* CEN */ +} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/RAISONANCE_REVA_STM8S/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/RAISONANCE_REVA_STM8S/board.h new file mode 100644 index 0000000..adca216 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/RAISONANCE_REVA_STM8S/board.h @@ -0,0 +1,186 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _BOARD_H_ +#define _BOARD_H_ + +/* + * Setup for Raisonance REva V3 + STM8S208RB daughter board. + */ + +/* + * Board identifiers. + */ +#define BOARD_REVA_V3_STM8S208RB +#define BOARD_NAME "Raisonance REva V3 + STM8S208RB" + +/* + * Board frequencies. + */ +#define HSECLK 24000000 + +/* + * MCU model used on the board. + * The available models are listed in the file ./os/hal/platforms/stm8/stm8.h + */ +#define STM8_PLATFORM PLATFORM_STM8S208RB + +/* + * Pin definitions. + */ +#define PA_OSCIN 1 +#define PA_J2_25 2 /* It is also OSCOUT. */ +#define PA_J2_27 3 +#define PA_RX 4 +#define PA_TX 5 + +#define PB_LED(n) (n) +#define PB_LCD_D0 0 +#define PB_LCD_D1 1 +#define PB_LCD_CSB 2 +#define PB_LCD_RESB 3 + +#define PC_ADC_ETR 0 +#define PC_J2_51 1 +#define PC_J2_53 2 +#define PC_J2_55 3 +#define PC_J2_57 4 +#define PC_SCK 5 +#define PC_MOSI 6 +#define PC_MISO 7 + +#define PD_J2_69 0 +#define PD_J2_21 1 +#define PD_J2_67 2 +#define PD_J2_65 3 +#define PD_PWM 4 +#define PD_J2_63 5 +#define PD_J2_61 6 +#define PD_J2_59 7 + +#define PE_P2_49 0 +#define PE_SCL 1 +#define PE_SDA 2 +#define PE_P2_47 3 +#define PE_P2_45 4 +#define PE_P2_43 5 +#define PE_P2_41 6 +#define PE_P2_39 7 + +#define PF_J2_37 0 +#define PF_J2_35 1 +#define PF_J2_33 2 +#define PF_J2_31 3 +#define PF_ANA_IN1 4 +#define PF_ANA_IN2 5 +#define PF_ANA_TEMP 6 +#define PF_ANA_POT 7 + +#define PG_CAN_TX 0 +#define PG_CAN_RX 1 +#define PG_BT5 2 +#define PG_BT6 3 +#define PG_SW4 4 +#define PG_SW3 5 +#define PG_SW2 6 +#define PG_SW1 7 + +#define PI_J2_71 0 + +/* + * Port A initial setup. + */ +#define VAL_GPIOAODR (1 << PA_TX) /* PA_TX initially to 1. */ +#define VAL_GPIOADDR (1 << PA_TX) /* PA_TX output, others inputs. */ +#define VAL_GPIOACR1 0xFF /* All pull-up or push-pull. */ +#define VAL_GPIOACR2 0 + +/* + * Port B initial setup. + */ +#define VAL_GPIOBODR 0xFF /* Initially all set to high. */ +#define VAL_GPIOBDDR 0xFF /* All outputs. */ +#define VAL_GPIOBCR1 0xFF /* All push-pull. */ +#define VAL_GPIOBCR2 0 + +/* + * Port C initial setup. + */ +#define VAL_GPIOCODR 0 +#define VAL_GPIOCDDR 0 /* All inputs. */ +#define VAL_GPIOCCR1 0xFF /* All pull-up. */ +#define VAL_GPIOCCR2 0 + +/* + * Port D initial setup. + */ +#define VAL_GPIODODR 0 +#define VAL_GPIODDDR 0 /* All inputs. */ +#define VAL_GPIODCR1 0xFF /* All pull-up. */ +#define VAL_GPIODCR2 0 + +/* + * Port E initial setup. + */ +#define VAL_GPIOEODR 0 +#define VAL_GPIOEDDR 0 /* All inputs. */ +#define VAL_GPIOECR1 0xFF /* All pull-up. */ +#define VAL_GPIOECR2 0 + +/* + * Port F initial setup. + */ +#define VAL_GPIOFODR 0 +#define VAL_GPIOFDDR 0 /* All inputs. */ +#define VAL_GPIOFCR1 0xFF /* All pull-up. */ +#define VAL_GPIOFCR2 0 + +/* + * Port G initial setup. + */ +#define VAL_GPIOGODR (1 << PG_CAN_TX)/* CAN_TX initially to 1. */ +#define VAL_GPIOGDDR (1 << PG_CAN_TX)/* CAN_TX output, others inputs. */ +#define VAL_GPIOGCR1 0xFF /* All pull-up or push-pull. */ +#define VAL_GPIOGCR2 0 + +/* + * Port H initial setup (dummy, not present). + */ +#define VAL_GPIOHODR 0 +#define VAL_GPIOHDDR 0 /* All inputs. */ +#define VAL_GPIOHCR1 0xFF /* All pull-up. */ +#define VAL_GPIOHCR2 0 + +/* + * Port I initial setup. + */ +#define VAL_GPIOIODR 0 +#define VAL_GPIOIDDR 0 /* All inputs. */ +#define VAL_GPIOICR1 0xFF /* All pull-up. */ +#define VAL_GPIOICR2 0 + +#ifdef __cplusplus +extern "C" { +#endif + void hwinit(void); +#ifdef __cplusplus +} +#endif + +#endif /* _BOARD_H_ */ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/hal.dox b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/hal.dox index bd843de..08a3ebb 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/hal.dox +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/hal.dox @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,18 +10,11 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/adc.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/adc.h index 61c6b7c..983fe0f 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/adc.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/adc.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,23 +10,17 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** - * @file adc.h - * @brief ADC Driver macros and structures. + * @file adc.h + * @brief ADC Driver macros and structures. + * * @addtogroup ADC * @{ */ @@ -57,7 +51,7 @@ /*===========================================================================*/ /** - * @brief Driver state machine possible states. + * @brief Driver state machine possible states. */ typedef enum { ADC_UNINIT = 0, /**< @brief Not initialized. */ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/can.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/can.h index 8d6dd68..b503dd8 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/can.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/can.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,23 +10,17 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** - * @file can.h - * @brief CAN Driver macros and structures. + * @file can.h + * @brief CAN Driver macros and structures. + * * @addtogroup CAN * @{ */ @@ -41,23 +35,23 @@ /*===========================================================================*/ /** - * @brief Errors rate warning. + * @brief Errors rate warning. */ #define CAN_LIMIT_WARNING 1 /** - * @brief Errors rate error. + * @brief Errors rate error. */ #define CAN_LIMIT_ERROR 2 /** - * @brief Bus off condition reached. + * @brief Bus off condition reached. */ #define CAN_BUS_OFF_ERROR 4 /** - * @brief Framing error of some kind on the CAN bus. + * @brief Framing error of some kind on the CAN bus. */ #define CAN_FRAMING_ERROR 8 /** - * @brief Overflow in receive queue. + * @brief Overflow in receive queue. */ #define CAN_OVERFLOW_ERROR 16 @@ -66,7 +60,7 @@ /*===========================================================================*/ /** - * @brief Sleep mode related APIs inclusion switch. + * @brief Sleep mode related APIs inclusion switch. */ #define CAN_USE_SLEEP_MODE TRUE @@ -83,7 +77,7 @@ /*===========================================================================*/ /** - * @brief Driver state machine possible states. + * @brief Driver state machine possible states. */ typedef enum { CAN_UNINIT = 0, /**< @brief Not initialized. */ @@ -100,7 +94,7 @@ typedef enum { /*===========================================================================*/ /** - * @brief Adds some flags to the CAN status mask. + * @brief Adds some flags to the CAN status mask. * * @param[in] canp pointer to the @p CANDriver object * @param[in] mask flags to be added to the status mask diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/hal.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/hal.h index 821747a..1084baf 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/hal.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/hal.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,23 +10,17 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** - * @file hal.h - * @brief HAL subsystem header. + * @file hal.h + * @brief HAL subsystem header. + * * @addtogroup HAL * @{ */ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/mac.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/mac.h index 5b20d49..a180cc4 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/mac.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/os/hal/include/mac.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. This file is part of ChibiOS/RT. @@ -10,23 +10,16 @@ ChibiOS/RT 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 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - --- - - A special exception to the GPL can be applied should you wish to distribute - a combined work that includes ChibiOS/RT, without being obliged to provide - the source code for any proprietary components. See the file exception.txt - for full details of how and when the exception can be applied. + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** - * @file mac.h - * @brief MAC Driver macros and structures. + * @file mac.h + * @brief MAC Driver macros and structures. * @addtogroup MAC * @{ */ @@ -63,37 +56,38 @@ /*===========================================================================*/ ... [truncated message content] |
From: Jérémie D. <Ba...@us...> - 2010-04-23 15:42:50
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 53011d40f475d331129d27c4494e551dffac308a (commit) from 4e1406903f99434b59ebcadf6236dc6d65f0932c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 53011d40f475d331129d27c4494e551dffac308a Author: Jérémie Dimino <dim@gaia.(none)> Date: Fri Apr 23 17:40:35 2010 +0200 use Obus_property.updates for monitoring robot properties ----------------------------------------------------------------------- Changes: diff --git a/info/control/clients/controller.ml b/info/control/clients/controller.ml index 72c8bbd..cf5792f 100644 --- a/info/control/clients/controller.ml +++ b/info/control/clients/controller.ml @@ -452,18 +452,19 @@ lwt () = notify box; notify logs; notify services; - - lwt () = OBus_bus.add_match bus (OBus_match.rule ~typ:`Signal ~member:"ProppertiesChanged" ()) in - let _ = - Lwt_sequence.add_l - (function - | { OBus_message.typ = OBus_message.Signal(_, _, "PropertiesChanged") } as msg -> - push (); - Some msg - | msg -> - Some msg) - (OBus_connection.incoming_filters bus) + let notify_property property = + Lwt_event.always_notify + (fun _ -> push ()) + (OBus_property.updates property) in + notify_property (Krobot.compass krobot); + notify_property (Krobot.logic_sensors krobot); + notify_property (Krobot.range_finders krobot); + notify_property (Krobot.inhibit_forward_until krobot); + notify_property (Krobot.inhibit_backward_until krobot); + notify_property (Krobot.Card.state krobot `Interface); + notify_property (Krobot.Card.state krobot `Sensor); + notify_property (Krobot.Card.state krobot `Motor); List.iter (fun card -> hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2010-04-23 08:59:55
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 4e1406903f99434b59ebcadf6236dc6d65f0932c (commit) from 8b3e9b66e2076f44754a5283696bc17f3288f6d1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4e1406903f99434b59ebcadf6236dc6d65f0932c Author: Jérémie Dimino <dim@gaia.(none)> Date: Fri Apr 23 10:59:02 2010 +0200 use only lowercase letters in script paths ----------------------------------------------------------------------- Changes: diff --git a/info/control/clients/script.ml b/info/control/clients/script.ml index dba63be..4649704 100644 --- a/info/control/clients/script.ml +++ b/info/control/clients/script.ml @@ -569,7 +569,7 @@ let make_command cmd = { (Value.arg_names cmd.Commands.send) (Value.C.type_sequence (Value.arg_types cmd.Commands.send)); c_name = cmd.Commands.name; - c_path = ["unsafe"; cmd.Commands.section]; + c_path = ["unsafe"; String.lowercase cmd.Commands.section]; c_exec = fun args logger krobot -> let args = hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2010-04-23 08:53:21
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 8b3e9b66e2076f44754a5283696bc17f3288f6d1 (commit) from ad5e0b49e34128237c74cb551a2f3243387d9a3f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8b3e9b66e2076f44754a5283696bc17f3288f6d1 Author: Jérémie Dimino <dim@gaia.(none)> Date: Fri Apr 23 10:51:53 2010 +0200 Use record instead of labelled arguments for D-Bus interface creation This improve error messages ----------------------------------------------------------------------- Changes: diff --git a/info/control/driver/driver.ml b/info/control/driver/driver.ml index 70fbde6..d8614ac 100644 --- a/info/control/driver/driver.ml +++ b/info/control/driver/driver.ml @@ -59,6 +59,8 @@ struct value : int React.signal; } + open Krobot_interfaces.Fr_krobot_Device_Compass + let make card path = lwt value = make_signal ~update_delay:(Config.update_delay *. 2.) (fun card -> snd =|< USBCard.call Commands.Compass.get card ()) card in let dev = { @@ -67,8 +69,9 @@ struct ~interfaces:[Export_unsafe.interface "compass" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_Compass.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~p_Value:(fun dev -> React.S.map Int32.of_int dev.value) - ()] + { + p_Value = (fun dev -> React.S.map Int32.of_int dev.value); + }] path; card = card; value = value; @@ -88,6 +91,8 @@ struct card : USBCard.t; } + open Krobot_interfaces.Fr_krobot_Device_LCD + let set_lcd dev lines = if List.length lines > 4 || List.exists (fun line -> String.length line > 20) lines then invalid_arg "SetLCD" @@ -114,10 +119,11 @@ struct ~interfaces:[Export_unsafe.interface "LCD" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_LCD.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~m_SetLCD:(fun ctx -> set_lcd) - ~m_BacklightOn:(fun ctx obj () -> backlight_on obj) - ~m_BacklightOff:(fun ctx obj () -> backlight_off obj) - ()] + { + m_SetLCD = (fun ctx -> set_lcd); + m_BacklightOn = (fun ctx obj () -> backlight_on obj); + m_BacklightOff = (fun ctx obj () -> backlight_off obj); + }] path; card = card; } in @@ -136,6 +142,8 @@ struct card : USBCard.t; } + open Krobot_interfaces.Fr_krobot_Device_Servo + let claws_enable dev = USBCard.call Commands.Servo.set_config dev.card (0b10100, 0) @@ -158,12 +166,13 @@ struct ~interfaces:[Export_unsafe.interface "servo" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_Servo.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~m_ClawsEnable:(fun ctx obj () -> claws_enable obj) - ~m_ClawsDisable:(fun ctx obj () -> claws_disable obj) - ~m_ClawsOpen:(fun ctx obj () -> claws_open obj) - ~m_ClawsClose:(fun ctx obj () -> claws_close obj) - ~m_ClawsTake:(fun ctx obj () -> claws_take obj) - ()] + { + m_ClawsEnable = (fun ctx obj () -> claws_enable obj); + m_ClawsDisable = (fun ctx obj () -> claws_disable obj); + m_ClawsOpen = (fun ctx obj () -> claws_open obj); + m_ClawsClose = (fun ctx obj () -> claws_close obj); + m_ClawsTake = (fun ctx obj () -> claws_take obj); + }] path; card = card; } in @@ -182,6 +191,8 @@ struct card : USBCard.t; } + open Krobot_interfaces.Fr_krobot_Device_AX12 + let grip_up_position = 880 let grip_down_position = 580 let ax12_default_velocity = 50 @@ -255,7 +266,8 @@ struct ~interfaces:[Export_unsafe.interface "AX12" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_AX12.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~m_SetAX12:(fun ctx obj positions -> + { + m_SetAX12 = (fun ctx obj positions -> let positions = List.map (fun (x1, x2, x3) -> @@ -264,13 +276,13 @@ struct aa_velocity = Int32.to_int x3 }) positions in - set_ax12 obj positions) - ~m_GripUp:(fun ctx obj () -> grip_up obj) - ~m_GripDown:(fun ctx obj () -> grip_down obj) - ~m_GripOpen:(fun ctx obj () -> grip_open obj) - ~m_GripClose:(fun ctx obj () -> grip_close obj) - ~m_GripRelease:(fun ctx obj () -> grip_release obj) - ()] + set_ax12 obj positions); + m_GripUp = (fun ctx obj () -> grip_up obj); + m_GripDown = (fun ctx obj () -> grip_down obj); + m_GripOpen = (fun ctx obj () -> grip_open obj); + m_GripClose = (fun ctx obj () -> grip_close obj); + m_GripRelease = (fun ctx obj () -> grip_release obj); + }] path; card = card; } @@ -291,6 +303,8 @@ struct value : bool array React.signal; } + open Krobot_interfaces.Fr_krobot_Device_LogicSensors + let make card path = lwt value = make_signal (fun card -> USBCard.call Commands.Logic_sensors.get_state card ()) card in let dev = { @@ -299,8 +313,9 @@ struct ~interfaces:[Export_unsafe.interface "logic-sensors" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_LogicSensors.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~p_Value:(fun dev -> React.S.map Array.to_list dev.value) - ()] + { + p_Value = (fun dev -> React.S.map Array.to_list dev.value); + }] path; card = card; value = value; @@ -321,6 +336,8 @@ struct value : int array React.signal; } + open Krobot_interfaces.Fr_krobot_Device_RangeFinders + let get_calibration dev id = USBCard.call Commands.Range_finders.get_calibration dev.card id @@ -341,16 +358,17 @@ struct ~interfaces:[Export_unsafe.interface "range-finders" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_RangeFinders.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~p_Value:(fun dev -> React.S.map (fun a -> List.map Int32.of_int (Array.to_list a)) dev.value) - ~m_GetCalibration:(fun ctx obj id -> - lwt result = get_calibration obj (Int32.to_int id) in - return (List.map Int32.of_int (Array.to_list result))) - ~m_CalibrationStart:(fun ctx obj (id, skip_measure) -> - let id = Int32.to_int id in - calibration_start obj id skip_measure) - ~m_CalibrationStop:(fun ctx obj () -> calibration_stop obj) - ~m_CalibrationContinue:(fun ctx obj () -> calibration_continue obj) - ()] + { + p_Value = (fun dev -> React.S.map (fun a -> List.map Int32.of_int (Array.to_list a)) dev.value); + m_GetCalibration = (fun ctx obj id -> + lwt result = get_calibration obj (Int32.to_int id) in + return (List.map Int32.of_int (Array.to_list result))); + m_CalibrationStart = (fun ctx obj (id, skip_measure) -> + let id = Int32.to_int id in + calibration_start obj id skip_measure); + m_CalibrationStop = (fun ctx obj () -> calibration_stop obj); + m_CalibrationContinue = (fun ctx obj () -> calibration_continue obj); + }] path; card = card; value = value; @@ -365,6 +383,8 @@ end module Motors = struct + open Krobot_interfaces.Fr_krobot_Device_Motors + type trajectory = { trajectory : [ `Forward | `Backward | `Left | `Right | `Goto ]; mutable stopped : bool; @@ -665,39 +685,40 @@ struct ~interfaces:[Export_unsafe.interface "motors" (fun dev -> dev.card); Krobot_interfaces.Fr_krobot_Device_Motors.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~m_Turn:(fun ctx obj (angle, velocity, acceleration) -> - let angle = Int32.to_int angle in - let velocity = Int32.to_int velocity in - let acceleration = Int32.to_int acceleration in - turn obj angle velocity acceleration >|= int32_of_move_result) - ~m_Move:(fun ctx obj (distance, velocity, acceleration) -> - let distance = Int32.to_int distance in - let velocity = Int32.to_int velocity in - let acceleration = Int32.to_int acceleration in - move obj distance velocity acceleration >|= int32_of_move_result) - ~m_Goto:(fun ctx obj (x, y, velocity, acceleration, mode, bypass_distance) -> - let x = Int32.to_int x in - let y = Int32.to_int y in - let velocity = Int32.to_int velocity in - let acceleration = Int32.to_int acceleration in - let mode = goto_mode_of_int32 mode in - let bypass_distance = Int32.to_int bypass_distance in - goto obj x y velocity acceleration mode bypass_distance >|= int32_of_move_result) - ~m_StopMotors:(fun ctx obj mode -> - let mode = stop_mode_of_int32 mode in - stop_motors obj mode) - ~m_SetVelocities:(fun ctx obj (velocity_l, acceleration_l, velocity_r, acceleration_r, duration) -> - let velocity_l = Int32.to_int velocity_l in - let acceleration_l = Int32.to_int acceleration_l in - let velocity_r = Int32.to_int velocity_r in - let acceleration_r = Int32.to_int acceleration_r in - set_velocities obj (velocity_l, velocity_r) (acceleration_l, acceleration_r) duration) - ~p_InhibitForwardUntil:((fun obj -> Var.signal obj.inhibit_forward_until), - (fun ctx -> set_inhibit_forward_until)) - ~p_InhibitBackwardUntil:((fun obj -> Var.signal obj.inhibit_backward_until), - (fun ctx -> set_inhibit_backward_until)) - ~p_State:(fun obj -> state obj) - ()] + { + m_Turn = (fun ctx obj (angle, velocity, acceleration) -> + let angle = Int32.to_int angle in + let velocity = Int32.to_int velocity in + let acceleration = Int32.to_int acceleration in + turn obj angle velocity acceleration >|= int32_of_move_result); + m_Move = (fun ctx obj (distance, velocity, acceleration) -> + let distance = Int32.to_int distance in + let velocity = Int32.to_int velocity in + let acceleration = Int32.to_int acceleration in + move obj distance velocity acceleration >|= int32_of_move_result); + m_Goto = (fun ctx obj (x, y, velocity, acceleration, mode, bypass_distance) -> + let x = Int32.to_int x in + let y = Int32.to_int y in + let velocity = Int32.to_int velocity in + let acceleration = Int32.to_int acceleration in + let mode = goto_mode_of_int32 mode in + let bypass_distance = Int32.to_int bypass_distance in + goto obj x y velocity acceleration mode bypass_distance >|= int32_of_move_result); + m_StopMotors = (fun ctx obj mode -> + let mode = stop_mode_of_int32 mode in + stop_motors obj mode); + m_SetVelocities = (fun ctx obj (velocity_l, acceleration_l, velocity_r, acceleration_r, duration) -> + let velocity_l = Int32.to_int velocity_l in + let acceleration_l = Int32.to_int acceleration_l in + let velocity_r = Int32.to_int velocity_r in + let acceleration_r = Int32.to_int acceleration_r in + set_velocities obj (velocity_l, velocity_r) (acceleration_l, acceleration_r) duration); + p_InhibitForwardUntil = ((fun obj -> Var.signal obj.inhibit_forward_until), + (fun ctx -> set_inhibit_forward_until)); + p_InhibitBackwardUntil = ((fun obj -> Var.signal obj.inhibit_backward_until), + (fun ctx -> set_inhibit_backward_until)); + p_State = (fun obj -> state obj); + }] path; card = card; inhibit_forward_until = Var.create 0.0; @@ -727,6 +748,8 @@ let card_motor, set_card_motor = React.S.create None module Manager = struct + open Krobot_interfaces.Fr_krobot_Manager + let close card = match React.S.value card with | None -> return () @@ -759,9 +782,10 @@ struct OBus_object.make ~interfaces:[Krobot_interfaces.Fr_krobot_Manager.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~m_CardStates:(fun ctx obj () -> card_states obj) - ~m_Shutdown:(fun ctx obj () -> shutdown ctx obj) - ()] + { + m_CardStates = (fun ctx obj () -> card_states obj); + m_Shutdown = (fun ctx obj () -> shutdown ctx obj); + }] ["fr"; "krobot"; "Manager"] in OBus_object.attach manager (); @@ -774,6 +798,8 @@ end module Card = struct + open Krobot_interfaces.Fr_krobot_Card + type t = { card : USBCard.t option React.signal; obus : t OBus_object.t; @@ -813,14 +839,15 @@ struct ~interfaces:[Export_unsafe.interface "card" get_card; Krobot_interfaces.Fr_krobot_Card.make ~notify_mode:(OBus_object.notify_update "PropertiesChanged") - ~p_Name:(fun obj -> React.S.const name) - ~p_State:(fun obj -> React.S.map int32_of_card_state obj.state) - ~m_GetFirmwareBuild:(fun ctx obj () -> get_firmware_build obj) - ~m_GetBoardInfo:(fun ctx obj () -> get_board_info obj) - ~m_Bootloader:(fun ctx obj () -> bootloader obj) - ~m_Reset:(fun ctx obj () -> reset obj) - ~m_Test:(fun ctx obj () -> test obj) - ()] + { + p_Name = (fun obj -> React.S.const name); + p_State = (fun obj -> React.S.map int32_of_card_state obj.state); + m_GetFirmwareBuild = (fun ctx obj () -> get_firmware_build obj); + m_GetBoardInfo = (fun ctx obj () -> get_board_info obj); + m_Bootloader = (fun ctx obj () -> bootloader obj); + m_Reset = (fun ctx obj () -> reset obj); + m_Test = (fun ctx obj () -> test obj); + }] path; card = card; name = name; hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2010-04-22 14:32:03
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via ad5e0b49e34128237c74cb551a2f3243387d9a3f (commit) from 15f2f81f08e1a3684c09b9be858889a925977fb4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ad5e0b49e34128237c74cb551a2f3243387d9a3f Author: Jérémie Dimino <dim@gaia.(none)> Date: Thu Apr 22 16:30:05 2010 +0200 terminate code upgrade ----------------------------------------------------------------------- Changes: diff --git a/info/control/Makefile b/info/control/Makefile index ab1e117..8850da0 100644 --- a/info/control/Makefile +++ b/info/control/Makefile @@ -32,15 +32,15 @@ install: $(wildcard _build/*.cmxa) \ $(wildcard _build/*.cmxs) \ $(wildcard _build/*.a) - install -m 0755 _build/card-tools/krobot_send_firmware.best $(PREFIX)/bin/krobot-send-firmware - install -m 0755 _build/card-tools/krobot_dump_memory.best $(PREFIX)/bin/krobot-dump-memory - install -m 0755 _build/tools/krobot_forward_dbus.best $(PREFIX)/bin/krobot-forward-dbus - install -m 0755 _build/clients/krobot_info.best $(PREFIX)/bin/krobot-info - install -m 0755 _build/clients/krobot_joy_control.best $(PREFIX)/bin/krobot-joystick - install -m 0755 _build/clients/krobot_controller.best $(PREFIX)/bin/krobot-controller - install -m 0755 _build/services/krobot_hard_stop.best $(PREFIX)/bin/krobot-hard-stop - install -m 0755 _build/driver/krobot_driver.best $(PREFIX)/bin/krobot-driver - install -m 0755 _build/clients/krobot_ax12.best $(PREFIX)/bin/krobot-ax12 + install -m 0755 _build/card-tools/send_firmware.best $(PREFIX)/bin/krobot-send-firmware + install -m 0755 _build/card-tools/dump_memory.best $(PREFIX)/bin/krobot-dump-memory + install -m 0755 _build/tools/forward_dbus.best $(PREFIX)/bin/krobot-forward-dbus + install -m 0755 _build/clients/info.best $(PREFIX)/bin/krobot-info + install -m 0755 _build/clients/joy_control.best $(PREFIX)/bin/krobot-joystick + install -m 0755 _build/clients/controller.best $(PREFIX)/bin/krobot-controller + install -m 0755 _build/services/hard_stop.best $(PREFIX)/bin/krobot-hard-stop + install -m 0755 _build/driver/driver.best $(PREFIX)/bin/krobot-driver + install -m 0755 _build/clients/ax12_control.best $(PREFIX)/bin/krobot-ax12 .PHONY: uninstall uninstall: diff --git a/info/control/_tags b/info/control/_tags index 1aaed9b..6cd01b3 100644 --- a/info/control/_tags +++ b/info/control/_tags @@ -26,10 +26,10 @@ <clients/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log <clients/**>: pkg_lwt.unix, pkg_obus -<clients/krobot_joy_control.*>: pkg_sdl -<clients/krobot_controller.*>: pkg_lwt.text -<clients/krobot_script*>: pkg_text -<clients/krobot_ax12.*>: pkg_lwt.text +<clients/joy_control.*>: pkg_sdl +<clients/controller.*>: pkg_lwt.text +<clients/script{.*,_lexer.*}>: pkg_text +<clients/ax12_control.*>: pkg_lwt.text # +------------------------------------------------------------------+ # | Services | @@ -55,8 +55,8 @@ # | Tools | # +------------------------------------------------------------------+ -<tools/krobot_forward_dbus.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log -<tools/krobot_forward_dbus.*>: pkg_obus +<tools/forward_dbus.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log +<tools/forward_dbus.*>: pkg_obus # +------------------------------------------------------------------+ # | Tests | diff --git a/info/control/card-tools/boardname.mli b/info/control/card-tools/boardname.mli new file mode 100644 index 0000000..51dc1b5 --- /dev/null +++ b/info/control/card-tools/boardname.mli @@ -0,0 +1,12 @@ +(* + * krobot_boardname.mli + * -------------------- + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + +val get_board_name : string -> string option + (** [get_board_name dump] recherche dans le [dump] mémoire (peut + être également un fichier .hex chargé) le nom de la carte. *) diff --git a/info/control/card-tools/boardname.mll b/info/control/card-tools/boardname.mll new file mode 100644 index 0000000..96b39b6 --- /dev/null +++ b/info/control/card-tools/boardname.mll @@ -0,0 +1,22 @@ +(* + * krobot_boardname.mll + * -------------------- + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + + +let boardname_regex = ("Carte " | "Robot Interface" | "Battery Monitoring ") [^'\n']+ + +rule boardname = parse + | (boardname_regex as name) '\n' { Some name } + | _ { boardname lexbuf } + | eof { None } + +{ + let get_board_name str = + let lexbuf = Lexing.from_string str in + boardname lexbuf +} diff --git a/info/control/card-tools/bootloader.ml b/info/control/card-tools/bootloader.ml new file mode 100644 index 0000000..7151d00 --- /dev/null +++ b/info/control/card-tools/bootloader.ml @@ -0,0 +1,184 @@ +(* + * krobot_Bootloader.ml + * -------------------- + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + +open Lwt +open Lwt_io + +(* Code très inspiré de kard.ml, mais mis à part car le mode de + communication avec la carte est différent (bulk au lieu + d'interrupt). *) + +type t = { + mutable is_open : bool; + (* La carte est-elle ouverte ? *) + + handle : USB.handle; + (* Handle pour le périphérique usb *) + + kernel_active : bool; + (* Est-ce qu'un driver noyau était attaché à la carte avant qu'on + l'utilise ? *) +} + +type error = + | IncompleteWrite of int * int + | IncompleteRead of int * int + | UnexpectedReply of string * string + | WriteError of string * string + +let string_of_error = function + | IncompleteWrite (a, b) -> Printf.sprintf "%d byte(s) written instead of %d" a b + | IncompleteRead (a, b) -> Printf.sprintf "%d byte(s) read instead of %d" a b + | UnexpectedReply (a, b) -> Printf.sprintf "received unexpected reply %S instead of %S" a b + | WriteError (a, b) -> Printf.sprintf "written: %S, read back: %S" a b + +exception Error of error + +let failwith e = fail (Error e) + +let close k = + if k.is_open then begin + lwt _ = USB.release_interface k.handle 0 in + lwt _ = USB.reset_device k.handle in + (*if k.kernel_active then USB.attach_kernel_driver k.handle 0;*) + (*USB.close k.handle;*) + k.is_open <- false; + return () + end else return () + +let open_card () = + let handle = USB.open_device_with + ~vendor_id:PcInterface.usb_vid + ~product_id:PcInterface.usb_pid_bootloader + in + let kernel_active = USB.kernel_driver_active handle 0 in + if kernel_active then USB.detach_kernel_driver handle 0; + lwt _ = USB.set_configuration handle 1 in + lwt _ = USB.claim_interface handle 0 in + let k = { is_open = true; + handle = handle; + kernel_active = kernel_active } in + let _ = Lwt_sequence.add_l (fun _ -> close k) Lwt_main.exit_hooks in + return k + +let header_length = 5 + +let put_message buffer cmd length address data = + let body_length = String.length data in + assert (String.length buffer >= header_length+body_length); + let set i n = buffer.[i] <- char_of_int n in + set 0 cmd; + assert (length < 0x100); + set 1 length; + assert (address <= 0x1000000); + set 2 (address land 0xff); + set 3 ((address lsr 8) land 0xff); + set 4 ((address lsr 16) land 0xff); + String.blit data 0 buffer 5 body_length + +let send_receive_packet k send_buffer send_length receive_buffer receive_length send_delay receive_delay = + let handle = k.handle and endpoint = 1 in + lwt sent = USB.bulk_send ~handle ~endpoint ~timeout:1. send_buffer 0 send_length in + if sent <> send_length then + failwith (IncompleteWrite (sent, send_length)) + else begin + lwt received = USB.bulk_recv ~handle ~endpoint ~timeout:3. receive_buffer 0 receive_length in + if received <> receive_length then + failwith (IncompleteRead (received, receive_length)) + else + return () + end + +let get_flash k ~address ~length = + let response_length = 64 in + let increment = response_length-header_length in + assert (increment < 256); + let send_buffer = String.create header_length in + let receive_buffer = String.create response_length in + let result_buffer = String.create length in + let rec loop offset total_length = + if total_length <= 0 then + return result_buffer + else begin + let length = min increment total_length in + let response_length = length+header_length in + let address = address+offset in + put_message send_buffer PcInterface.read_flash length address ""; + lwt () = send_receive_packet k send_buffer header_length receive_buffer response_length 1. 3. in + let receive_header = String.sub receive_buffer 0 header_length in + if receive_header <> send_buffer then + failwith (UnexpectedReply (receive_header, send_buffer)) + else begin + String.blit receive_buffer header_length result_buffer offset length; + loop (offset+length) (total_length-length); + end + end + in loop 0 length + +let erase_flash k ~address ~length = + let response_length = 1 in + (* les effacements se font par blocs de 64 octets *) + let increment = 64 in + let send_buffer = String.create header_length in + let receive_buffer = String.create response_length in + let rec loop offset total_length = + if total_length <= 0 then + return () + else begin + let address = address+offset in + put_message send_buffer PcInterface.erase_flash 1 address ""; + lwt () = send_receive_packet k send_buffer header_length receive_buffer response_length 1. 5. in + if int_of_char receive_buffer.[0] <> PcInterface.erase_flash then + failwith (UnexpectedReply (receive_buffer, String.make 1 (char_of_int PcInterface.erase_flash))) + else + loop (offset+increment) (total_length-increment); + end + in loop 0 length + +let reference = String.make 16 '\255' + +let write_flash k ~address data offset length = + let send_length = 64 and receive_length = 1 in + (* les écritures se font par blocs de 16 octets *) + let increment = 16 in + let send_buffer = String.create send_length in + let receive_buffer = String.create receive_length in + let rec loop address offset total_length = + (* address: sur le PIC, offset: dans data, total_length: taille restante *) + if total_length <= 0 then + return () + else begin + let packet = String.make increment '\255' in + String.blit data offset packet 0 (min total_length increment); + if packet = reference then begin + (* le paquet n'a pas de contenu, on l'ignore *) + (* lwt () = printf "Skipping address 0x%06X...\n" address in *) + loop (address+increment) (offset+increment) (total_length-increment) + end else begin + (* lwt () = printf "Processing address 0x%06X...\n" address in *) + put_message send_buffer PcInterface.write_flash increment address packet; + lwt () = send_receive_packet k send_buffer send_length receive_buffer receive_length 0.5 1. in + if int_of_char receive_buffer.[0] <> PcInterface.write_flash then + failwith (UnexpectedReply (receive_buffer, String.make 1 (char_of_int PcInterface.erase_flash))) + else begin + lwt written = get_flash k ~address ~length:increment in + if written <> packet then + failwith (WriteError (packet, written)) + else + loop (address+increment) (offset+increment) (total_length-increment) + end + end + end + in loop address offset length + +let reset_board k = + let send_buffer = String.create 64 and receive_buffer = String.create 64 in + send_buffer.[0] <- char_of_int PcInterface.reset; + lwt () = send_receive_packet k send_buffer 1 receive_buffer 64 5. 5. in + return () diff --git a/info/control/card-tools/dump_memory.ml b/info/control/card-tools/dump_memory.ml new file mode 100644 index 0000000..a19af09 --- /dev/null +++ b/info/control/card-tools/dump_memory.ml @@ -0,0 +1,28 @@ +(* + * krobot_dump_memory.ml + * --------------------- + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + +open Printf +open Lwt +open Lwt_io + +lwt () = + lwt k = Bootloader.open_card () in + try_lwt + lwt data = Bootloader.get_flash k ~address:0x0 ~length:0x8000 in + let msg = match Boardname.get_board_name data with + | Some s -> sprintf "Board: %S" s + | None -> "Unable to identify board!" + in + lwt () = eprintlf "%s" msg in + (if Unix.isatty Unix.stdout then hexdump else write) stdout data >> flush stdout + with + | Bootloader.Error e -> + eprintlf "%s" (Bootloader.string_of_error e) + | e -> + eprintlf "%s" (Printexc.to_string e) diff --git a/info/control/card-tools/hexfile.ml b/info/control/card-tools/hexfile.ml new file mode 100644 index 0000000..2d2c361 --- /dev/null +++ b/info/control/card-tools/hexfile.ml @@ -0,0 +1,112 @@ +(* + * krobot_hexfile.ml + * ----------------- + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + +open Lwt +open Lwt_io + +type hex_record = + | Data of int * string + | ExtendedLinearAddress of int + | EndOfFile of int + +let string_of_hexline str = + let n = String.length str in + assert (n > 0 && n mod 2 = 1 && str.[0] = ':'); + let m = n/2 in + let result = String.create m in + for i = 0 to m-1 do + let j = 2*i+1 in + result.[i] <- char_of_int (int_of_string ("0x"^(String.sub str j 2))) + done; + result + +let compute_checksum str = + let rec aux i accu = + if i < 0 then + (-accu) land 0xff + else + aux (i-1) (accu+(int_of_char str.[i])) + in aux (String.length str - 2) 0 + +let parse_line str = + let str = string_of_hexline str in + let get i = int_of_char str.[i] in + let n = String.length str in + assert (n >= 5 && compute_checksum str = int_of_char str.[n-1]); + let count = get 0 in + assert (count+5 = n); + let address = ((get 1) lsl 8) lor (get 2) in + let record_type = get 3 in + let data = String.sub str 4 count in + match record_type with + | 0x00 -> + Data (address, data) + | 0x01 -> + assert (count = 0); + EndOfFile address + | 0x04 -> + assert (count = 2 && address = 0); + let msb = int_of_char data.[0] and lsb = int_of_char data.[1] in + (* check for possible overflow *) + assert (msb land 0x80 = 0); + ExtendedLinearAddress ((msb lsl 8) lor lsb) + | _ -> assert false + +let parse_file file = + let ic = Lwt_io.open_file ~mode:input file in + let lines = Lwt_io.read_lines ic in + let lines = Lwt_stream.map parse_line lines in + lwt lines = Lwt_stream.get_while (fun _ -> true) lines in + lwt _ = Lwt_io.close ic in + return lines + +let print_record = function + | Data (address, data) -> + Printf.printf "DAT %04x" address; + String.iter (fun c -> Printf.printf " %02x" (int_of_char c)) data; + Printf.printf "\n" + | ExtendedLinearAddress address -> + Printf.printf "ELA %04x\n" address + | EndOfFile address -> + Printf.printf "EOF %04x\n" address + +let validate_and_copy hex addr_base buffer offset length = + assert (offset+length <= String.length buffer); + let min_address = addr_base+offset in + let max_address = min_address+length in + let addr_high = ref 0 in + let execute_record = function + | Data (address, data) -> + assert (address land 0xFFFF = address); + let address = !addr_high lor address in + if address < min_address || address >= max_address then + Printf.eprintf + "0x%04x is outside range, all bytes dropped\n" + address + else begin + let length = + let n = String.length data in + if address+n >= max_address then begin + Printf.eprintf + "some bytes at address 0x%04x are outside range (dropped)\n" + address; + max_address-address + end else n + in + let offset2 = address-addr_base in + String.blit data 0 buffer offset2 length; + end + | ExtendedLinearAddress address -> + assert (address land 0x8000 = 0); + addr_high := address lsl 16 + | EndOfFile address -> + assert (address = 0); + raise Exit + in + try List.iter execute_record hex with Exit -> () diff --git a/info/control/card-tools/hexfile.mli b/info/control/card-tools/hexfile.mli new file mode 100644 index 0000000..932e32e --- /dev/null +++ b/info/control/card-tools/hexfile.mli @@ -0,0 +1,26 @@ +(* + * krobot_hexfile.mli + * ------------------ + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + +type hex_record = + | Data of int * string + | ExtendedLinearAddress of int + | EndOfFile of int + +val parse_file : string -> hex_record list Lwt.t + +val print_record : hex_record -> unit + (** Prints one record on standard output. *) + +val validate_and_copy : hex_record list -> int -> string -> int -> int -> unit + (** [validate_and_copy hex addr_base buffer offset length] copies + the contents of the (parsed) [hex] file to [buffer]. [offset] + and [length] denote the valid range inside [buffer] that can be + written. [addr_base] is the address [buffer] is mapped to on the + microcontroller. Bytes outside the range are ignored (and a + warning is printed on standard error. *) diff --git a/info/control/card-tools/krobot_boardname.mli b/info/control/card-tools/krobot_boardname.mli deleted file mode 100644 index 51dc1b5..0000000 --- a/info/control/card-tools/krobot_boardname.mli +++ /dev/null @@ -1,12 +0,0 @@ -(* - * krobot_boardname.mli - * -------------------- - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - -val get_board_name : string -> string option - (** [get_board_name dump] recherche dans le [dump] mémoire (peut - être également un fichier .hex chargé) le nom de la carte. *) diff --git a/info/control/card-tools/krobot_boardname.mll b/info/control/card-tools/krobot_boardname.mll deleted file mode 100644 index 96b39b6..0000000 --- a/info/control/card-tools/krobot_boardname.mll +++ /dev/null @@ -1,22 +0,0 @@ -(* - * krobot_boardname.mll - * -------------------- - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - - -let boardname_regex = ("Carte " | "Robot Interface" | "Battery Monitoring ") [^'\n']+ - -rule boardname = parse - | (boardname_regex as name) '\n' { Some name } - | _ { boardname lexbuf } - | eof { None } - -{ - let get_board_name str = - let lexbuf = Lexing.from_string str in - boardname lexbuf -} diff --git a/info/control/card-tools/krobot_bootloader.ml b/info/control/card-tools/krobot_bootloader.ml deleted file mode 100644 index 1deb632..0000000 --- a/info/control/card-tools/krobot_bootloader.ml +++ /dev/null @@ -1,184 +0,0 @@ -(* - * krobot_bootloader.ml - * -------------------- - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - -open Lwt -open Lwt_io - -(* Code très inspiré de kard.ml, mais mis à part car le mode de - communication avec la carte est différent (bulk au lieu - d'interrupt). *) - -type t = { - mutable is_open : bool; - (* La carte est-elle ouverte ? *) - - handle : USB.handle; - (* Handle pour le périphérique usb *) - - kernel_active : bool; - (* Est-ce qu'un driver noyau était attaché à la carte avant qu'on - l'utilise ? *) -} - -type error = - | IncompleteWrite of int * int - | IncompleteRead of int * int - | UnexpectedReply of string * string - | WriteError of string * string - -let string_of_error = function - | IncompleteWrite (a, b) -> Printf.sprintf "%d byte(s) written instead of %d" a b - | IncompleteRead (a, b) -> Printf.sprintf "%d byte(s) read instead of %d" a b - | UnexpectedReply (a, b) -> Printf.sprintf "received unexpected reply %S instead of %S" a b - | WriteError (a, b) -> Printf.sprintf "written: %S, read back: %S" a b - -exception Error of error - -let failwith e = fail (Error e) - -let close k = - if k.is_open then begin - lwt _ = USB.release_interface k.handle 0 in - lwt _ = USB.reset_device k.handle in - (*if k.kernel_active then USB.attach_kernel_driver k.handle 0;*) - (*USB.close k.handle;*) - k.is_open <- false; - return () - end else return () - -let open_card () = - let handle = USB.open_device_with - ~vendor_id:PcInterface.usb_vid - ~product_id:PcInterface.usb_pid_bootloader - in - let kernel_active = USB.kernel_driver_active handle 0 in - if kernel_active then USB.detach_kernel_driver handle 0; - lwt _ = USB.set_configuration handle 1 in - lwt _ = USB.claim_interface handle 0 in - let k = { is_open = true; - handle = handle; - kernel_active = kernel_active } in - let _ = Lwt_sequence.add_l (fun _ -> close k) Lwt_main.exit_hooks in - return k - -let header_length = 5 - -let put_message buffer cmd length address data = - let body_length = String.length data in - assert (String.length buffer >= header_length+body_length); - let set i n = buffer.[i] <- char_of_int n in - set 0 cmd; - assert (length < 0x100); - set 1 length; - assert (address <= 0x1000000); - set 2 (address land 0xff); - set 3 ((address lsr 8) land 0xff); - set 4 ((address lsr 16) land 0xff); - String.blit data 0 buffer 5 body_length - -let send_receive_packet k send_buffer send_length receive_buffer receive_length send_delay receive_delay = - let handle = k.handle and endpoint = 1 in - lwt sent = USB.bulk_send ~handle ~endpoint ~timeout:1. send_buffer 0 send_length in - if sent <> send_length then - failwith (IncompleteWrite (sent, send_length)) - else begin - lwt received = USB.bulk_recv ~handle ~endpoint ~timeout:3. receive_buffer 0 receive_length in - if received <> receive_length then - failwith (IncompleteRead (received, receive_length)) - else - return () - end - -let get_flash k ~address ~length = - let response_length = 64 in - let increment = response_length-header_length in - assert (increment < 256); - let send_buffer = String.create header_length in - let receive_buffer = String.create response_length in - let result_buffer = String.create length in - let rec loop offset total_length = - if total_length <= 0 then - return result_buffer - else begin - let length = min increment total_length in - let response_length = length+header_length in - let address = address+offset in - put_message send_buffer PcInterface.read_flash length address ""; - lwt () = send_receive_packet k send_buffer header_length receive_buffer response_length 1. 3. in - let receive_header = String.sub receive_buffer 0 header_length in - if receive_header <> send_buffer then - failwith (UnexpectedReply (receive_header, send_buffer)) - else begin - String.blit receive_buffer header_length result_buffer offset length; - loop (offset+length) (total_length-length); - end - end - in loop 0 length - -let erase_flash k ~address ~length = - let response_length = 1 in - (* les effacements se font par blocs de 64 octets *) - let increment = 64 in - let send_buffer = String.create header_length in - let receive_buffer = String.create response_length in - let rec loop offset total_length = - if total_length <= 0 then - return () - else begin - let address = address+offset in - put_message send_buffer PcInterface.erase_flash 1 address ""; - lwt () = send_receive_packet k send_buffer header_length receive_buffer response_length 1. 5. in - if int_of_char receive_buffer.[0] <> PcInterface.erase_flash then - failwith (UnexpectedReply (receive_buffer, String.make 1 (char_of_int PcInterface.erase_flash))) - else - loop (offset+increment) (total_length-increment); - end - in loop 0 length - -let reference = String.make 16 '\255' - -let write_flash k ~address data offset length = - let send_length = 64 and receive_length = 1 in - (* les écritures se font par blocs de 16 octets *) - let increment = 16 in - let send_buffer = String.create send_length in - let receive_buffer = String.create receive_length in - let rec loop address offset total_length = - (* address: sur le PIC, offset: dans data, total_length: taille restante *) - if total_length <= 0 then - return () - else begin - let packet = String.make increment '\255' in - String.blit data offset packet 0 (min total_length increment); - if packet = reference then begin - (* le paquet n'a pas de contenu, on l'ignore *) - (* lwt () = printf "Skipping address 0x%06X...\n" address in *) - loop (address+increment) (offset+increment) (total_length-increment) - end else begin - (* lwt () = printf "Processing address 0x%06X...\n" address in *) - put_message send_buffer PcInterface.write_flash increment address packet; - lwt () = send_receive_packet k send_buffer send_length receive_buffer receive_length 0.5 1. in - if int_of_char receive_buffer.[0] <> PcInterface.write_flash then - failwith (UnexpectedReply (receive_buffer, String.make 1 (char_of_int PcInterface.erase_flash))) - else begin - lwt written = get_flash k ~address ~length:increment in - if written <> packet then - failwith (WriteError (packet, written)) - else - loop (address+increment) (offset+increment) (total_length-increment) - end - end - end - in loop address offset length - -let reset_board k = - let send_buffer = String.create 64 and receive_buffer = String.create 64 in - send_buffer.[0] <- char_of_int PcInterface.reset; - lwt () = send_receive_packet k send_buffer 1 receive_buffer 64 5. 5. in - return () diff --git a/info/control/card-tools/krobot_dump_memory.ml b/info/control/card-tools/krobot_dump_memory.ml deleted file mode 100644 index 91b80d1..0000000 --- a/info/control/card-tools/krobot_dump_memory.ml +++ /dev/null @@ -1,28 +0,0 @@ -(* - * krobot_dump_memory.ml - * --------------------- - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - -open Printf -open Lwt -open Lwt_io - -lwt () = - lwt k = Krobot_bootloader.open_card () in - try_lwt - lwt data = Krobot_bootloader.get_flash k ~address:0x0 ~length:0x8000 in - let msg = match Krobot_boardname.get_board_name data with - | Some s -> sprintf "Board: %S" s - | None -> "Unable to identify board!" - in - lwt () = eprintlf "%s" msg in - (if Unix.isatty Unix.stdout then hexdump else write) stdout data >> flush stdout - with - | Krobot_bootloader.Error e -> - eprintlf "%s" (Krobot_bootloader.string_of_error e) - | e -> - eprintlf "%s" (Printexc.to_string e) diff --git a/info/control/card-tools/krobot_hexfile.ml b/info/control/card-tools/krobot_hexfile.ml deleted file mode 100644 index 2d2c361..0000000 --- a/info/control/card-tools/krobot_hexfile.ml +++ /dev/null @@ -1,112 +0,0 @@ -(* - * krobot_hexfile.ml - * ----------------- - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - -open Lwt -open Lwt_io - -type hex_record = - | Data of int * string - | ExtendedLinearAddress of int - | EndOfFile of int - -let string_of_hexline str = - let n = String.length str in - assert (n > 0 && n mod 2 = 1 && str.[0] = ':'); - let m = n/2 in - let result = String.create m in - for i = 0 to m-1 do - let j = 2*i+1 in - result.[i] <- char_of_int (int_of_string ("0x"^(String.sub str j 2))) - done; - result - -let compute_checksum str = - let rec aux i accu = - if i < 0 then - (-accu) land 0xff - else - aux (i-1) (accu+(int_of_char str.[i])) - in aux (String.length str - 2) 0 - -let parse_line str = - let str = string_of_hexline str in - let get i = int_of_char str.[i] in - let n = String.length str in - assert (n >= 5 && compute_checksum str = int_of_char str.[n-1]); - let count = get 0 in - assert (count+5 = n); - let address = ((get 1) lsl 8) lor (get 2) in - let record_type = get 3 in - let data = String.sub str 4 count in - match record_type with - | 0x00 -> - Data (address, data) - | 0x01 -> - assert (count = 0); - EndOfFile address - | 0x04 -> - assert (count = 2 && address = 0); - let msb = int_of_char data.[0] and lsb = int_of_char data.[1] in - (* check for possible overflow *) - assert (msb land 0x80 = 0); - ExtendedLinearAddress ((msb lsl 8) lor lsb) - | _ -> assert false - -let parse_file file = - let ic = Lwt_io.open_file ~mode:input file in - let lines = Lwt_io.read_lines ic in - let lines = Lwt_stream.map parse_line lines in - lwt lines = Lwt_stream.get_while (fun _ -> true) lines in - lwt _ = Lwt_io.close ic in - return lines - -let print_record = function - | Data (address, data) -> - Printf.printf "DAT %04x" address; - String.iter (fun c -> Printf.printf " %02x" (int_of_char c)) data; - Printf.printf "\n" - | ExtendedLinearAddress address -> - Printf.printf "ELA %04x\n" address - | EndOfFile address -> - Printf.printf "EOF %04x\n" address - -let validate_and_copy hex addr_base buffer offset length = - assert (offset+length <= String.length buffer); - let min_address = addr_base+offset in - let max_address = min_address+length in - let addr_high = ref 0 in - let execute_record = function - | Data (address, data) -> - assert (address land 0xFFFF = address); - let address = !addr_high lor address in - if address < min_address || address >= max_address then - Printf.eprintf - "0x%04x is outside range, all bytes dropped\n" - address - else begin - let length = - let n = String.length data in - if address+n >= max_address then begin - Printf.eprintf - "some bytes at address 0x%04x are outside range (dropped)\n" - address; - max_address-address - end else n - in - let offset2 = address-addr_base in - String.blit data 0 buffer offset2 length; - end - | ExtendedLinearAddress address -> - assert (address land 0x8000 = 0); - addr_high := address lsl 16 - | EndOfFile address -> - assert (address = 0); - raise Exit - in - try List.iter execute_record hex with Exit -> () diff --git a/info/control/card-tools/krobot_hexfile.mli b/info/control/card-tools/krobot_hexfile.mli deleted file mode 100644 index 932e32e..0000000 --- a/info/control/card-tools/krobot_hexfile.mli +++ /dev/null @@ -1,26 +0,0 @@ -(* - * krobot_hexfile.mli - * ------------------ - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - -type hex_record = - | Data of int * string - | ExtendedLinearAddress of int - | EndOfFile of int - -val parse_file : string -> hex_record list Lwt.t - -val print_record : hex_record -> unit - (** Prints one record on standard output. *) - -val validate_and_copy : hex_record list -> int -> string -> int -> int -> unit - (** [validate_and_copy hex addr_base buffer offset length] copies - the contents of the (parsed) [hex] file to [buffer]. [offset] - and [length] denote the valid range inside [buffer] that can be - written. [addr_base] is the address [buffer] is mapped to on the - microcontroller. Bytes outside the range are ignored (and a - warning is printed on standard error. *) diff --git a/info/control/card-tools/krobot_send_firmware.ml b/info/control/card-tools/krobot_send_firmware.ml deleted file mode 100644 index 82261c5..0000000 --- a/info/control/card-tools/krobot_send_firmware.ml +++ /dev/null @@ -1,69 +0,0 @@ -(* - * krobot_send_firmware.ml - * ----------------------- - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - -open Lwt -open Lwt_io - -let do_flash force filename = - lwt hex = Krobot_hexfile.parse_file filename in - let memory = - let buffer = String.make 0x8000 '\255' in - Krobot_hexfile.validate_and_copy hex 0x0 buffer 0 0x8000; - buffer - in - let firmware_name = Krobot_boardname.get_board_name memory in - lwt () = match firmware_name with - | Some s -> printf "Detected firmware: %S\n" s - | None -> printf "Unable to identify firmware!\n" - in - let address = 0x800 and length = 0x8000-0x800 in - lwt k = Krobot_bootloader.open_card () in - lwt () = printf "Card opened\n" in - lwt data = Krobot_bootloader.get_flash k ~address:0x0 ~length:0x8000 in - let board_name = Krobot_boardname.get_board_name data in - lwt () = match board_name with - | Some s -> printf "Detected card: %S\n" s - | None -> printf "Unable to identify card!\n" - in - lwt () = - if not force && (board_name = None || firmware_name = None || board_name <> firmware_name) then begin - lwt () = eprintf "board name and firmware name do not match, use --force\n" in - exit 1 - end else return () - in - lwt () = Krobot_bootloader.erase_flash k ~address ~length in - lwt () = printf "Flash erased\n" in - lwt () = Krobot_bootloader.write_flash k ~address memory address length in - lwt () = printf "Flashing completed\n" in - lwt () = Krobot_bootloader.reset_board k in - return () - -lwt () = - let force = ref false in - let filename = ref None in - let speclist = [ - "--force", Arg.Set force, "Force flashing even if board id and firmware id do not match"; - ] in - Arg.parse speclist - (fun s -> - match !filename with - | None -> filename := Some s - | Some _ -> raise (Arg.Bad s)) - "Send a firmware to a board in bootloader mode"; - let filename = match !filename with - | None -> Printf.eprintf "You must specify a .hex file!\n"; exit 1 - | Some s -> s - in - try_lwt - do_flash !force filename - with - | Krobot_bootloader.Error e -> - eprintl (Krobot_bootloader.string_of_error e) - | e -> - eprintl (Printexc.to_string e) diff --git a/info/control/card-tools/send_firmware.ml b/info/control/card-tools/send_firmware.ml new file mode 100644 index 0000000..45e7645 --- /dev/null +++ b/info/control/card-tools/send_firmware.ml @@ -0,0 +1,69 @@ +(* + * krobot_send_firmware.ml + * ----------------------- + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + +open Lwt +open Lwt_io + +let do_flash force filename = + lwt hex = Hexfile.parse_file filename in + let memory = + let buffer = String.make 0x8000 '\255' in + Hexfile.validate_and_copy hex 0x0 buffer 0 0x8000; + buffer + in + let firmware_name = Boardname.get_board_name memory in + lwt () = match firmware_name with + | Some s -> printf "Detected firmware: %S\n" s + | None -> printf "Unable to identify firmware!\n" + in + let address = 0x800 and length = 0x8000-0x800 in + lwt k = Bootloader.open_card () in + lwt () = printf "Card opened\n" in + lwt data = Bootloader.get_flash k ~address:0x0 ~length:0x8000 in + let board_name = Boardname.get_board_name data in + lwt () = match board_name with + | Some s -> printf "Detected card: %S\n" s + | None -> printf "Unable to identify card!\n" + in + lwt () = + if not force && (board_name = None || firmware_name = None || board_name <> firmware_name) then begin + lwt () = eprintf "board name and firmware name do not match, use --force\n" in + exit 1 + end else return () + in + lwt () = Bootloader.erase_flash k ~address ~length in + lwt () = printf "Flash erased\n" in + lwt () = Bootloader.write_flash k ~address memory address length in + lwt () = printf "Flashing completed\n" in + lwt () = Bootloader.reset_board k in + return () + +lwt () = + let force = ref false in + let filename = ref None in + let speclist = [ + "--force", Arg.Set force, "Force flashing even if board id and firmware id do not match"; + ] in + Arg.parse speclist + (fun s -> + match !filename with + | None -> filename := Some s + | Some _ -> raise (Arg.Bad s)) + "Send a firmware to a board in Bootloader mode"; + let filename = match !filename with + | None -> Printf.eprintf "You must specify a .hex file!\n"; exit 1 + | Some s -> s + in + try_lwt + do_flash !force filename + with + | Bootloader.Error e -> + eprintl (Bootloader.string_of_error e) + | e -> + eprintl (Printexc.to_string e) diff --git a/info/control/clients/ax12_control.ml b/info/control/clients/ax12_control.ml new file mode 100644 index 0000000..8d7f465 --- /dev/null +++ b/info/control/clients/ax12_control.ml @@ -0,0 +1,83 @@ +(* + * ax12_control.ml + * --------------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(* AX12 interactive controller *) + +open Lwt +open Lwt_io +open Lwt_term + +let render positions selected = + let size = React.S.value Lwt_term.size in + let zone = Zone.make ~width:size.columns ~height:size.lines in + let x = (size.columns / 2) - 7 in + let y = (size.lines / 2) - (Array.length positions / 2) in + for i = 0 to Array.length positions - 1 do + if i = selected then + Draw.textc ~zone ~x ~y:(y + i * 2) + ~text:[inverse; textf "ax12[%d] : %4d" (i + 1) positions.(i)] + else + Draw.textc ~zone ~x ~y:(y + i * 2) + ~text:[textf "ax12[%d] : %4d" (i + 1) positions.(i)] + done; + Lwt_term.render (Zone.points zone) + +lwt () = + lwt krobot = Krobot.create () in + + lwt () = Lwt_log.notice "reading current ax12 positions" in + lwt pos1 = Krobot.unsafe_call Commands.AX12.get_position krobot (1, 100) + and pos2 = Krobot.unsafe_call Commands.AX12.get_position krobot (2, 100) + and pos3 = Krobot.unsafe_call Commands.AX12.get_position krobot (3, 100) in + lwt () = Lwt_log.notice "done" in + + let positions = [|pos1; pos2; pos3|] in + + let rec loop selected = + lwt () = render positions selected in + Lwt_term.read_key () >>= function + | Key_up -> + if selected > 0 then + loop (selected - 1) + else + loop selected + | Key_down -> + if selected < Array.length positions - 1 then + loop (selected + 1) + else + loop selected + | Key_left -> + positions.(selected) <- max 0 (positions.(selected) - 10); + lwt () = Krobot.unsafe_call Commands.AX12.goto krobot (selected + 1, positions.(selected), 50, `Now) in + loop selected + | Key_right -> + positions.(selected) <- min 1023 (positions.(selected) + 10); + lwt () = Krobot.unsafe_call Commands.AX12.goto krobot (selected + 1, positions.(selected), 50, `Now) in + loop selected + | Key ("\027[d" | "\027[1;2D") -> + positions.(selected) <- max 0 (positions.(selected) - 1); + lwt () = Krobot.unsafe_call Commands.AX12.goto krobot (selected + 1, positions.(selected), 50, `Now) in + loop selected + | Key ("\027[c" | "\027[1;2C") -> + positions.(selected) <- min 1023 (positions.(selected) + 1); + lwt () = Krobot.unsafe_call Commands.AX12.goto krobot (selected + 1, positions.(selected), 50, `Now) in + loop selected + | Key_control '[' -> + return () + | _ -> + loop selected + in + + lwt () = Lwt_term.enter_drawing_mode () in + lwt () = Lwt_term.hide_cursor () in + + try_lwt + loop 0 + finally + Lwt_term.leave_drawing_mode () diff --git a/info/control/clients/controller.ml b/info/control/clients/controller.ml new file mode 100644 index 0000000..72c8bbd --- /dev/null +++ b/info/control/clients/controller.ml @@ -0,0 +1,490 @@ +(* + * controller.ml + * ------------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(* Prints status continuously *) + +open Lwt +open Lwt_term +open Lwt_read_line + +module TextSet = Set.Make(Text) + +(* Maximum number of refresh by seconds: *) +let refresh_rate = 10 + +(* +-----------------------------------------------------------------+ + | Logging | + +-----------------------------------------------------------------+ *) + +(* Maximum number of lines to keep in logs: *) +let log_count = 16384 + +(* Signal holding the current logs: *) +let logs, set_logs = React.S.create [] + +let add_date line = + let buffer = Buffer.create 42 in + Lwt_log.render ~buffer ~level:Lwt_log.Info ~message:"" ~template:"$(date): " ~section:Lwt_log.Section.main; + text (Buffer.contents buffer) :: line + +(* Add a list of lines to logs *) +let log_add_lines lines = + let rec truncate n = function + | [] -> + [] + | line :: rest -> + if n = log_count then + [] + else + line :: truncate (n + 1) rest + in + set_logs (truncate 0 (List.rev_map add_date lines @ (React.S.value logs))) + +let log_add_line line = + log_add_lines [line] + +(* Redirect stderr to logs *) +let redirect_stderr () = + let rec copy_logs ic = + lwt line = Lwt_io.read_line ic in + log_add_line [text line]; + copy_logs ic + in + let fdr, fdw = Unix.pipe () in + Unix.dup2 fdw Unix.stderr; + Unix.close fdw; + ignore (copy_logs (Lwt_io.of_unix_fd ~mode:Lwt_io.input fdr)) + +(* Make the default logger to logs into the log buffer *) +let init_logger () = + Lwt_log.default := + Lwt_log.make + ~output:(fun section level lines -> + log_add_lines + (List.map + (fun line -> + if level >= Lwt_log.Warning then + (* Colorize error in red: *) + [fg lred; text line] + else + [text line]) + lines); + return ()) + ~close:return + +(* +-----------------------------------------------------------------+ + | Read-line | + +-----------------------------------------------------------------+ *) + +let engine_state, set_engine_state = React.S.create (Engine.init []) +let box, set_box = React.S.create Terminal.Box_empty + +let () = + Lwt_signal.always_notify + (function + | Engine.Edition(before, after) -> + let comp = Script.complete before after in + set_box (Terminal.Box_words(comp.comp_words, 0)) + | Engine.Selection _ -> + set_box (Terminal.Box_message "<selection>") + | Engine.Search _ -> + set_box (Terminal.Box_message "<backward search>")) + (React.S.map (fun state -> state.Engine.mode) engine_state) + +let history_file_name = + Filename.concat (try Unix.getenv "HOME" with _ -> "") ".krobot-controller-history" + +let save_history history = + Lwt_read_line.save_history history_file_name history + +let rec loop krobot history = + lwt key = read_key () in + if key = key_escape then + save_history history + else + match Command.of_key key with + | Command.Accept_line -> + let line = Text.strip (Engine.all_input (React.S.value engine_state)) in + if line = "exit" then + save_history history + else if line <> "" then begin + let history = Lwt_read_line.add_entry line history in + set_engine_state (Engine.init history); + lwt () = Lwt_log.notice line in + ignore (Script.exec ~krobot ~logger:(fun line -> log_add_line line; return ()) ~command:line); + loop krobot history + end else + loop krobot history + | Command.Complete -> + let engine_state = Engine.reset (React.S.value engine_state) in + let before, after = Engine.edition_state engine_state in + let comp = Script.complete before after in + set_engine_state { engine_state with Engine.mode = Engine.Edition comp.comp_state }; + loop krobot history + | command -> + set_engine_state (Engine.update (React.S.value engine_state) command ()); + loop krobot history + +(* +-----------------------------------------------------------------+ + | Service monitoring | + +-----------------------------------------------------------------+ *) + +let services, set_services = React.S.create ~eq:TextSet.equal TextSet.empty + +let check_services bus = + lwt l = OBus_bus.list_names bus in + set_services (List.fold_left (fun set name -> + if Text.starts_with name "fr.krobot." then + TextSet.add (String.sub name 10 (String.length name - 10)) set + else + set) TextSet.empty l); + return () + +(* +-----------------------------------------------------------------+ + | Drawing | + +-----------------------------------------------------------------+ *) + +(* Draw the whole screen *) +let rec draw krobot = + let size = React.S.value Lwt_term.size in + + let screen = Zone.make ~width:size.columns ~height:size.lines in + let points = Zone.points screen in + + let line_color = lblue in + let line = { blank with style = { blank.style with foreground = line_color } } in + let name_color = lwhite in + + (* ===== Borders ===== *) + + for i = 1 to size.columns - 2 do + points.(0).(i) <- { line with char = "─" }; + points.(size.lines - 1).(i) <- { line with char = "─" } + done; + for i = 1 to size.lines - 2 do + points.(i).(0) <- { line with char = "│" }; + points.(i).(size.columns - 1) <- { line with char = "│" } + done; + points.(0).(0) <- { line with char = "┌" }; + points.(size.lines - 1).(0) <- { line with char = "└" }; + points.(size.lines - 1).(size.columns - 1) <- { line with char = "┘" }; + points.(0).(size.columns - 1) <- { line with char = "┐" }; + + (* ===== Status ===== *) + + Draw.textc screen 1 0 [fg line_color; text "─[ "; + fg name_color; text "Range finders"; + fg line_color; text " ]─┬─[ "; + fg name_color; text "Logic Sensors"; + fg line_color; text " ]─┬─[ "; + fg name_color; text "Services"; + fg line_color; text " ]─┬─[ "; + fg name_color; text "Cards"; + fg line_color; text " ]─┬─[ "; + fg name_color; text "Status"; + fg line_color; text " ]─"]; + points.(9).(0) <- { line with char = "├" }; + points.(9).(size.columns - 1) <- { line with char = "┤" }; + for i = 1 to size.columns - 2 do + points.(9).(i) <- { line with char = "─" } + done; + for i = 1 to 8 do + points.(i).(20) <- { line with char = "│" }; + points.(i).(40) <- { line with char = "│" }; + points.(i).(55) <- { line with char = "│" }; + points.(i).(67) <- { line with char = "│" } + done; + Draw.textc screen 1 9 [fg line_color; text "───────────────────┴───────────────────┴──────────────┴───────────┴"]; + + let zone = Zone.inner screen in + + lwt () = + try_lwt + lwt range_finders = OBus_property.get (Krobot.range_finders krobot) in + for i = 0 to Array.length range_finders - 1 do + Draw.textc zone 0 i [textf "%d : " i; text (Text.repeat (range_finders.(i) * 14 / 3146) "=")] + done; + return () + with exn -> + for i = 0 to 7 do + Draw.textc zone 0 i [fg red; text "error"] + done; + return () + in + + lwt () = + try_lwt + lwt logic_sensors = OBus_property.get (Krobot.logic_sensors krobot) in + for i = 0 to Array.length logic_sensors / 2 - 1 do + let j = i * 2 in + Draw.textf zone 20 i "%02d : %s %02d : %s" + (j + 0) (if logic_sensors.(j + 0) then "O" else ".") + (j + 1) (if logic_sensors.(j + 1) then "O" else ".") + done; + return () + with exn -> + for i = 0 to 7 do + Draw.textc zone 20 i [fg red; text "error"] + done; + return () + in + + let zone' = Zone.sub ~zone ~x:40 ~y:0 ~width:14 ~height:8 in + let rec loop y = function + | [] -> + () + | name :: rest -> + Draw.text ~zone:zone' ~x:0 ~y ~text:name; + loop (y + 1) rest + in + loop 0 (TextSet.elements (React.S.value services)); + + let x = 55 in + let text_of_state name = function + | `Absent -> [fg lred; text name] + | `Present -> [text name] + in + lwt () = + try_lwt + lwt interface_state = OBus_property.get (Krobot.Card.state krobot `Interface) + and sensor_state = OBus_property.get (Krobot.Card.state krobot `Sensor) + and motor_state = OBus_property.get (Krobot.Card.state krobot `Motor) + and monitoring_state = OBus_property.get (Krobot.Card.state krobot `Monitoring) in + Draw.textc zone x 0 (text_of_state "interface" interface_state); + Draw.textc zone x 1 (text_of_state "sensor" sensor_state); + Draw.textc zone x 2 (text_of_state "motor" motor_state); + Draw.textc zone x 3 (text_of_state "monitoring" monitoring_state); + return () + with exn -> + for i = 0 to 3 do + Draw.textc zone x i [fg red; text "error"] + done; + return () + in + let x = x + 12 in + lwt () = + try_lwt + lwt compass = OBus_property.get (Krobot.compass krobot) in + Draw.textf zone x 2 "compass = %d" compass; + return () + with exn -> + Draw.textc zone x 2 [fg red; text "error"]; + return () + in + let date = Unix.gettimeofday () in + let text_of_motor_state mode until = + if date < until then + [text mode; fg lyellow; text "inhibited"] + else + [text mode; text "OK"] + in + lwt () = + try_lwt + lwt forward = OBus_property.get (Krobot.inhibit_forward_until krobot) + and backward = OBus_property.get (Krobot.inhibit_backward_until krobot) in + Draw.textc zone x 3 (text_of_motor_state "move forward: " forward); + Draw.textc zone x 4 (text_of_motor_state "move backward: " backward); + return () + with exn -> + for i = 3 to 4 do + Draw.textc zone x i [fg red; text "error"] + done; + return () + in + + (* ===== History ===== *) + + let zone = Zone.sub ~zone:screen ~x:1 ~y:10 ~width:(Zone.width screen - 2) ~height:(Zone.height screen - 15) in + let rec loop y = function + | [] -> + () + | line :: rest -> + if y < 0 then + () + else begin + Draw.textc zone 0 y line; + loop (y - 1) rest + end + in + loop (Zone.height zone - 1) (React.S.value logs); + + (* ===== Read-line ===== *) + + points.(size.lines - 3).(0) <- { line with char = "├" }; + points.(size.lines - 3).(size.columns - 1) <- { line with char = "┤" }; + points.(size.lines - 5).(0) <- { line with char = "├" }; + points.(size.lines - 5).(size.columns - 1) <- { line with char = "┤" }; + for i = 1 to size.columns - 2 do + points.(size.lines - 5).(i) <- { line with char = "─" }; + points.(size.lines - 3).(i) <- { line with char = "─" } + done; + + let zone = Zone.sub ~zone:screen ~x:1 ~y:(size.lines - 4) ~width:(size.columns - 2) ~height:1 in + let engine_state = React.S.value engine_state in + let cursor_position = + match engine_state.Engine.mode with + | Engine.Edition(before, after) -> + let len = Text.length before in + Draw.textc zone 0 0 [Text before; Text after]; + len + | Engine.Selection state -> + let a = min state.Engine.sel_cursor state.Engine.sel_mark + and b = max state.Engine.sel_cursor state.Engine.sel_mark in + let part_before = Text.chunk (Text.pointer_l state.Engine.sel_text) a + and part_selected = Text.chunk a b + and part_after = Text.chunk (Text.pointer_r state.Engine.sel_text) b in + Draw.textc zone 0 0 [Text part_before; Underlined; Text part_selected; Reset; Text part_after]; + if state.Engine.sel_cursor < state.Engine.sel_mark then + Text.length part_before + else + Text.length part_before + Text.length part_selected + | Engine.Search state -> + let len = Text.length state.Engine.search_word in + Draw.text zone 0 0 (Printf.sprintf "(reverse-i-search)'%s'" state.Engine.search_word); + begin match state.Engine.search_history with + | [] -> + 19 + len + | phrase :: _ -> + let ptr_start = match Text.find phrase state.Engine.search_word with + | Some ptr -> + ptr + | None -> + assert false + in + let ptr_end = Text.move len ptr_start in + let before = Text.chunk (Text.pointer_l phrase) ptr_start + and selected = Text.chunk ptr_start ptr_end + and after = Text.chunk ptr_end (Text.pointer_r phrase) in + Draw.textc zone (20 + len) 0 [ + Text ": "; + Text before; + Underlined; + Text selected; + Reset; + Text after; + ]; + 19 + len + end + in + Draw.map zone cursor_position 0 (fun point -> { point with style = { point.style with inverse = true } }); + + let zone = Zone.sub ~zone:screen ~x:1 ~y:(size.lines - 3) ~width:(size.columns - 2) ~height:3 in + begin + match React.S.value box with + | Terminal.Box_none | Terminal.Box_empty -> + () + | Terminal.Box_message msg -> + Draw.text zone 0 1 msg + | Terminal.Box_words(words, _) -> + ignore (TextSet.fold + (fun word i -> + let len = Text.length word in + Draw.text zone i 1 word; + let i = i + len in + Draw.textc zone i 0 [fg line_color; text "┬"]; + Draw.textc zone i 1 [fg line_color; text "│"]; + Draw.textc zone i 2 [fg line_color; text "┴"]; + i + 1) + words 0) + end; + + Lwt_term.render (Zone.points screen) + +(* Wether the screen need to be refreshed *) +let refresh_needed = ref false + +(* Program a refresh before the next main loop iteration *) +let refresh krobot = + if !refresh_needed then + return () + else begin + refresh_needed := true; + lwt () = Lwt.pause () in + refresh_needed := false; + draw krobot + end + +(* +-----------------------------------------------------------------+ + | Entry point | + +-----------------------------------------------------------------+ *) + +lwt () = + lwt () = Lwt_log.notice "connecting to the krobot bus..." in + lwt krobot = Krobot.create () in + let bus = OBus_peer.connection (Krobot.to_peer krobot) in + + (* Put the terminal into drawing mode: *) + lwt () = Lwt_term.enter_drawing_mode () in + lwt () = Lwt_term.hide_cursor () in + + init_logger (); + redirect_stderr (); + + (* Dump all logs to stdout on abnormal exit: *) + let node = + Lwt_sequence.add_l + (fun () -> + lwt () = Lwt_term.leave_drawing_mode () in + Lwt_list.iter_s printlc (List.rev (React.S.value logs))) + Lwt_main.exit_hooks + in + + (* Service monitoring *) + lwt () = check_services bus in + Lwt_event.always_notify_p (fun _ -> check_services bus) (OBus_signal.event (OBus_bus.name_owner_changed bus)); + + (* Minimum delay to wait between two screen redrawing *) + let delay = 1.0 /. (float_of_int refresh_rate) in + (* Event which refresh the screen when it occurs: *) + let event, push = React.E.create () in + Lwt_event.always_notify_p + (fun () -> refresh krobot) + (* Limit the number of redraw per seconds: *) + (Lwt_event.limit (fun () -> Lwt_unix.sleep delay) event); + (* Ask for a refresh when [signal] changes: *) + let notify signal = Lwt_signal.always_notify (fun _ -> push ()) signal in + notify box; + notify logs; + notify services; + + lwt () = OBus_bus.add_match bus (OBus_match.rule ~typ:`Signal ~member:"ProppertiesChanged" ()) in + let _ = + Lwt_sequence.add_l + (function + | { OBus_message.typ = OBus_message.Signal(_, _, "PropertiesChanged") } as msg -> + push (); + Some msg + | msg -> + Some msg) + (OBus_connection.incoming_filters bus) + in + + List.iter + (fun card -> + Lwt_event.always_notify + (fun error -> log_add_line [fg lred; textf "error on card %s: %s" (Krobot.Card.name card) error]) + (OBus_signal.event (Krobot.Card.errors krobot card))) + [`Interface; `Sensor; `Motor; `Monitoring]; + + (* Redraw immedlatly the screen when [signal] changes: *) + let urgent signal = Lwt_signal.always_notify_p (fun _ -> refresh krobot) signal in + urgent Lwt_term.size; + urgent engine_state; + + lwt history = Lwt_read_line.load_history history_file_name in + set_engine_state (Engine.init history); + + (* User input loop *) + lwt () = Lwt_term.with_raw_mode (fun () -> loop krobot history) in + + (* Normal exit, do not dump logs on stdout: *) + Lwt_sequence.remove node; + + (* Leave drawing mode *) + Lwt_term.leave_drawing_mode () diff --git a/info/control/clients/info.ml b/info/control/clients/info.ml new file mode 100644 index 0000000..f60bb31 --- /dev/null +++ b/info/control/clients/info.ml @@ -0,0 +1,36 @@ +(* + * info.ml + * ------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(* Print cards informations *) + +open Lwt +open Lwt_io + +let print_card krobot card = + OBus_property.get (Krobot.Card.state krobot card) >>= function + | `Present -> + lwt firmware_build = Krobot.Card.get_firmware_build krobot card + and board_info = Krobot.Card.get_board_info krobot card in + let name = Krobot.Card.name card in + lwt () = printl "==========" in + lwt () = printlf "card.%s.state = present" name in + lwt () = printlf "card.%s.firmware_build = %s" name firmware_build in + lwt () = printlf "card.%s.board_info = %s" name board_info in + return () + | `Absent -> + lwt () = printl "==========" in + printlf "card.%s.state = absent" (Krobot.Card.name card) + +lwt () = + lwt krobot = Krobot.create () in + lwt () = print_card krobot `Interface in + lwt () = print_card krobot `Sensor in + lwt () = print_card krobot `Motor in + lwt () = print_card krobot `Monitoring in + return () diff --git a/info/control/clients/init_position.ml b/info/control/clients/init_position.ml new file mode 100644 index 0000000..16aa2e0 --- /dev/null +++ b/info/control/clients/init_position.ml @@ -0,0 +1,41 @@ +(* + * init_position.ml + * ---------------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(* Put the robot into its initial state *) + +open Lwt + +let move_backward_slowly krobot = + lwt () = Lwt_log.notice "moving backward" in + Krobot.move krobot ~distance:(-1000) ~velocity:100 ~acceleration:100 >>= function + ... [truncated message content] |
From: Jérémie D. <Ba...@us...> - 2010-04-21 16:50:29
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 15f2f81f08e1a3684c09b9be858889a925977fb4 (commit) from 0fc3c12e38eba6fab3a467ad96573098b8b88633 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 15f2f81f08e1a3684c09b9be858889a925977fb4 Author: Jeremie Dimino <di...@vo...> Date: Wed Apr 21 18:10:53 2010 +0200 refactoring ----------------------------------------------------------------------- Changes: diff --git a/info/control/Makefile b/info/control/Makefile index fd92830..ab1e117 100644 --- a/info/control/Makefile +++ b/info/control/Makefile @@ -7,7 +7,7 @@ PREFIX := $(HOME) -OC := ocamlbuild -Is common,protocol,lib-krobot +OC := ocamlbuild OF := ocamlfind ifeq ($(TERM),dumb) diff --git a/info/control/_tags b/info/control/_tags index 937c55b..1aaed9b 100644 --- a/info/control/_tags +++ b/info/control/_tags @@ -11,7 +11,7 @@ # | Protocol | # +------------------------------------------------------------------+ -<protocol/krobot_interfaces.*>: pkg_obus +<protocol/*>: pkg_obus # +------------------------------------------------------------------+ # | Card tools | @@ -42,9 +42,7 @@ # | Common | # +------------------------------------------------------------------+ -<common/krobot_{types,util}.{ml,mli}>: syntax_camlp4o, pkg_lwt.syntax -<common/krobot_{types,util}.*>: pkg_obus -<common/var.*>: pkg_react +<common/*>: pkg_react, pkg_obus, syntax_camlp4o, pkg_lwt.syntax # +------------------------------------------------------------------+ # | Driver | diff --git a/info/control/common/PcInterface.h b/info/control/common/PcInterface.h deleted file mode 100644 index d681bb5..0000000 --- a/info/control/common/PcInterface.h +++ /dev/null @@ -1,249 +0,0 @@ -/** - * @file PcInterface.h - * Fichier commun avec le programme hsur la carte m (USB PC). - * Ce fichier dnit de nombreuses constantes utilis pour le protocole - * de communication carte <-> PC. -*/ - -#ifndef PC_INTERFACE_H -#define PC_INTERFACE_H - -#define USB_VID 0x04D8 ///< Vendor ID commun aux diffntes cartes USB -#define USB_PID_USB_DEV_BOARD 0x0001 ///< Product ID de la Carte d'essais -#define USB_PID_PROXIMITY_SENSOR 0x0002 ///< Product ID de la Carte capteurs -#define USB_PID_MOTOR_CONTROLLER 0x0003 ///< Product ID de la Carte d'asservissement -#define USB_PID_ROBOT_INTERFACE 0x0004 ///< Product ID de la Carte d'actionneur -#define USB_PID_BATTERY_MONITORING 0x0005 ///< Product ID de la carte Battery Monitoring -#define USB_PID_BOOTLOADER 0x000b ///< Product ID d'une carte en mode bootloader - -// Protocole USB -typedef struct _UP { - BYTE HSEQ; - BYTE DSEQ; - BYTE CMD; - BYTE ERR; - BYTE RES0; - BYTE RES1; - BYTE RES2; - BYTE RES3; - BYTE DATA[52]; - BYTE RES4; - BYTE RES5; - BYTE RES6; - BYTE RES7; -} UP; - -#define UP_HSEQ 0 ///< Host sequence number -#define UP_DSEQ 1 ///< Device sequence number -#define UP_CMD 2 -#define UP_ERR 3 -#define UP_RES0 4 -#define UP_RES1 5 -#define UP_RES2 6 -#define UP_RES3 7 -#define UP_RES4 60 -#define UP_RES5 61 -#define UP_RES6 62 -#define UP_RES7 63 -#define UP_DATA 8 - -// Commande (premier bit) -#define CMD_RESET 0 ///< Reset du PIC -#define CMD_BOOTLOADER 1 ///< Reset du PIC en mode bootloader -#define CMD_GET 2 ///< Obtenir une information -#define CMD_RESPOND 3 ///< Rnse ne commande -#define CMD_ERR 4 ///< Envoyer une erreur -#define CMD_SEND 5 ///< Envoyer du texte -#define CMD_SET 6 ///< Dnir l't d'un parame -#define CMD_TEST 7 ///< Commande grique pour dencher une action de test -#define CMD_CALIBRATE 8 ///< Lance la calibration d'un tme [Carte capteurs] -#define CMD_AX12 9 -#define CMD_TRAJ 10 ///< Transmet une trajetoire au Krobot -#define CMD_MOTOR 11 ///< Gestion des moteurs -#define CMD_MOTOR_TOR 12 -#define CMD_LCD 13 ///< Commande de l'afficheur LCD - -// CMD_GET arguments -#define GET_RESET_SOURCE 0 ///< Demande au PIC la source du Reset -#define GET_BOARD_INFO 1 ///< Demande au PIC le nom de la carte et l'auteur -#define GET_FIRMWARE_BUILD 2 ///< Demande au PIC la date et l'heure de compilation du firmware -#define GET_PORTS_CONFIG 3 ///< Demande la config TRIS des ports du PIC -#define GET_PORTS_STATE 4 ///< Demande l't des ports du PIC -#define GET_RANGEFINDER_STATE 5 ///< Demande au PIC les mesures des tmes [Carte capteurs] -#define GET_ISENS 6 ///< Demande au PIC les valeurs des courants moteurs mesur [Carte d'asservissement] -#define GET_CURRENT_POS 7 ///< Demande au PIC les positions actuelles des moteurs [Carte d'asservissement] -#define GET_RANGEFINDER_CALIBRATION 8 ///< Demande au PIC les valeurs de calibration des tmes [Carte capteurs] -#define GET_TOR_STATE 9 ///< Demande au PIC l't des capteurs de contact [Carte capteurs] -#define GET_CMP03_DATA 10 ///< Rp les infos du compas ctronique CMP03 -#define GET_CELL_VOLTAGE 11 ///< Tensions des cellules [Battery Monitoring] -#define GET_CURRENT 12 ///< Valeur instantandu courant dtar la batterie [Battery Monitoring] -#define GET_POWER_STATE 13 ///< Etat de l'alimentation de puissance (On/Off) [Battery Monitoring] -#define GET_BATTERY_STATE 14 ///< Etat des batteries (Pleine charge/Charge moyenne/Charge faible) [Battery Monitoring] -#define GET_CURRENT_SPEED 15 ///< Demande au PIC la valeur actuelle d'un moteur [Carte d'asservissement] -#define GET_INTEGRATION_SUM 16 ///< Demande au PIC la valeur actuelle du terme integration de l'asservissement [Carte d'asservissement] - -// CMD_ERR arguments -#define ERR_UNKNOWN_CMD 1 ///< Commande inconnue -#define ERR_UNKNOWN_GET 2 ///< Demande inconnue -#define ERR_UNKNOWN_SET 3 ///< Demande inconnue -#define ERR_INVALID_RESPONSE 4 ///< Rnse invalide -#define ERR_AX12_WRONG_PACKET 5 -#define ERR_AX12_ERROR 6 -#define ERR_AX12_CHKSUM 7 -#define ERR_CMP03_NOT_RESPONDING 8 -#define ERR_ADJD_S371_NOT_RESPONDING 9 -#define ERR_LM_COMMAND_ERROR 10 -#define ERR_LM_POSITION_ERROR 11 -#define ERR_INVALID_AXIS 12 - -// CMD_SET arguments -#define SET_PORTS_CONFIG_INPUTS 0x00 ///< Dnir les entr du PIC -#define SET_PORTS_CONFIG_OUTPUTS 0x01 ///< Dnir les sorties du PIC -#define SET_PORTS_STATE_LOW 0x02 ///< Dnir les sorties 't bas du PIC -#define SET_PORTS_STATE_HIGH 0x03 ///< Dnir les sorties 't haut du PIC -#define SET_SERVO_CONFIG 0x04 ///< Dnir la config des servomoteurs -#define SET_SERVO_STATE 0x05 ///< Dnir l't des servomoteurs - -// CMD_CALIBRATE arguments -#define CAL_START 0x00 -#define CAL_CONTINUE 0x01 -#define CAL_STOP 0x02 -#define CAL_ERROR 0x03 -#define CAL_DONE 0x04 -#define CAL_PLACE_INF 0x05 -#define CAL_PLACE_30 0x06 -#define CAL_PLACE_100 0x07 - -// GET_RESET_SOURCE reponse -#define RESET_SOURCE_POR 0x01 ///< Power-on Reset -#define RESET_SOURCE_RI 0x02 ///< RESET Instruction -#define RESET_SOURCE_BOR 0x03 ///< Brown-out Reset -#define RESET_SOURCE_WDT 0x04 ///< Watchdog Time-out Reset -#define RESET_SOURCE_STKFUL 0x05 ///< Stack Full Reset -#define RESET_SOURCE_STKUNF 0x06 ///< Stack Underflow Reset -#define RESET_SOURCE_MCLR 0x07 ///< Master Clear Reset - -// CMD_AX12 -#define AX12_PING 1 -#define AX12_READ8 2 -#define AX12_READ16 3 -#define AX12_WRITE8 4 -#define AX12_WRITE16 5 -#define AX12_GOTO 6 -#define AX12_GET_POS 7 -#define AX12_GET_SPEED 8 -#define AX12_GET_LOAD 9 -#define AX12_GET_STATS 10 -#define AX12_WRITE_REG8 11 -#define AX12_WRITE_REG16 12 -#define AX12_ACTION 13 -#define AX12_RESET 14 -#define AX12_CONFIG 15 - -#define AX12_EXEC_NOW 0x00 -#define AX12_EXEC_ACTION 0x01 - -// CMD_LCD -#define LCD_CLEAR 0x00 -#define LCD_CURSOR_ON 0x01 -#define LCD_CURSOR_OFF 0x02 -#define LCD_BACKLIGHT_ON 0x03 -#define LCD_BACKLIGHT_OFF 0x04 -#define LCD_GOTO_POS 0x05 -#define LCD_WRITE 0x06 -#define LCD_WRITE_LINE 0x07 - -// CMD_TRAJ -#define TRAJ_INIT 0x00 -#define TRAJ_FORWARD 0x01 -#define TRAJ_BACKWARD 0x02 -#define TRAJ_TR 0x03 -#define TRAJ_TL 0x04 -#define TRAJ_GOTO 0x05 -#define TRAJ_FINISHED 0x06 -#define TRAJ_STOP 0x07 -#define TRAJ_NEW_POSITION 0x08 -#define TRAJ_NEW_VELOCITY 0x09 -#define TRAJ_CHANGE_VELOCITY 0x0A -#define TRAJ_CONFIG 0x0B -#define TRAJ_CONFIG_DEFAULT 0x0C -#define TRAJ_START 0x0D -#define TRAJ_GET_REL_POS 0x0E -#define TRAJ_READ_CONFIG 0x0F -#define TRAJ_TURN 0x10 - -#define TRAJ_NOT_COMPLETED 0x00 -#define TRAJ_COMPLETED 0x01 - -#define TRAJ_STOP_MOTOR_OFF 256 -#define TRAJ_STOP_ABRUPT 512 -#define TRAJ_STOP_SMOOTH 1024 - -// CMD_MOTOR -#define MOTOR_ENABLE 1 -#define MOTOR_DISABLE 2 -#define MOTOR_MOVE 3 - -#define MOTOR_RIGHT 1 ///< Sction du moteur de droite (moteur 1) -#define MOTOR_LEFT 2 ///< Sction du moteur de gauche (moteur 2) -#define MOTOR_BOTH 3 ///< Sction des 2 moteurs simultannt - -// XXX omplr -#define READ_VERSION 0x00 -#define READ_FLASH 0x01 -#define WRITE_FLASH 0x02 -#define ERASE_FLASH 0x03 -#define READ_EEDATA 0x04 -#define WRITE_EEDATA 0x05 -#define READ_CONFIG 0x06 -#define WRITE_CONFIG 0x07 -#define UPDATE_LED 0x32 -#define RESET 0xFF - -#define FLASH_BOOT_START 0x00 -#define FLASH_BOOT_END 0x7FF -#define FLASH_VECTOR_START 0x800 -#define FLASH_VECTOR_END 0x829 -#define FLASH_PAGE_START 0x82A -#define FLASH_PAGE_END 0x7FFF - -#define PORTA_RA0 1 -#define PORTA_RA1 2 -#define PORTA_RA2 4 -#define PORTA_RA3 8 -#define PORTA_RA4 16 -#define PORTA_RA5 32 -#define PORTA_RA6 64 - -#define PORTB_RB0 1 -#define PORTB_RB1 2 -#define PORTB_RB2 4 -#define PORTB_RB3 8 -#define PORTB_RB4 16 -#define PORTB_RB5 32 -#define PORTB_RB6 64 -#define PORTB_RB7 128 - -#define PORTC_RC0 1 -#define PORTC_RC1 2 -#define PORTC_RC2 4 -#define PORTC_RC4 16 -#define PORTC_RC5 32 -#define PORTC_RC6 64 -#define PORTC_RC7 128 - -#define PORTD_RD0 1 -#define PORTD_RD1 2 -#define PORTD_RD2 4 -#define PORTD_RD3 8 -#define PORTD_RD4 16 -#define PORTD_RD5 32 -#define PORTD_RD6 64 -#define PORTD_RD7 128 - -#define PORTE_RE0 1 -#define PORTE_RE1 2 -#define PORTE_RE2 4 -#define PORTE_RE3 8 - -#endif // PC_INTERFACE_H diff --git a/info/control/common/krobot_config.ml b/info/control/common/krobot_config.ml deleted file mode 100644 index f51a703..0000000 --- a/info/control/common/krobot_config.ml +++ /dev/null @@ -1,15 +0,0 @@ -(* - * krobot_config.ml - * ---------------- - * Copyright : (c) 2010, Jeremie Dimino <je...@di...> - * Licence : BSD3 - * - * This file is a part of [kro]bot. - *) - -let back_sensors = [3; 6; 7; 10] -let front_sensors = [0; 1; 2; 4; 5; 8; 9; 11; 12; 13; 14; 15] -let initial_position = 200 -let bus_address = "unix:abstract=krobot" -let update_delay = 0.05 -let reopen_delay = 1.0 diff --git a/info/control/common/krobot_config.mli b/info/control/common/krobot_config.mli deleted file mode 100644 index a582c32..0000000 --- a/info/control/common/krobot_config.mli +++ /dev/null @@ -1,28 +0,0 @@ -(* - * krobot_config.mli - * ----------------- - * Copyright : (c) 2010, Jeremie Dimino <je...@di...> - * Licence : BSD3 - * - * This file is a part of [kro]bot. - *) - -(** Krobot parameters *) - -val front_sensors : int list - (** List of front sensors *) - -val back_sensors : int list - (** List of back sensors *) - -val initial_position : int - (** Position to borders at the beginning of the match *) - -val bus_address : string - (** Default address of the krobot dbus daemon *) - -val update_delay : float - (** Time to wait between updates *) - -val reopen_delay : float - (** Time to wait before retrying to open a card *) diff --git a/info/control/common/krobot_types.ml b/info/control/common/krobot_types.ml deleted file mode 100644 index 4d3215c..0000000 --- a/info/control/common/krobot_types.ml +++ /dev/null @@ -1,108 +0,0 @@ -(* - * krobot_types.ml - * --------------- - * Copyright : (c) 2010, Jeremie Dimino <je...@di...> - * Licence : BSD3 - * - * This file is a part of [kro]bot. - *) - -(* Note: integers value must be taken from PcInterface.h *) - -let make_map l = - ((fun x -> - let rec loop = function - | [] -> failwith "Krobot_types: invalid value" - | (x', y) :: _ when x = x' -> y - | _ :: l -> loop l - in - loop l), - (fun y -> - let rec loop = function - | [] -> failwith "Krobot_types: invalid value" - | (x, y') :: _ when y = y' -> x - | _ :: l -> loop l - in - loop l)) - -type move_result = [ `OK | `Stopped ] - -let int32_of_move_result, move_result_of_int32 = - make_map [ - `OK, 0l; - `Stopped, 1l; - ] - -type motor = [ `Left | `Right | `Both ] - -let int32_of_motor, motor_of_int32 = - make_map [ - `Left, Int32.of_int PcInterface.motor_left; - `Both, Int32.of_int PcInterface.motor_both; - `Right, Int32.of_int PcInterface.motor_right - ] - -type stop_mode = [ `Off | `Abrupt | `Smooth ] - -let int32_of_stop_mode, stop_mode_of_int32 = - make_map [ - `Off, Int32.of_int PcInterface.traj_stop_motor_off; - `Abrupt, Int32.of_int PcInterface.traj_stop_abrupt; - `Smooth, Int32.of_int PcInterface.traj_stop_smooth; - ] - -type card_state = [ `Present | `Absent ] - -let int32_of_card_state, card_state_of_int32 = - make_map [ - `Present, 0l; - `Absent, 1l; - ] - -type goto_mode = [ `Straight | `Curve_right | `Curve_left ] - -let int32_of_goto_mode, goto_mode_of_int32 = - make_map [ - `Straight, 0l; - `Curve_right, 1l; - `Curve_left, 2l; - ] - -type ax12_stats = { - ax12_position : int; - ax12_velocity : int; - ax12_torque : int; - ax12_voltage : int; - ax12_temperature : int; - ax12_cw_angle_limit : int; - ax12_ccw_angle_limit : int; -} - -type exec_mode = [ `Now | `Action ] - -let int32_of_exec_mode, exec_mode_of_int32 = - make_map [ - `Now, Int32.of_int PcInterface.ax12_exec_now; - `Action, Int32.of_int PcInterface.ax12_exec_action; - ] - -type direction = [ `Forward | `Backward ] - -let int32_of_direction, direction_of_int32 = - make_map [ - `Forward, 1l; - `Backward, -1l; - ] - -type ax12_action = { - aa_id : int; - aa_position : int; - aa_velocity : int; -} - -type motor_config = { - motor_kp : int; - motor_ki : int; - motor_kd : int; - motor_li : int; -} diff --git a/info/control/common/krobot_types.mli b/info/control/common/krobot_types.mli deleted file mode 100644 index 3bc674f..0000000 --- a/info/control/common/krobot_types.mli +++ /dev/null @@ -1,80 +0,0 @@ -(* - * krobot_types.mli - * ---------------- - * Copyright : (c) 2010, Jeremie Dimino <je...@di...> - * Licence : BSD3 - * - * This file is a part of [kro]bot. - *) - -(** Common types *) - -(** This types are used by the driver and the client-side krobot - library. *) - -type move_result = [ `OK | `Stopped ] - (** Result of a movement started by [Krobot.move] or - [Krobot.turn] *) - -val int32_of_move_result : move_result -> int32 -val move_result_of_int32 : int32 -> move_result - -type motor = [ `Left | `Right | `Both ] - (** Motors *) - -val int32_of_motor : motor -> int32 -val motor_of_int32 : int32 -> motor - -type stop_mode = [ `Off | `Abrupt | `Smooth ] - (** Mode for stopping motors *) - -val int32_of_stop_mode : stop_mode -> int32 -val stop_mode_of_int32 : int32 -> stop_mode - -type direction = [ `Forward | `Backward ] - -val int32_of_direction : direction -> int32 -val direction_of_int32 : int32 -> direction - -type card_state = [ `Present | `Absent ] - (** State of a card *) - -val int32_of_card_state : card_state -> int32 -val card_state_of_int32 : int32 -> card_state - -type goto_mode = [ `Straight | `Curve_right | `Curve_left ] - (** Form of the trajectory for the goto command *) - -val int32_of_goto_mode : goto_mode -> int32 -val goto_mode_of_int32 : int32 -> goto_mode - -type exec_mode = [ `Now | `Action ] - (** Mode of execution of the goto command for ax12 *) - -val int32_of_exec_mode : exec_mode -> int32 -val exec_mode_of_int32 : int32 -> exec_mode - -type ax12_stats = { - ax12_position : int; - ax12_velocity : int; - ax12_torque : int; - ax12_voltage : int; - ax12_temperature : int; - ax12_cw_angle_limit : int; - ax12_ccw_angle_limit : int; -} - -(** Action on an AX12: *) -type ax12_action = { - aa_id : int; - aa_position : int; - aa_velocity : int; -} - -(** Motor configuration *) -type motor_config = { - motor_kp : int; - motor_ki : int; - motor_kd : int; - motor_li : int; -} diff --git a/info/control/common/krobot_util.ml b/info/control/common/krobot_util.ml deleted file mode 100644 index 382a8c4..0000000 --- a/info/control/common/krobot_util.ml +++ /dev/null @@ -1,46 +0,0 @@ -(* - * krobot_util.ml - * -------------- - * Copyright : (c) 2010, Jeremie Dimino <je...@di...> - * Licence : BSD3 - * - * This file is a part of [kro]bot. - *) - -open Lwt - -let front_collide sensors = - if Array.length sensors <> 16 then invalid_arg "Until.front_collide"; - let rec loop = function - | 16 -> false - | n -> (sensors.(n) && List.mem n Krobot_config.front_sensors) || loop (n + 1) - in - loop 0 - -let back_collide sensors = - if Array.length sensors <> 16 then invalid_arg "Until.back_collide"; - let rec loop = function - | 16 -> false - | n -> (sensors.(n) && List.mem n Krobot_config.back_sensors) || loop (n + 1) - in - loop 0 - -let unexpected_reply name reply = - lwt () = Lwt_log.log_f ~level:Lwt_log.Fatal "unexpected reply for request_name(%S): %s" name reply in - exit 1 - -let single_instance bus name = - Lwt_event.always_notify_p - (fun name -> - lwt () = Lwt_log.log ~level:Lwt_log.Notice "service restarted, exiting" in - exit 0) - (React.E.filter ((=) name) (OBus_signal.event (OBus_bus.name_lost bus))); - OBus_bus.request_name bus ~allow_replacement:true ~replace_existing:true name >>= function - | `Primary_owner -> - return () - | `In_queue -> - unexpected_reply name "in-queue" - | `Exists -> - unexpected_reply name "exists" - | `Already_owner -> - unexpected_reply name "already-owner" diff --git a/info/control/common/krobot_util.mli b/info/control/common/krobot_util.mli deleted file mode 100644 index 3bcdbc9..0000000 --- a/info/control/common/krobot_util.mli +++ /dev/null @@ -1,24 +0,0 @@ -(* - * krobot_util.mli - * --------------- - * Copyright : (c) 2010, Jeremie Dimino <je...@di...> - * Licence : BSD3 - * - * This file is a part of [kro]bot. - *) - -(** Utilities *) - -val front_collide : bool array -> bool - (** [front_collide sensors] returns whether on of the front sensors - is activated *) - -val back_collide : bool array -> bool - (** [front_collide sensors] returns whether on of the back sensors is - activated *) - -val single_instance : OBus_bus.t -> OBus_name.bus -> unit Lwt.t - (** [single_instance bus name] requests the bus name [name], and - exit the program when this name is lost. This permit to easily - restart the service and ensures that there is only one running - instance. *) diff --git a/info/control/common/types.ml b/info/control/common/types.ml new file mode 100644 index 0000000..66845ed --- /dev/null +++ b/info/control/common/types.ml @@ -0,0 +1,108 @@ +(* + * types.ml + * -------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(* Note: integers value must be taken from PcInterface.h *) + +let make_map l = + ((fun x -> + let rec loop = function + | [] -> failwith "Krobot_types: invalid value" + | (x', y) :: _ when x = x' -> y + | _ :: l -> loop l + in + loop l), + (fun y -> + let rec loop = function + | [] -> failwith "Krobot_types: invalid value" + | (x, y') :: _ when y = y' -> x + | _ :: l -> loop l + in + loop l)) + +type move_result = [ `OK | `Stopped ] + +let int32_of_move_result, move_result_of_int32 = + make_map [ + `OK, 0l; + `Stopped, 1l; + ] + +type motor = [ `Left | `Right | `Both ] + +let int32_of_motor, motor_of_int32 = + make_map [ + `Left, Int32.of_int PcInterface.motor_left; + `Both, Int32.of_int PcInterface.motor_both; + `Right, Int32.of_int PcInterface.motor_right + ] + +type stop_mode = [ `Off | `Abrupt | `Smooth ] + +let int32_of_stop_mode, stop_mode_of_int32 = + make_map [ + `Off, Int32.of_int PcInterface.traj_stop_motor_off; + `Abrupt, Int32.of_int PcInterface.traj_stop_abrupt; + `Smooth, Int32.of_int PcInterface.traj_stop_smooth; + ] + +type card_state = [ `Present | `Absent ] + +let int32_of_card_state, card_state_of_int32 = + make_map [ + `Present, 0l; + `Absent, 1l; + ] + +type goto_mode = [ `Straight | `Curve_right | `Curve_left ] + +let int32_of_goto_mode, goto_mode_of_int32 = + make_map [ + `Straight, 0l; + `Curve_right, 1l; + `Curve_left, 2l; + ] + +type ax12_stats = { + ax12_position : int; + ax12_velocity : int; + ax12_torque : int; + ax12_voltage : int; + ax12_temperature : int; + ax12_cw_angle_limit : int; + ax12_ccw_angle_limit : int; +} + +type exec_mode = [ `Now | `Action ] + +let int32_of_exec_mode, exec_mode_of_int32 = + make_map [ + `Now, Int32.of_int PcInterface.ax12_exec_now; + `Action, Int32.of_int PcInterface.ax12_exec_action; + ] + +type direction = [ `Forward | `Backward ] + +let int32_of_direction, direction_of_int32 = + make_map [ + `Forward, 1l; + `Backward, -1l; + ] + +type ax12_action = { + aa_id : int; + aa_position : int; + aa_velocity : int; +} + +type motor_config = { + motor_kp : int; + motor_ki : int; + motor_kd : int; + motor_li : int; +} diff --git a/info/control/common/types.mli b/info/control/common/types.mli new file mode 100644 index 0000000..eba0912 --- /dev/null +++ b/info/control/common/types.mli @@ -0,0 +1,80 @@ +(* + * types.mli + * --------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(** Common types *) + +(** This types are used by the driver and the client-side krobot + library. *) + +type move_result = [ `OK | `Stopped ] + (** Result of a movement started by [Krobot.move] or + [Krobot.turn] *) + +val int32_of_move_result : move_result -> int32 +val move_result_of_int32 : int32 -> move_result + +type motor = [ `Left | `Right | `Both ] + (** Motors *) + +val int32_of_motor : motor -> int32 +val motor_of_int32 : int32 -> motor + +type stop_mode = [ `Off | `Abrupt | `Smooth ] + (** Mode for stopping motors *) + +val int32_of_stop_mode : stop_mode -> int32 +val stop_mode_of_int32 : int32 -> stop_mode + +type direction = [ `Forward | `Backward ] + +val int32_of_direction : direction -> int32 +val direction_of_int32 : int32 -> direction + +type card_state = [ `Present | `Absent ] + (** State of a card *) + +val int32_of_card_state : card_state -> int32 +val card_state_of_int32 : int32 -> card_state + +type goto_mode = [ `Straight | `Curve_right | `Curve_left ] + (** Form of the trajectory for the goto command *) + +val int32_of_goto_mode : goto_mode -> int32 +val goto_mode_of_int32 : int32 -> goto_mode + +type exec_mode = [ `Now | `Action ] + (** Mode of execution of the goto command for ax12 *) + +val int32_of_exec_mode : exec_mode -> int32 +val exec_mode_of_int32 : int32 -> exec_mode + +type ax12_stats = { + ax12_position : int; + ax12_velocity : int; + ax12_torque : int; + ax12_voltage : int; + ax12_temperature : int; + ax12_cw_angle_limit : int; + ax12_ccw_angle_limit : int; +} + +(** Action on an AX12: *) +type ax12_action = { + aa_id : int; + aa_position : int; + aa_velocity : int; +} + +(** Motor configuration *) +type motor_config = { + motor_kp : int; + motor_ki : int; + motor_kd : int; + motor_li : int; +} diff --git a/info/control/common/util.ml b/info/control/common/util.ml new file mode 100644 index 0000000..d6e90ec --- /dev/null +++ b/info/control/common/util.ml @@ -0,0 +1,46 @@ +(* + * util.ml + * ------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +open Lwt + +let front_collide sensors = + if Array.length sensors <> 16 then invalid_arg "Until.front_collide"; + let rec loop = function + | 16 -> false + | n -> (sensors.(n) && List.mem n Config.front_sensors) || loop (n + 1) + in + loop 0 + +let back_collide sensors = + if Array.length sensors <> 16 then invalid_arg "Until.back_collide"; + let rec loop = function + | 16 -> false + | n -> (sensors.(n) && List.mem n Config.back_sensors) || loop (n + 1) + in + loop 0 + +let unexpected_reply name reply = + lwt () = Lwt_log.log_f ~level:Lwt_log.Fatal "unexpected reply for request_name(%S): %s" name reply in + exit 1 + +let single_instance bus name = + Lwt_event.always_notify_p + (fun name -> + lwt () = Lwt_log.log ~level:Lwt_log.Notice "service restarted, exiting" in + exit 0) + (React.E.filter ((=) name) (OBus_signal.event (OBus_bus.name_lost bus))); + OBus_bus.request_name bus ~allow_replacement:true ~replace_existing:true name >>= function + | `Primary_owner -> + return () + | `In_queue -> + unexpected_reply name "in-queue" + | `Exists -> + unexpected_reply name "exists" + | `Already_owner -> + unexpected_reply name "already-owner" diff --git a/info/control/common/util.mli b/info/control/common/util.mli new file mode 100644 index 0000000..36ad923 --- /dev/null +++ b/info/control/common/util.mli @@ -0,0 +1,24 @@ +(* + * util.mli + * -------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(** Utilities *) + +val front_collide : bool array -> bool + (** [front_collide sensors] returns whether on of the front sensors + is activated *) + +val back_collide : bool array -> bool + (** [front_collide sensors] returns whether on of the back sensors is + activated *) + +val single_instance : OBus_bus.t -> OBus_name.bus -> unit Lwt.t + (** [single_instance bus name] requests the bus name [name], and + exit the program when this name is lost. This permit to easily + restart the service and ensures that there is only one running + instance. *) diff --git a/info/control/config.ml b/info/control/config.ml new file mode 100644 index 0000000..c248d6e --- /dev/null +++ b/info/control/config.ml @@ -0,0 +1,15 @@ +(* + * config.ml + * --------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +let back_sensors = [3; 6; 7; 10] +let front_sensors = [0; 1; 2; 4; 5; 8; 9; 11; 12; 13; 14; 15] +let initial_position = 200 +let bus_address = "unix:abstract=krobot" +let update_delay = 0.05 +let reopen_delay = 1.0 diff --git a/info/control/config.mli b/info/control/config.mli new file mode 100644 index 0000000..645ac10 --- /dev/null +++ b/info/control/config.mli @@ -0,0 +1,28 @@ +(* + * config.mli + * ---------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(** Krobot parameters *) + +val front_sensors : int list + (** List of front sensors *) + +val back_sensors : int list + (** List of back sensors *) + +val initial_position : int + (** Position to borders at the beginning of the match *) + +val bus_address : string + (** Default address of the krobot dbus daemon *) + +val update_delay : float + (** Time to wait between updates *) + +val reopen_delay : float + (** Time to wait before retrying to open a card *) diff --git a/info/control/driver/USBCard.ml b/info/control/driver/USBCard.ml new file mode 100644 index 0000000..06098d8 --- /dev/null +++ b/info/control/driver/USBCard.ml @@ -0,0 +1,503 @@ +(* + * USBCard.ml + * ---------- + * Copyright : (c) 2009-2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +let section = Lwt_log.Section.make "card" + +open Lwt + +let error_messages = [ + PcInterface.err_unknown_cmd, "unknown command"; + PcInterface.err_unknown_get, "unknown get request"; + PcInterface.err_unknown_set, "unknown set request"; + PcInterface.err_invalid_response, "invalid response"; + PcInterface.err_ax12_wrong_packet, "invalid AX12 packet"; + PcInterface.err_ax12_error, "AX12 error"; + PcInterface.err_ax12_chksum, "invalid checksum of AX12 packet"; + PcInterface.err_cmp03_not_responding, "cmp03 not responding"; + PcInterface.err_adjd_s371_not_responding, "adjd_s371 not responding"; + PcInterface.err_lm_command_error, "lm command error"; + PcInterface.err_lm_position_error, "lm position error"; + PcInterface.err_invalid_axis, "invalid axis"; +] + +let error_message error = + try + List.assoc error error_messages + with Not_found -> + Printf.sprintf "unknown error (%d)" error + +exception Error of string + +(* +-----------------------------------------------------------------+ + | Serialization | + +-----------------------------------------------------------------+ *) + +type pointer = { + mutable offset : int; + buffer : string; +} + +let get_uint8 pointer = + let offset = pointer.offset in + pointer.offset <- offset + 1; + Char.code pointer.buffer.[offset] +let put_uint8 pointer value = + let offset = pointer.offset in + pointer.offset <- offset + 1; + pointer.buffer.[offset] <- Char.unsafe_chr value +let get_sint8 = get_uint8 +let put_sint8 = put_uint8 + +let get_sint16 pointer = + let v0 = get_uint8 pointer in + let v1 = get_uint8 pointer in + (v0 lsl 8) lor v1 +let get_uint16 = get_sint16 + +let put_sint16 pointer value = + put_uint8 pointer ((value lsr 8) land 0xff); + put_uint8 pointer (value land 0xff) +let put_uint16 = put_sint16 + +let get_sint32 pointer = + let v0 = get_uint8 pointer in + let v1 = get_uint8 pointer in + let v2 = get_uint8 pointer in + let v3 = get_uint8 pointer in + (v0 lsl 24) lor (v1 lsl 16) lor (v2 lsl 8) lor v3 +let get_uint32 = get_sint32 + +let put_sint32 pointer value = + put_uint8 pointer ((value lsr 24) land 0xff); + put_uint8 pointer ((value lsr 16) land 0xff); + put_uint8 pointer ((value lsr 8) land 0xff); + put_uint8 pointer (value land 0xff) +let put_uint32 = put_sint32 + +let get_string pointer = + let index = + try + String.index_from pointer.buffer pointer.offset '\000' + with Not_found -> + String.length pointer.buffer + in + let offset = pointer.offset in + pointer.offset <- index + 1; + String.sub pointer.buffer offset (index - offset) + +let put_string pointer value = + let len = String.length value in + if len > String.length pointer.buffer - pointer.offset then + invalid_arg "RW.put_string: string too long" + else begin + String.blit value 0 pointer.buffer pointer.offset len; + let offset = pointer.offset + len in + if offset < String.length pointer.buffer then begin + pointer.buffer.[offset] <- '\x00'; + pointer.offset <- offset + 1 + end else + pointer.offset <- offset + end + +open Value + +let rec put_single ptr = function + | V.Int(Sint8, x) -> put_sint8 ptr x + | V.Int(Uint8, x) -> put_uint8 ptr x + | V.Int(Sint16, x) -> put_sint16 ptr x + | V.Int(Uint16, x) -> put_uint16 ptr x + | V.Int(Sint32, x) -> put_sint32 ptr x + | V.Int(Uint32, x) -> put_uint32 ptr x + | V.Boolean true -> put_uint8 ptr 1 + | V.Boolean false -> put_uint8 ptr 0 + | V.String str -> put_string ptr str + | V.Array a -> Array.iter (put_single ptr) a + +let put_sequence ptr l = + List.iter (put_single ptr) l + +let rec get_single ptr = function + | T.Int Sint8 | T.Enum(Sint8, _) | T.Bit_mask(Sint8, _) -> V.Int(Sint8, get_sint8 ptr) + | T.Int Uint8 | T.Enum(Uint8, _) | T.Bit_mask(Uint8, _) -> V.Int(Uint8, get_uint8 ptr) + | T.Int Sint16 | T.Enum(Sint16, _) | T.Bit_mask(Sint16, _) -> V.Int(Sint16, get_sint16 ptr) + | T.Int Uint16 | T.Enum(Uint16, _) | T.Bit_mask(Uint16, _) -> V.Int(Uint16, get_uint16 ptr) + | T.Int Sint32 | T.Enum(Sint32, _) | T.Bit_mask(Sint32, _) -> V.Int(Sint32, get_sint32 ptr) + | T.Int Uint32 | T.Enum(Uint32, _) | T.Bit_mask(Uint32, _) -> V.Int(Uint32, get_uint32 ptr) + | T.Boolean -> V.Boolean(get_uint8 ptr <> 0) + | T.String -> V.String(get_string ptr) + | T.Array(size, typ) -> V.Array(Array.init size (fun _ -> get_single ptr typ)) + +let rec get_sequence ptr = function + | [] -> [] + | t :: l -> get_single ptr t :: get_sequence ptr l + +(* +-----------------------------------------------------------------+ + | Messages | + +-----------------------------------------------------------------+ *) + +let data_length = 52 + (* Taille en octet du corps d'un message *) + +type serial = int + (* Type d'un numéro de série d'un message *) + +type message = { + host_serial : serial; + (* Le numéro de série du message, émis par l'ordinateur. Vaut 0 pour + les messages émis par le PIC. *) + + device_serial : serial; + (* Le numéro de série du message, émis par le PIC. Vaut 0 pour les + messages émis par l'ordinateur. *) + + command : int; + (* La commande, en fait c'est plutôt le type du message *) + + error : int; + (* Si c'est un message d'erreur ce flag est non-nul *) + + data : string; + (* Les données du messages, il y a 52 octets. *) +} + +let make_buffer () = String.make data_length '\000' + +(* Parse un message depuis un buffer brut: *) +let parse_message buf = { + host_serial = Char.code buf.[PcInterface.up_hseq]; + device_serial = Char.code buf.[PcInterface.up_dseq]; + command = Char.code buf.[PcInterface.up_cmd]; + error = Char.code buf.[PcInterface.up_err]; + data = String.sub buf PcInterface.up_data 52; +} + +(* Créé un buffer brut depuis un message: *) +let forge_message msg = + let buf = String.make 64 '\000' in + buf.[PcInterface.up_hseq] <- Char.chr msg.host_serial; + buf.[PcInterface.up_dseq] <- Char.chr msg.device_serial; + buf.[PcInterface.up_cmd] <- Char.chr msg.command; + buf.[PcInterface.up_err] <- Char.chr msg.error; + if String.length msg.data > 52 then + Printf.ksprintf invalid_arg "message body too big: %d > 52" (String.length msg.data) + else begin + String.blit msg.data 0 buf PcInterface.up_data (String.length msg.data); + buf + end + +(* +-----------------------------------------------------------------+ + | Definitions | + +-----------------------------------------------------------------+ *) + +exception Card_closed +exception Card_crashed of string + +module Int_map = Map.Make(struct type t = int let compare = compare end) + +(* Type of a up and running card *) +type card = { + mutable serial_pool : serial list; + (* Pool de serial disponibles, comme il n'y a que 256 serial + disponibles on évite de juste incrémenter un compteur au pif. *) + + mutable reply_waiters : string Lwt.u Int_map.t; + (* Threads en attente d'une réponse *) + + handle : USB.handle; + (* Handle pour le périphérique usb *) + + kernel_active : bool; + (* Est-ce qu'un driver noyau était attaché à la carte avant qu'on + l'utilise ? *) + + mutex : Lwt_mutex.t; + (* Mutex pour envoyer des commandes, les cartes n'aiment pas les + appels parallèles. *) + + abort_waiter : int Lwt.t; + abort_wakener : int Lwt.u; + (* Sleeping thread which is wakeup when the card is closed *) + + errors : string React.event; + push_error : string -> unit; + + commands : (int * string) React.event; + push_command : int * string -> unit; + + wrapper : wrapper; + (* The associated wrapper *) +} + +and state = + | Opened of card + | Closed of exn + +and wrapper = { + mutable state : state; + name : string; + watch : [ `Error of exn | `Closed ] Lwt.t; +} + +type t = wrapper + +let name wrapper = wrapper.name +let closed wrapper = match wrapper.state with + | Opened _ -> false + | Closed _ -> true + +let watch wrapper = wrapper.watch + +(* Return a running card, if possible. *) +let get_card wrapper = match wrapper.state with + | Opened card -> + return card + | Closed exn -> + fail exn + +let errors wrapper = match wrapper.state with + | Opened card -> card.errors + | Closed exn -> raise exn + +let commands wrapper = match wrapper.state with + | Opened card -> card.commands + | Closed exn -> raise exn + +(* +-----------------------------------------------------------------+ + | Aborting | + +-----------------------------------------------------------------+ *) + +let abort wrapper exn = + match wrapper.state with + | Closed exn -> + return exn + | Opened card -> + wrapper.state <- Closed exn; + try_lwt + lwt () = USB.release_interface card.handle 0 in + if card.kernel_active then USB.attach_kernel_driver card.handle 0; + USB.close card.handle; + return exn + finally + wakeup_exn card.abort_wakener exn; + Int_map.iter (fun serial w -> wakeup_exn w exn) card.reply_waiters; + return () + +(* +-----------------------------------------------------------------+ + | Dispatching | + +-----------------------------------------------------------------+ *) + +let dropped typ card msg = + lwt () = Lwt_log.warning_f ~section "%s dropped on card %s" typ card.wrapper.name in + lwt () = Lwt_log.warning_f ~section "===== +host_serial = %d +device_serial = %d +command = %d +error = %s +data:" msg.host_serial msg.device_serial msg.command (if msg.error <> 0 then error_message msg.error else "none") in + Lwt_stream.iter_s (fun line -> Lwt_log.warning ~section line) (Lwt_stream.hexdump (Lwt_stream.of_string msg.data)) + +(* Dispatch incomming messages continously *) +let rec dispatch card = + let buffer = String.create 64 in + begin + try_lwt + pick [card.abort_waiter; + USB.interrupt_recv + ~handle:card.handle + ~endpoint:1 + buffer 0 64] >|= fun len -> `OK len + with exn -> + return (`Error exn) + end >>= function + | `Error exn -> + lwt () = Lwt_log.error_f ~section ~exn "stop dispatching on %s card" card.wrapper.name in + lwt _ = abort card.wrapper exn in + return () + | `OK len -> + if len <> 64 then begin + let msg = Printf.sprintf "read on %s card returned %d instead of 64" card.wrapper.name len in + lwt () = Lwt_log.error ~section msg in + lwt _ = abort card.wrapper (Card_crashed msg) in + return () + end else begin + let msg = parse_message buffer in + if msg.error <> 0 then begin + if msg.command = PcInterface.cmd_respond then + card.push_error ("response: " ^ error_message msg.error) + else + card.push_error ("spontaneous: " ^ error_message msg.error) + end; + if msg.command = PcInterface.cmd_respond then begin + match try Some(Int_map.find msg.host_serial card.reply_waiters) with Not_found -> None with + | Some wakener -> + card.reply_waiters <- Int_map.remove msg.host_serial card.reply_waiters; + card.serial_pool <- card.serial_pool @ [msg.host_serial]; + if msg.error <> 0 then + Lwt.wakeup_exn wakener (Error(error_message msg.error)) + else + Lwt.wakeup wakener msg.data + | None -> + ignore (dropped "response" card msg) + end else begin + try + card.push_command (msg.command, msg.data) + with exn -> + ignore (Lwt_log.error_f ~section ~exn "pushing event %d from %s card failed with" msg.command card.wrapper.name) + end; + dispatch card + end + +(* +-----------------------------------------------------------------+ + | Opening and closing | + +-----------------------------------------------------------------+ *) + +let close wrapper = match wrapper.state with + | Opened _ -> + lwt _ = abort wrapper Card_closed in + return () + | Closed _ -> + return () + +let rec make ~name ~handle = + lwt () = USB.reset_device handle in + let kernel_active = USB.kernel_driver_active handle 0 in + if kernel_active then USB.detach_kernel_driver handle 0; + lwt () = USB.set_configuration handle 1 in + lwt () = USB.claim_interface handle 0 in + let abort_waiter, abort_wakener = wait () in + let errors, push_error = React.E.create () in + let commands, push_command = React.E.create () in + let rec card = { + serial_pool = (let rec loop = function + | 256 -> [] + | n -> n :: loop (n + 1) + in + loop 1); + reply_waiters = Int_map.empty; + handle = handle; + kernel_active = kernel_active; + mutex = Lwt_mutex.create (); + abort_waiter = abort_waiter; + abort_wakener = abort_wakener; + wrapper = wrapper; + errors = errors; + push_error = push_error; + commands = commands; + push_command = push_command; + } and wrapper = { + state = Opened card; + name = name; + watch = (try_lwt + lwt _ = abort_waiter in + (* Never happen: *) + return `Closed + with + | Card_closed -> + return `Closed + | exn -> + return (`Error exn)) + } in + ignore (dispatch card); + return wrapper + +(* +-----------------------------------------------------------------+ + | Sending/receiving messages | + +-----------------------------------------------------------------+ *) + +let send card buffer = + lwt len = pick [card.abort_waiter; USB.interrupt_send ~handle:card.handle ~endpoint:1 buffer 0 64] in + if len <> 64 then begin + let msg = Printf.sprintf "write on %s card returned %d instead of 64" card.wrapper.name len in + lwt () = Lwt_log.error ~section msg in + fail =<< abort card.wrapper (Card_crashed msg) + end else + return () + +(* Send a command without waiting for the reply: *) +let call_without_reply cmd wrapper x = + let data = make_buffer () in + let ptr = { buffer = data; offset = 0 } in + let () = + match cmd.Commands.request with + | Some r -> + put_uint8 ptr r + | None -> + () + in + put_sequence ptr (Value.C.make_sequence (Value.arg_types cmd.Commands.send) x); + lwt card = get_card wrapper in + let buffer = forge_message { host_serial = 0; + device_serial = 0; + command = cmd.Commands.command; + error = 0; + data = data } in + try_lwt + Lwt_mutex.with_lock card.mutex + (fun () -> + lwt () = send card buffer in + return (Value.C.cast_sequence (Value.arg_types cmd.Commands.recv) [])) + with + | Canceled -> + fail Canceled + | exn -> + lwt () = Lwt_log.error_f ~section ~exn "write to %s card failed with" wrapper.name in + fail =<< abort wrapper exn + +(* Send a command and wait for the response: *) +let call_with_reply cmd wrapper x = + let data = make_buffer () in + let ptr = { buffer = data; offset = 0 } in + let () = + match cmd.Commands.request with + | Some r -> + put_uint8 ptr r + | None -> + () + in + put_sequence ptr (Value.C.make_sequence (Value.arg_types cmd.Commands.send) x); + lwt card = get_card wrapper in + let serial = match card.serial_pool with + | [] -> + failwith "Card.send_command_with_reply: no more serial available!" + | serial :: rest -> + card.serial_pool <- rest; + serial + in + let waiter, wakener = Lwt.task () in + card.reply_waiters <- Int_map.add serial wakener card.reply_waiters; + on_cancel waiter (fun () -> + card.reply_waiters <- Int_map.remove serial card.reply_waiters; + card.serial_pool <- card.serial_pool @ [serial]); + let buffer = forge_message { host_serial = serial; + device_serial = 0; + command = cmd.Commands.command; + error = 0; + data = data } in + try_lwt + Lwt_mutex.with_lock card.mutex + (fun () -> + lwt () = send card buffer in + lwt data = waiter in + let ptr = { buffer = data; offset = 0 } in + return (Value.C.cast_sequence (Value.arg_types cmd.Commands.recv) + (get_sequence ptr + (Value.C.type_sequence + (Value.arg_types cmd.Commands.recv))))) + with + | Canceled -> + fail Canceled + | exn -> + lwt () = Lwt_log.error_f ~section ~exn "write to %s card failed with" wrapper.name in + fail =<< abort wrapper exn + +let call cmd wrapper x = + if cmd.Commands.response then + call_with_reply cmd wrapper x + else + call_without_reply cmd wrapper x diff --git a/info/control/driver/USBCard.mli b/info/control/driver/USBCard.mli new file mode 100644 index 0000000..b5fdd0d --- /dev/null +++ b/info/control/driver/USBCard.mli @@ -0,0 +1,56 @@ +(* + * USBCard.mli + * ----------- + * Copyright : (c) 2009-2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(** Lowlevel card interfaces *) + +type t + (** Type of a card *) + +val name : t -> string + (** Returns the name of a card. It can be applied on a closed + card. *) + +val closed : t -> bool + (** Returns [true] iff the card has been closed *) + +val watch : t -> [ `Error of exn | `Closed ] Lwt.t + (** [watch card] is a thread which is wakeup when the card is + closed, or when a fatal error happen. The argument describe the + reason. *) + +exception Card_closed + (** Exception raised when trying to use a closed card *) + +exception Card_crashed of string + (** Exception raised when a fatal error happen on the card *) + +exception Error of string + (** An error returned by a card *) + +(** {6 Card opening/closing} *) + +val make : name : string -> handle : USB.handle -> t Lwt.t + (** [make ~name ~handle] creates a card using the given USB + handle. [name] is used for debug messages. *) + +val close : t -> unit Lwt.t + (** Close the given card *) + +(** {6 Sending/receving messages} *) + +val call : ('a, 'b) Commands.t -> t -> 'a -> 'b Lwt.t + (** Call a command on a device*) + +val commands : t -> (int * string) React.event + (** [comamnds card] returns the event which occurs each a message is + received from the card *) + +val errors : t -> string React.event + (** [errors card] is an event which occurs each time a card send an + error *) diff --git a/info/control/driver/driver.ml b/info/control/driver/driver.ml new file mode 100644 index 0000000..70fbde6 --- /dev/null +++ b/info/control/driver/driver.ml @@ -0,0 +1,1009 @@ +(* + * driver.ml + * --------- + * Copyright : (c) 2009-2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(* Driver for USB cards *) + +let section = Lwt_log.Section.make "driver" + +open Types +open Lwt + +let make_signal ?(update_delay=Config.update_delay) get card = + lwt value = get card in + return (React.S.hold value (Lwt_event.from + (fun () -> + lwt () = Lwt_unix.sleep update_delay in + get card))) + +(* THe notification mode for all interfaces: *) +let notify_mode () = OBus_object.notify_update "PropertiesChanged" + +(* +-----------------------------------------------------------------+ + | Power | + +-----------------------------------------------------------------+ *) + +module Power = +struct + type t = { + obus : t OBus_object.t; + card : USBCard.t; + } + + let make card path = + let dev = { + obus = + OBus_object.make + ~interfaces:[Export_unsafe.interface "power" (fun dev -> dev.card)] + path; + card = card; + } in + OBus_object.attach dev.obus dev; + return dev +end + +(* +-----------------------------------------------------------------+ + | Compass | + +-----------------------------------------------------------------+ *) + +module Compass = +struct + type t = { + obus : t OBus_object.t; + card : USBCard.t; + value : int React.signal; + } + + let make card path = + lwt value = make_signal ~update_delay:(Config.update_delay *. 2.) (fun card -> snd =|< USBCard.call Commands.Compass.get card ()) card in + let dev = { + obus = + OBus_object.make + ~interfaces:[Export_unsafe.interface "compass" (fun dev -> dev.card); + Krobot_interfaces.Fr_krobot_Device_Compass.make + ~notify_mode:(OBus_object.notify_update "PropertiesChanged") + ~p_Value:(fun dev -> React.S.map Int32.of_int dev.value) + ()] + path; + card = card; + value = value; + } in + OBus_object.attach dev.obus dev; + return dev +end + +(* +-----------------------------------------------------------------+ + | LCD | + +-----------------------------------------------------------------+ *) + +module LCD = +struct + type t = { + obus : t OBus_object.t; + card : USBCard.t; + } + + let set_lcd dev lines = + if List.length lines > 4 || List.exists (fun line -> String.length line > 20) lines then + invalid_arg "SetLCD" + else begin + lwt () = USBCard.call Commands.LCD.clear dev.card () in + lwt () = USBCard.call Commands.LCD.cursor_off dev.card () in + let rec loop i = function + | [] -> + return () + | line :: lines -> + lwt () = USBCard.call Commands.LCD.write_line dev.card (i, line) in + loop (i + 1) lines + in + loop 1 lines + end + + let backlight_on dev = USBCard.call Commands.LCD.backlight_on dev.card () + let backlight_off dev = USBCard.call Commands.LCD.backlight_off dev.card () + + let make card path = + let dev = { + obus = + OBus_object.make + ~interfaces:[Export_unsafe.interface "LCD" (fun dev -> dev.card); + Krobot_interfaces.Fr_krobot_Device_LCD.make + ~notify_mode:(OBus_object.notify_update "PropertiesChanged") + ~m_SetLCD:(fun ctx -> set_lcd) + ~m_BacklightOn:(fun ctx obj () -> backlight_on obj) + ~m_BacklightOff:(fun ctx obj () -> backlight_off obj) + ()] + path; + card = card; + } in + OBus_object.attach dev.obus dev; + return dev +end + +(* +-----------------------------------------------------------------+ + | Servo | + +-----------------------------------------------------------------+ *) + +module Servo = +struct + type t = { + obus : t OBus_object.t; + card : USBCard.t; + } + + let claws_enable dev = + USBCard.call Commands.Servo.set_config dev.card (0b10100, 0) + + let claws_disable dev = + USBCard.call Commands.Servo.set_config dev.card (0, 0xff) + + let claws_open dev = + USBCard.call Commands.Servo.set_state dev.card (0b10100, 0, 0, 18, 0, -69) + + let claws_close dev = + USBCard.call Commands.Servo.set_state dev.card (0b10100, 0, 0, -100, 0, 45) + + let claws_take dev = + USBCard.call Commands.Servo.set_state dev.card (0b10100, 0, 0, -40, 0, -20) + + let make card path = + let dev = { + obus = + OBus_object.make + ~interfaces:[Export_unsafe.interface "servo" (fun dev -> dev.card); + Krobot_interfaces.Fr_krobot_Device_Servo.make + ~notify_mode:(OBus_object.notify_update "PropertiesChanged") + ~m_ClawsEnable:(fun ctx obj () -> claws_enable obj) + ~m_ClawsDisable:(fun ctx obj () -> claws_disable obj) + ~m_ClawsOpen:(fun ctx obj () -> claws_open obj) + ~m_ClawsClose:(fun ctx obj () -> claws_close obj) + ~m_ClawsTake:(fun ctx obj () -> claws_take obj) + ()] + path; + card = card; + } in + OBus_object.attach dev.obus dev; + return dev +end + +(* +-----------------------------------------------------------------+ + | AX12 | + +-----------------------------------------------------------------+ *) + +module AX12 = +struct + type t = { + obus : t OBus_object.t; + card : USBCard.t; + } + + let grip_up_position = 880 + let grip_down_position = 580 + let ax12_default_velocity = 50 + + (* +---------------------------------------------------------------+ + | High-level commands | + +---------------------------------------------------------------+ *) + + type ax12_action = { + aa_id : int; + aa_position : int; + aa_velocity : int; + } + + let set_ax12 dev actions = + lwt () = + Lwt_list.iter_p + (fun action -> + USBCard.call Commands.AX12.goto + dev.card + (action.aa_id, + action.aa_position, + action.aa_velocity, + `Action)) + actions + in + USBCard.call Commands.AX12.action dev.card 0xfe + + let grip_up dev = + set_ax12 dev [{ aa_id = 1; + aa_position = 880; + aa_velocity = 50 }; + { aa_id = 2; + aa_position = 180; + aa_velocity = 50 }] + + let grip_down dev = + set_ax12 dev [{ aa_id = 1; + aa_position = 580; + aa_velocity = 50 }; + { aa_id = 2; + aa_position = 510; + aa_velocity = 50 }; + { aa_id = 3; + aa_position = 390; + aa_velocity = 200 }] + + let grip_open dev = + set_ax12 dev [{ aa_id = 2; + aa_position = 610; + aa_velocity = 100 }; + { aa_id = 3; + aa_position = 265; + aa_velocity = 200 }] + + let grip_close dev = + set_ax12 dev [{ aa_id = 2; + aa_position = 510; + aa_velocity = 100 }; + { aa_id = 3; + aa_position = 390; + aa_velocity = 200 }] + + let grip_release dev = + USBCard.call Commands.AX12.goto dev.card (3, 200, 200, `Now) + + let make card path = + let dev = { + obus = + OBus_object.make + ~interfaces:[Export_unsafe.interface "AX12" (fun dev -> dev.card); + Krobot_interfaces.Fr_krobot_Device_AX12.make + ~notify_mode:(OBus_object.notify_update "PropertiesChanged") + ~m_SetAX12:(fun ctx obj positions -> + let positions = + List.map + (fun (x1, x2, x3) -> + { aa_id = Int32.to_int x1; + aa_position = Int32.to_int x2; + aa_velocity = Int32.to_int x3 }) + positions + in + ... [truncated message content] |
From: Nicolas D. <Ba...@us...> - 2010-04-20 21:29:49
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 0fc3c12e38eba6fab3a467ad96573098b8b88633 (commit) via f63b0be39aeea1f7696d901daa50d09d79fad248 (commit) from a4d48e95570cecb45f05cbf26547eb72a025eb71 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0fc3c12e38eba6fab3a467ad96573098b8b88633 Author: Nicolas Dandrimont <Nic...@cr...> Date: Tue Apr 20 23:28:08 2010 +0200 Add a vertical Ultrasound Transducer board for the US Beacons commit f63b0be39aeea1f7696d901daa50d09d79fad248 Author: Nicolas Dandrimont <Nic...@cr...> Date: Tue Apr 20 23:12:27 2010 +0200 Add revision a of a Sensor Interface board This board comprises - 8 I²C connectors, with removable pull-ups - 16 logic connectors - 1 Serial port ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/Interface_Sensor/Assembly/USB_I2C_BRIDGE.BOM b/elec/boards/Interface_Sensor/Assembly/USB_I2C_BRIDGE.BOM new file mode 100644 index 0000000..bdc199a --- /dev/null +++ b/elec/boards/Interface_Sensor/Assembly/USB_I2C_BRIDGE.BOM @@ -0,0 +1,40 @@ +USB IC Bridge : Microcontroller Core Revised: Friday, April 02, 2010 + Revision: 1.0 + + + + + + + +Bill Of Materials April 2,2010 15:31:13 Page1 + +Item Quantity Reference Part +______________________________________________ + +1 3 C1,C2,C6 100n +2 1 C3 220n +3 2 C4,C5 22p +4 1 C7 0.33u +5 1 D1 10BQ040 +6 2 D2,D3 Orange LED +7 1 D4 Red LED +8 1 D5 D1N4001 +9 8 I1,I2,I3,I4,I5,I6,I7,I8 IC Bus +10 1 J1 Con. mini USB +11 1 J2 Con. PROG +12 1 J26 Power Bus +13 2 PU1,PU2 JP2 +14 4 R1,R2,R5,R9 10k +15 2 R3,R4 3k3 +16 2 R6,R7 680 +17 1 R8 100k +18 1 R10 470 +19 1 SW0 RESET +20 16 SW1,SW2,SW3,SW4,SW5,SW6, SW + SW7,SW8,SW9,SW10,SW11, + SW12,SW13,SW14,SW15,SW16 +21 1 S1 Serial Bus +22 1 U1 PIC18F4550-TQFP +23 1 U2 LM7805C/TO220 +24 1 X1 8 MHz diff --git a/elec/boards/Interface_Sensor/PCB/USB_I2C_BRIDGE.MAX b/elec/boards/Interface_Sensor/PCB/USB_I2C_BRIDGE.MAX new file mode 100644 index 0000000..2a48204 Binary files /dev/null and b/elec/boards/Interface_Sensor/PCB/USB_I2C_BRIDGE.MAX differ diff --git a/elec/boards/Interface_Sensor/PCB/USB_I2C_BRIDGE.MNL b/elec/boards/Interface_Sensor/PCB/USB_I2C_BRIDGE.MNL new file mode 100644 index 0000000..7052ad1 Binary files /dev/null and b/elec/boards/Interface_Sensor/PCB/USB_I2C_BRIDGE.MNL differ diff --git a/elec/boards/Interface_Sensor/Schematic/USB_I2C_BRIDGE.DSN b/elec/boards/Interface_Sensor/Schematic/USB_I2C_BRIDGE.DSN new file mode 100644 index 0000000..5edc8f5 Binary files /dev/null and b/elec/boards/Interface_Sensor/Schematic/USB_I2C_BRIDGE.DSN differ diff --git a/elec/boards/Interface_Sensor/Schematic/USB_I2C_BRIDGE_0.DBK b/elec/boards/Interface_Sensor/Schematic/USB_I2C_BRIDGE_0.DBK new file mode 100644 index 0000000..1a36ea4 Binary files /dev/null and b/elec/boards/Interface_Sensor/Schematic/USB_I2C_BRIDGE_0.DBK differ diff --git a/elec/boards/Interface_Sensor/Schematic/USB_I2C_Bridge-PSpiceFiles/SCHEMATIC1/default.mrk b/elec/boards/Interface_Sensor/Schematic/USB_I2C_Bridge-PSpiceFiles/SCHEMATIC1/default.mrk new file mode 100644 index 0000000..a1c2448 Binary files /dev/null and b/elec/boards/Interface_Sensor/Schematic/USB_I2C_Bridge-PSpiceFiles/SCHEMATIC1/default.mrk differ diff --git a/elec/boards/Interface_Sensor/Schematic/USB_I2C_Bridge.opj b/elec/boards/Interface_Sensor/Schematic/USB_I2C_Bridge.opj new file mode 100644 index 0000000..282987c --- /dev/null +++ b/elec/boards/Interface_Sensor/Schematic/USB_I2C_Bridge.opj @@ -0,0 +1,108 @@ +(ExpressProject "USB_I2C_Bridge" + (ProjectVersion "19981106") + (ProjectType "Analog or A/D Mixed Mode") + (Folder "Design Resources" + (Folder "Library") + (NoModify) + (File ".\usb_i2c_bridge.dsn" + (Type "Schematic Design")) + (BuildFileAddedOrDeleted "x") + (CompileFileAddedOrDeleted "x") + (PSPICE_Regenerate_Netlist_Flag "FALSE") + (Netlist_TAB "3") + (LAYOUT_Netlist_File "..\PCB\USB_I2C_BRIDGE.MNL") + (LAYOUT_PCB_Footprint "{PCB Footprint}") + (TRUE) + (LAYOUT_Units "0") + (DRC_Scope "0") + (DRC_Action "0") + (DRC_Create_Warnings "FALSE") + (DRC_Check_Ports "FALSE") + (DRC_Check_Off-Page_Connectors "FALSE") + (DRC_Identical_References "TRUE") + (DRC_Type_Mismatch "TRUE") + (DRC_Report_Ports_and_Off-page_Connectors "TRUE") + (DRC_SDT_Compatibility "FALSE") + (DRC_Report_Off-grid_Objects "TRUE") + (DRC_Check_Unconnected_Nets "TRUE") + (DRC_Check_for_Misleading_TAP "TRUE") + (DRC_Visible_Power_pins "FALSE") + (DRC_Report_Netnames "TRUE") + (DRC_View_Output "FALSE") + (DRC_Report_File ".\USB_I2C_BRIDGE.DRC") + (TRUE) + (TRUE) + (TRUE) + (BOM_Scope "0") + (BOM_Mode "0") + (BOM_Report_File "..\Assembly\USB_I2C_BRIDGE.BOM") + (BOM_Merge_Include "FALSE") + (BOM_Property_Combine_7.0 "{Item}\t{Quantity}\t{Reference}\t{Value}") + (BOM_Header "Item\tQuantity\tReference\tPart") + (BOM_Include_File "..\Assembly\USB_I2C_BRIDGE.INC") + (BOM_Include_File_Combine_7.0 "{Item}\t{Quantity}\t{Reference}\t{Value}") + (BOM_One_Part_Per_Line "FALSE") + (Open_BOM_in_Excel "FALSE") + (BOM_View_Output "TRUE")) + (Folder "Outputs" + (File ".\usb_i2c_bridge-pspicefiles\schematic1\schematic1.net" + (Type "Report")) + (File "..\PCB\usb_i2c_bridge.mnl" + (Type "LAYOUT Netlist File")) + (File ".\usb_i2c_bridge.drc" + (Type "Report")) + (File "..\Assembly\usb_i2c_bridge.bom" + (Type "Report"))) + (Folder "PSpice Resources" + (Folder "Simulation Profiles") + (Folder "Model Libraries") + (Folder "Stimulus Files") + (Folder "Include Files")) + (DefaultLibraryBrowseDirectory "library\PSpice") + (PartMRUSelector + (0 + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\CAPSYM.OLB") + (DeviceIndex "0")) + (OFFPAGELEFT-L + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\CAPSYM.OLB") + (DeviceIndex "0")) + (OFFPAGELEFT-R + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\CAPSYM.OLB") + (DeviceIndex "0")) + (JP2 + (FullPartName "JP2.Normal") + (LibraryName "Z:\CODE\KROBOT\KROBOT\LIBRARY\ORCAD\KROBOT.OLB") + (DeviceIndex "0")) + (R + (FullPartName "R.Normal") + (LibraryName + "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\PSPICE\ANALOG.OLB") + (DeviceIndex "0")) + (VCC + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\CAPSYM.OLB") + (DeviceIndex "0"))) + (LastUsedLibraryBrowseDirectory + "C:\OrCAD\OrCAD_16.0\tools\capture\library\pspice") + (GlobalState + (FileView + (Path "Design Resources") + (Path "Outputs") + (Select "Design Resources")) + (HierarchyView) + (Doc + (Type "COrCapturePMDoc") + (Frame + (Placement "44 0 1 -1 -1 -4 -23 1570 1886 0 718")) + (Tab 0)) + (Doc + (Type "COrSchematicDoc") + (Frame + (Placement "44 0 1 -1 -1 -4 -23 28 1056 0 718") + (Scroll "0 0") + (Zoom "106") + (Occurrence "/")) + (Path + "Z:\CODE\KROBOT\KROBOT\ELEC\BOARDS\INTERFACE_I2C\SCHEMATIC\USB_I2C_BRIDGE.DSN") + (Schematic "SCHEMATIC1") + (Page "Power"))) + (MPSSessionName "Nicolas Dandrimont")) diff --git a/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/PCB/VERTICAL_US_TRANSDUCER.MAX b/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/PCB/VERTICAL_US_TRANSDUCER.MAX new file mode 100644 index 0000000..438393b Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/PCB/VERTICAL_US_TRANSDUCER.MAX differ diff --git a/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/PCB/VERTICAL_US_TRANSDUCER.MNL b/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/PCB/VERTICAL_US_TRANSDUCER.MNL new file mode 100644 index 0000000..38684a0 Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/PCB/VERTICAL_US_TRANSDUCER.MNL differ diff --git a/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/Schematic/VERTICAL_US_TRANSDUCER.DBK b/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/Schematic/VERTICAL_US_TRANSDUCER.DBK new file mode 100644 index 0000000..94da72b Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/Schematic/VERTICAL_US_TRANSDUCER.DBK differ diff --git a/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/Schematic/VERTICAL_US_TRANSDUCER.DSN b/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/Schematic/VERTICAL_US_TRANSDUCER.DSN new file mode 100644 index 0000000..57817b1 Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/Schematic/VERTICAL_US_TRANSDUCER.DSN differ diff --git a/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/Schematic/Vertical_US_Transducer-PSpiceFiles/SCHEMATIC1/default.mrk b/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/Schematic/Vertical_US_Transducer-PSpiceFiles/SCHEMATIC1/default.mrk new file mode 100644 index 0000000..a1c2448 Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/Schematic/Vertical_US_Transducer-PSpiceFiles/SCHEMATIC1/default.mrk differ diff --git a/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/Schematic/Vertical_US_Transducer.opj b/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/Schematic/Vertical_US_Transducer.opj new file mode 100644 index 0000000..d891311 --- /dev/null +++ b/elec/boards/Sensor_BeaconUS/Vertical_US_Transducer/Schematic/Vertical_US_Transducer.opj @@ -0,0 +1,58 @@ +(ExpressProject "Vertical_US_Transducer" + (ProjectVersion "19981106") + (ProjectType "Analog or A/D Mixed Mode") + (Folder "Design Resources" + (Folder "Library") + (NoModify) + (File ".\vertical_us_transducer.dsn" + (Type "Schematic Design")) + (BuildFileAddedOrDeleted "x") + (CompileFileAddedOrDeleted "x") + (Netlist_TAB "3") + (LAYOUT_Netlist_File "..\PCB\vertical_us_transducer.MNL") + (LAYOUT_PCB_Footprint "{PCB Footprint}") + (TRUE) + (LAYOUT_Units "0")) + (Folder "Outputs" + (File "..\PCB\vertical_us_transducer.mnl" + (Type "LAYOUT Netlist File"))) + (Folder "PSpice Resources" + (Folder "Simulation Profiles") + (Folder "Model Libraries") + (Folder "Stimulus Files") + (Folder "Include Files")) + (DefaultLibraryBrowseDirectory "library\PSpice") + (PartMRUSelector + (US + (FullPartName "US.Normal") + (LibraryName "..\..\..\..\LIB\ORCAD\KROBOT.OLB") + (DeviceIndex "0")) + (JP2 + (FullPartName "JP2.Normal") + (LibraryName "..\..\..\..\lib\OrCAD\KROBOT.OLB") + (DeviceIndex "0"))) + (LastUsedLibraryBrowseDirectory "..\..\..\..\lib\OrCAD") + (GlobalState + (FileView + (Path "Design Resources") + (Path "Outputs") + (Select "Design Resources" + ".\vertical_us_transducer.dsn")) + (HierarchyView) + (Doc + (Type "COrCapturePMDoc") + (Frame + (Placement "44 0 1 -1 -1 -4 -23 0 200 0 379")) + (Tab 0)) + (Doc + (Type "COrSchematicDoc") + (Frame + (Placement "44 0 1 -1 -1 -4 -23 44 884 44 420") + (Scroll "0 0") + (Zoom "100") + (Occurrence "/")) + (Path + ".\VERTICAL_US_TRANSDUCER.DSN") + (Schematic "SCHEMATIC1") + (Page "PAGE1"))) + (MPSSessionName "Nicolas Dandrimont")) hooks/post-receive -- krobot |
From: Xavier L. <Ba...@us...> - 2010-04-20 21:13:27
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via a4d48e95570cecb45f05cbf26547eb72a025eb71 (commit) from b5811f1a46d1688a0809a29845724de03c9ef420 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a4d48e95570cecb45f05cbf26547eb72a025eb71 Author: Xavier Lagorce <Xav...@cr...> Date: Tue Apr 20 23:12:30 2010 +0200 Added schematics and board for an interface card to a TB6612FNG H-Bridge and an EMG30 motor. ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/H_Bridge_TB6612FNG_EMG30/PCB/INTERFACEEMG30.MNL b/elec/boards/H_Bridge_TB6612FNG_EMG30/PCB/INTERFACEEMG30.MNL new file mode 100644 index 0000000..6ccf101 Binary files /dev/null and b/elec/boards/H_Bridge_TB6612FNG_EMG30/PCB/INTERFACEEMG30.MNL differ diff --git a/elec/boards/H_Bridge_TB6612FNG_EMG30/PCB/INTERFACEEMG30_A.MAX b/elec/boards/H_Bridge_TB6612FNG_EMG30/PCB/INTERFACEEMG30_A.MAX new file mode 100644 index 0000000..2615512 Binary files /dev/null and b/elec/boards/H_Bridge_TB6612FNG_EMG30/PCB/INTERFACEEMG30_A.MAX differ diff --git a/elec/boards/H_Bridge_TB6612FNG_EMG30/Schematic/INTERFACEEMG30.DSN b/elec/boards/H_Bridge_TB6612FNG_EMG30/Schematic/INTERFACEEMG30.DSN new file mode 100644 index 0000000..8ab89ca Binary files /dev/null and b/elec/boards/H_Bridge_TB6612FNG_EMG30/Schematic/INTERFACEEMG30.DSN differ diff --git a/elec/boards/H_Bridge_TB6612FNG_EMG30/Schematic/INTERFACEEMG30_0.DBK b/elec/boards/H_Bridge_TB6612FNG_EMG30/Schematic/INTERFACEEMG30_0.DBK new file mode 100644 index 0000000..ef0daa1 Binary files /dev/null and b/elec/boards/H_Bridge_TB6612FNG_EMG30/Schematic/INTERFACEEMG30_0.DBK differ diff --git a/elec/boards/H_Bridge_TB6612FNG_EMG30/Schematic/interfaceEMG30.opj b/elec/boards/H_Bridge_TB6612FNG_EMG30/Schematic/interfaceEMG30.opj new file mode 100644 index 0000000..b884da4 --- /dev/null +++ b/elec/boards/H_Bridge_TB6612FNG_EMG30/Schematic/interfaceEMG30.opj @@ -0,0 +1,87 @@ +(ExpressProject "interfaceEMG30" + (ProjectVersion "19981106") + (ProjectType "Analog or A/D Mixed Mode") + (Folder "Design Resources" + (Folder "Library" + (File "..\bibliothes\krobot.olb" + (Type "Schematic Library")) + (File "..\bibliothes\crans.olb" + (Type "Schematic Library"))) + (NoModify) + (File ".\interfaceemg30.dsn" + (Type "Schematic Design")) + (BuildFileAddedOrDeleted "x") + (CompileFileAddedOrDeleted "x") + (Netlist_TAB "3") + (LAYOUT_Netlist_File "INTERFACEEMG30.MNL") + (LAYOUT_PCB_Footprint "{PCB Footprint}") + (TRUE) + (LAYOUT_Units "0") + (BOM_Scope "0") + (BOM_Mode "0") + (BOM_Report_File + "C:\Documents and Settings\XL\My Documents\cartesMars2010\BOM\interfaceEMG30.BOM") + (BOM_Merge_Include "FALSE") + (BOM_Property_Combine_7.0 "{Item}\t{Quantity}\t{Reference}\t{Value}") + (BOM_Header "Item\tQuantity\tReference\tPart") + (BOM_Include_File "C:\ORCAD_DATA\INTERFACEEMG30\INTERFACEEMG30.INC") + (BOM_Include_File_Combine_7.0 "{Item}\t{Quantity}\t{Reference}\t{Value}") + (BOM_One_Part_Per_Line "FALSE") + (Open_BOM_in_Excel "FALSE") + (BOM_View_Output "TRUE")) + (Folder "Outputs" + (File ".\interfaceemg30.mnl" + (Type "LAYOUT Netlist File")) + (File + "c:\documents and settings\xl\my documents\cartesmars2010\bom\interfaceemg30.bom" + (Type "Report"))) + (Folder "PSpice Resources" + (Folder "Simulation Profiles") + (Folder "Model Libraries" + (Sort User)) + (Folder "Stimulus Files" + (Sort User)) + (Folder "Include Files" + (Sort User))) + (DefaultLibraryBrowseDirectory "library\PSpice") + (PartMRUSelector + (C + (FullPartName "C.Normal") + (LibraryName + "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\PSPICE\ANALOG.OLB") + (DeviceIndex "0")) + (VCC_BAR + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\CAPSYM.OLB") + (DeviceIndex "0")) + (SPARKFUN_ROB-09457 + (FullPartName "SPARKFUN_ROB-09457.Normal") + (LibraryName "C:\ORCAD_DATA\BIBLIOTHUES\CRANS.OLB") + (DeviceIndex "0")) + (JP6 + (FullPartName "JP6.Normal") + (LibraryName "C:\ORCAD_DATA\BIBLIOTHUES\CRANS.OLB") + (DeviceIndex "0"))) + (GlobalState + (FileView + (Path "Design Resources") + (Path "Design Resources" "Library") + (Path "Outputs") + (Select "Design Resources" + "C:\ORCAD_DATA\interfaceEMG30\interfaceemg30.dsn")) + (HierarchyView) + (Doc + (Type "COrCapturePMDoc") + (Frame + (Placement "44 2 3 -1 -1 -4 -30 0 200 0 398")) + (Tab 0)) + (Doc + (Type "COrSchematicDoc") + (Frame + (Placement "44 0 1 -1 -1 -4 -30 114 1240 28 460") + (Scroll "0 40") + (Zoom "100") + (Occurrence "/")) + (Path "C:\ORCAD_DATA\INTERFACEEMG30\INTERFACEEMG30.DSN") + (Schematic "SCHEMATIC1") + (Page "PAGE1"))) + (MPSSessionName "XL")) hooks/post-receive -- krobot |
From: Xavier L. <Ba...@us...> - 2010-04-20 21:08:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via b5811f1a46d1688a0809a29845724de03c9ef420 (commit) from 6f0bb5eeb43ae743a2a50face068c8bf194c4a36 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b5811f1a46d1688a0809a29845724de03c9ef420 Author: Xavier Lagorce <Xav...@cr...> Date: Tue Apr 20 23:07:42 2010 +0200 Added schemtaics and PCB for new generation ultrasonic range finders. Based on PSoCs, these boards are ultrasonic range finders interfaced by I2C. ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/Sensor_USRangeFinder/PCB/TELEMETREUS.MNL b/elec/boards/Sensor_USRangeFinder/PCB/TELEMETREUS.MNL new file mode 100644 index 0000000..1d1e228 Binary files /dev/null and b/elec/boards/Sensor_USRangeFinder/PCB/TELEMETREUS.MNL differ diff --git a/elec/boards/Sensor_USRangeFinder/PCB/TELEMETREUS_A.MAX b/elec/boards/Sensor_USRangeFinder/PCB/TELEMETREUS_A.MAX new file mode 100644 index 0000000..9633fd5 Binary files /dev/null and b/elec/boards/Sensor_USRangeFinder/PCB/TELEMETREUS_A.MAX differ diff --git a/elec/boards/Sensor_USRangeFinder/Schematic/TELEMETREUS.DSN b/elec/boards/Sensor_USRangeFinder/Schematic/TELEMETREUS.DSN new file mode 100644 index 0000000..1b38aed Binary files /dev/null and b/elec/boards/Sensor_USRangeFinder/Schematic/TELEMETREUS.DSN differ diff --git a/elec/boards/Sensor_USRangeFinder/Schematic/TELEMETREUS_0.DBK b/elec/boards/Sensor_USRangeFinder/Schematic/TELEMETREUS_0.DBK new file mode 100644 index 0000000..e902fbd Binary files /dev/null and b/elec/boards/Sensor_USRangeFinder/Schematic/TELEMETREUS_0.DBK differ diff --git a/elec/boards/Sensor_USRangeFinder/Schematic/telemetreUS.opj b/elec/boards/Sensor_USRangeFinder/Schematic/telemetreUS.opj new file mode 100644 index 0000000..0f207bf --- /dev/null +++ b/elec/boards/Sensor_USRangeFinder/Schematic/telemetreUS.opj @@ -0,0 +1,88 @@ +(ExpressProject "telemetreUS" + (ProjectVersion "19981106") + (ProjectType "Analog or A/D Mixed Mode") + (Folder "Design Resources" + (Folder "Library" + (File "..\bibliothes\krobot.olb" + (Type "Schematic Library")) + (File "..\bibliothes\crans.olb" + (Type "Schematic Library"))) + (NoModify) + (File ".\telemetreus.dsn" + (Type "Schematic Design")) + (BuildFileAddedOrDeleted "x") + (CompileFileAddedOrDeleted "x") + (Netlist_TAB "3") + (LAYOUT_Netlist_File "TELEMETREUS.MNL") + (LAYOUT_PCB_Footprint "{PCB Footprint}") + (TRUE) + (LAYOUT_Units "0") + (TRUE) + (BOM_Scope "0") + (BOM_Mode "0") + (BOM_Report_File + "C:\Documents and Settings\XL\My Documents\cartesMars2010\BOM\telemetreUltrasons.BOM") + (BOM_Merge_Include "FALSE") + (BOM_Property_Combine_7.0 "{Item}\t{Quantity}\t{Reference}\t{Value}") + (BOM_Header "Item\tQuantity\tReference\tPart") + (BOM_Include_File "C:\ORCAD_DATA\TELEMETREUS\TELEMETREUS.INC") + (BOM_Include_File_Combine_7.0 "{Item}\t{Quantity}\t{Reference}\t{Value}") + (BOM_One_Part_Per_Line "FALSE") + (Open_BOM_in_Excel "FALSE") + (BOM_View_Output "FALSE")) + (Folder "Outputs" + (File ".\telemetreus.mnl" + (Type "LAYOUT Netlist File")) + (File + "c:\documents and settings\xl\my documents\cartesmars2010\bom\telemetreultrasons.bom" + (Type "Report"))) + (Folder "PSpice Resources" + (Folder "Simulation Profiles") + (Folder "Model Libraries" + (Sort User)) + (Folder "Stimulus Files" + (Sort User)) + (Folder "Include Files" + (Sort User))) + (DefaultLibraryBrowseDirectory "library\PSpice") + (PartMRUSelector + (JP4 + (FullPartName "JP4.Normal") + (LibraryName "C:\ORCAD_DATA\BIBLIOTHUES\KROBOT.OLB") + (DeviceIndex "0")) + (MAX202 + (FullPartName "MAX202.Normal") + (LibraryName "C:\ORCAD_DATA\BIBLIOTHUES\CRANS.OLB") + (DeviceIndex "0")) + (TestPoint + (FullPartName "TestPoint.Normal") + (LibraryName "C:\ORCAD_DATA\BIBLIOTHUES\CRANS.OLB") + (DeviceIndex "0")) + (blocUS + (FullPartName "blocUS.Normal") + (LibraryName "C:\ORCAD_DATA\BIBLIOTHUES\CRANS.OLB") + (DeviceIndex "0"))) + (LastUsedLibraryBrowseDirectory "C:\OrCAD_Data\bibliothes") + (GlobalState + (FileView + (Path "Design Resources") + (Path "Design Resources" "Library") + (Path "Outputs") + (Select "Design Resources")) + (HierarchyView) + (Doc + (Type "COrCapturePMDoc") + (Frame + (Placement "44 0 1 -1 -1 -4 -30 0 301 0 428")) + (Tab 0)) + (Doc + (Type "COrSchematicDoc") + (Frame + (Placement "44 0 1 -1 -1 -4 -30 92 1218 77 509") + (Scroll "0 0") + (Zoom "200") + (Occurrence "/")) + (Path "C:\ORCAD_DATA\TELEMETREUS\TELEMETREUS.DSN") + (Schematic "SCHEMATIC1") + (Page "PAGE1"))) + (MPSSessionName "XL")) hooks/post-receive -- krobot |
From: Xavier L. <Ba...@us...> - 2010-04-20 21:01:59
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 6f0bb5eeb43ae743a2a50face068c8bf194c4a36 (commit) from 0a66f6584439e00fbb10974565a74e2b18a8cd5a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6f0bb5eeb43ae743a2a50face068c8bf194c4a36 Author: Xavier Lagorce <Xav...@cr...> Date: Tue Apr 20 22:58:48 2010 +0200 Added schematics and PCBs for the position sensor system. Based on PSoCs, it obtains the position of the robot by measuring flight time of ultrasonic waves emitted by the robot and received by satellites. The data are sent back to the robot with a Xbee radio link. code comming soon... (let's hope so...) ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/Sensor_BeaconUS/Beacon_Robot/PCB/BALISESKROBOT_ROBOT.MNL b/elec/boards/Sensor_BeaconUS/Beacon_Robot/PCB/BALISESKROBOT_ROBOT.MNL new file mode 100644 index 0000000..784c0a8 Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Beacon_Robot/PCB/BALISESKROBOT_ROBOT.MNL differ diff --git a/elec/boards/Sensor_BeaconUS/Beacon_Robot/PCB/BALISESKROBOT_ROBOT_A.MAX b/elec/boards/Sensor_BeaconUS/Beacon_Robot/PCB/BALISESKROBOT_ROBOT_A.MAX new file mode 100644 index 0000000..f764f21 Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Beacon_Robot/PCB/BALISESKROBOT_ROBOT_A.MAX differ diff --git a/elec/boards/Sensor_BeaconUS/Beacon_Robot/Schematic/BLASESKROBOT_ROBOT.DSN b/elec/boards/Sensor_BeaconUS/Beacon_Robot/Schematic/BLASESKROBOT_ROBOT.DSN new file mode 100644 index 0000000..f84412f Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Beacon_Robot/Schematic/BLASESKROBOT_ROBOT.DSN differ diff --git a/elec/boards/Sensor_BeaconUS/Beacon_Robot/Schematic/BLASESKROBOT_ROBOT_0.DBK b/elec/boards/Sensor_BeaconUS/Beacon_Robot/Schematic/BLASESKROBOT_ROBOT_0.DBK new file mode 100644 index 0000000..02be103 Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Beacon_Robot/Schematic/BLASESKROBOT_ROBOT_0.DBK differ diff --git a/elec/boards/Sensor_BeaconUS/Beacon_Robot/Schematic/blasesKrobot_Robot.opj b/elec/boards/Sensor_BeaconUS/Beacon_Robot/Schematic/blasesKrobot_Robot.opj new file mode 100644 index 0000000..9a512d6 --- /dev/null +++ b/elec/boards/Sensor_BeaconUS/Beacon_Robot/Schematic/blasesKrobot_Robot.opj @@ -0,0 +1,67 @@ +(ExpressProject "blasesKrobot_Robot" + (ProjectVersion "19981106") + (ProjectType "Analog or A/D Mixed Mode") + (Folder "Design Resources" + (Folder "Library") + (NoModify) + (File ".\blaseskrobot_robot.dsn" + (Type "Schematic Design")) + (BuildFileAddedOrDeleted "x") + (CompileFileAddedOrDeleted "x") + (Netlist_TAB "3") + (LAYOUT_Netlist_File "BALISESKROBOT_ROBOT.MNL") + (LAYOUT_PCB_Footprint "{PCB Footprint}") + (TRUE) + (LAYOUT_Units "0") + (TRUE)) + (Folder "Outputs" + (File ".\baliseskrobot_robot.mnl" + (Type "LAYOUT Netlist File"))) + (Folder "PSpice Resources" + (Folder "Simulation Profiles") + (Folder "Model Libraries" + (Sort User)) + (Folder "Stimulus Files" + (Sort User)) + (Folder "Include Files" + (Sort User))) + (DefaultLibraryBrowseDirectory "library\PSpice") + (MPSSessionName "XL") + (GlobalState + (FileView + (Path "Design Resources") + (Path "Outputs") + (Select "Design Resources")) + (HierarchyView) + (Doc + (Type "COrCapturePMDoc") + (Frame + (Placement "44 0 1 -1 -1 -4 -30 0 200 0 428")) + (Tab 0)) + (Doc + (Type "COrSchematicDoc") + (Frame + (Placement "44 0 1 -1 -1 -4 -30 104 1230 111 543") + (Scroll "0 0") + (Zoom "82") + (Occurrence "/")) + (Path "C:\ORCAD_DATA\BALISESKROBOT_ROBOT\BLASESKROBOT_ROBOT.DSN") + (Schematic "SCHEMATIC1") + (Page "PAGE1")) + (Doc + (Type "COrSchematicDoc") + (Frame + (Placement "44 0 1 -1 -1 -4 -30 52 1178 -13 419") + (Scroll "0 0") + (Zoom "90") + (Occurrence "/")) + (Path "C:\ORCAD_DATA\BALISESKROBOT_ROBOT\BLASESKROBOT_ROBOT.DSN") + (Schematic "SCHEMATIC1") + (Page "PAGE2"))) + (PartMRUSelector + (OFFPAGELEFT-L + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\CAPSYM.OLB") + (DeviceIndex "0")) + (OFFPAGELEFT-R + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\CAPSYM.OLB") + (DeviceIndex "0")))) diff --git a/elec/boards/Sensor_BeaconUS/Beacon_Satellite/PCB/BALISESKROBOT_BALISES.MNL b/elec/boards/Sensor_BeaconUS/Beacon_Satellite/PCB/BALISESKROBOT_BALISES.MNL new file mode 100644 index 0000000..cf6e32d Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Beacon_Satellite/PCB/BALISESKROBOT_BALISES.MNL differ diff --git a/elec/boards/Sensor_BeaconUS/Beacon_Satellite/PCB/BALISESKROBOT_BALISES_A.MAX b/elec/boards/Sensor_BeaconUS/Beacon_Satellite/PCB/BALISESKROBOT_BALISES_A.MAX new file mode 100644 index 0000000..09edbd7 Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Beacon_Satellite/PCB/BALISESKROBOT_BALISES_A.MAX differ diff --git a/elec/boards/Sensor_BeaconUS/Beacon_Satellite/Schematic/BALISESKROBOT_BALISES.DSN b/elec/boards/Sensor_BeaconUS/Beacon_Satellite/Schematic/BALISESKROBOT_BALISES.DSN new file mode 100644 index 0000000..e293896 Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Beacon_Satellite/Schematic/BALISESKROBOT_BALISES.DSN differ diff --git a/elec/boards/Sensor_BeaconUS/Beacon_Satellite/Schematic/BALISESKROBOT_BALISES_0.DBK b/elec/boards/Sensor_BeaconUS/Beacon_Satellite/Schematic/BALISESKROBOT_BALISES_0.DBK new file mode 100644 index 0000000..58ec654 Binary files /dev/null and b/elec/boards/Sensor_BeaconUS/Beacon_Satellite/Schematic/BALISESKROBOT_BALISES_0.DBK differ diff --git a/elec/boards/Sensor_BeaconUS/Beacon_Satellite/Schematic/BalisesKrobot_Balises.opj b/elec/boards/Sensor_BeaconUS/Beacon_Satellite/Schematic/BalisesKrobot_Balises.opj new file mode 100644 index 0000000..1e2ea73 --- /dev/null +++ b/elec/boards/Sensor_BeaconUS/Beacon_Satellite/Schematic/BalisesKrobot_Balises.opj @@ -0,0 +1,65 @@ +(ExpressProject "BalisesKrobot_Balises" + (ProjectVersion "19981106") + (ProjectType "Analog or A/D Mixed Mode") + (Folder "Design Resources" + (Folder "Library") + (NoModify) + (File ".\baliseskrobot_balises.dsn" + (Type "Schematic Design")) + (BuildFileAddedOrDeleted "x") + (CompileFileAddedOrDeleted "x") + (Netlist_TAB "3") + (LAYOUT_Netlist_File "BALISESKROBOT_BALISES.MNL") + (LAYOUT_PCB_Footprint "{PCB Footprint}") + ( "TRUE") + (LAYOUT_Units "0")) + (Folder "Outputs" + (File ".\baliseskrobot_balises.mnl" + (Type "LAYOUT Netlist File"))) + (Folder "PSpice Resources" + (Folder "Simulation Profiles") + (Folder "Model Libraries" + (Sort User)) + (Folder "Stimulus Files" + (Sort User)) + (Folder "Include Files" + (Sort User))) + (DefaultLibraryBrowseDirectory "library\PSpice") + (PartMRUSelector) + (GlobalState + (FileView + (Path "Design Resources") + (Path "Design Resources" + "C:\ORCAD_DATA\balisesKrobot_Balises\baliseskrobot_balises.dsn") + (Path "Design Resources" + "C:\ORCAD_DATA\balisesKrobot_Balises\baliseskrobot_balises.dsn" + "SCHEMATIC1") + (Path "Outputs") + (Select "Design Resources" + "C:\ORCAD_DATA\balisesKrobot_Balises\baliseskrobot_balises.dsn")) + (HierarchyView) + (Doc + (Type "COrCapturePMDoc") + (Frame + (Placement "44 0 1 -1 -1 -4 -30 0 200 0 398")) + (Tab 0)) + (Doc + (Type "COrSchematicDoc") + (Frame + (Placement "44 2 3 -1 -1 -4 -30 110 1236 145 577") + (Scroll "0 0") + (Zoom "82") + (Occurrence "/")) + (Path "C:\ORCAD_DATA\BALISESKROBOT_BALISES\BALISESKROBOT_BALISES.DSN") + (Schematic "SCHEMATIC1") + (Page "PAGE1")) + (Doc + (Type "COrSchematicDoc") + (Frame + (Placement "44 0 1 -1 -1 -4 -30 132 1254 174 602") + (Scroll "167 83") + (Zoom "148") + (Occurrence "/")) + (Path "C:\ORCAD_DATA\BALISESKROBOT_BALISES\BALISESKROBOT_BALISES.DSN") + (Schematic "SCHEMATIC1") + (Page "PAGE2")))) hooks/post-receive -- krobot |
From: Xavier L. <Ba...@us...> - 2010-04-20 16:45:41
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 0a66f6584439e00fbb10974565a74e2b18a8cd5a (commit) from fc0d09703d036e8fc2748caaf604f4954f5761b6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0a66f6584439e00fbb10974565a74e2b18a8cd5a Author: Xavier Lagorce <Xav...@cr...> Date: Tue Apr 20 18:44:37 2010 +0200 PI controller tunning. Bigger demo. ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/main.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/main.c index ec95407..af62475 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/main.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/main.c @@ -38,7 +38,6 @@ static msg_t Thread1(void *arg) { sc_setRefSpeed(MOTOR3, -360); chThdSleepMilliseconds(2000); - sc_setRefSpeed(MOTOR1, -360); sc_setRefSpeed(MOTOR2, 360); sc_setRefSpeed(MOTOR3, 0); @@ -53,6 +52,31 @@ static msg_t Thread1(void *arg) { palSetPad(IOPORT3, GPIOC_LED); chThdSleepMilliseconds(1000); + + sc_setRefSpeed(MOTOR1, 360); + sc_setRefSpeed(MOTOR2, 360); + sc_setRefSpeed(MOTOR3, 360); + chThdSleepMilliseconds(3000); + + sc_setRefSpeed(MOTOR1, 0); + sc_setRefSpeed(MOTOR2, 0); + sc_setRefSpeed(MOTOR3, 0); + chThdSleepMilliseconds(3000); + + sc_setRefSpeed(MOTOR1, -360); + sc_setRefSpeed(MOTOR2, -360); + sc_setRefSpeed(MOTOR3, -360); + chThdSleepMilliseconds(3000); + + sc_setRefSpeed(MOTOR1, 0); + sc_setRefSpeed(MOTOR2, 0); + sc_setRefSpeed(MOTOR3, 0); + + palClearPad(IOPORT3, GPIOC_LED); + chThdSleepMilliseconds(1000); + + palSetPad(IOPORT3, GPIOC_LED); + chThdSleepMilliseconds(1000); } return 0; } diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.h index 9a39128..aee988f 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.h @@ -6,13 +6,13 @@ #ifndef HEADER__SPEEDCONTROL #define HEADER__SPEEDCONTROL -#define K_P 20 +#define K_P 25 #define K_I 1 #define Te 50 #define K_v (1000/Te) #define K_Pn K_P -#define K_In 5//(K_I)*Te +#define K_In 25//(K_I)*Te #define DEAD_ZONE 100 #define MAX_COMMAND 35000 hooks/post-receive -- krobot |
From: Xavier L. <Ba...@us...> - 2010-04-19 22:43:14
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via fc0d09703d036e8fc2748caaf604f4954f5761b6 (commit) from 5f90539cdc0f9083a613e7004fa441489a337190 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fc0d09703d036e8fc2748caaf604f4954f5761b6 Author: Xavier Lagorce <Xav...@cr...> Date: Tue Apr 20 00:41:15 2010 +0200 Added a speed controller to the firmware Serial COM and monitoring shell are deactivated beacause they seem to hang the program. Krobot Junior can move in a triangle ! ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/Makefile b/elec/boards/MotherBoard_KrobotJr2010/Firmware/Makefile index 1b61e32..c6ef472 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/Makefile +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/Makefile @@ -81,6 +81,7 @@ CSRC += monitor.c CSRC += encoder.c CSRC += motor.c CSRC += cpu_load.c +CSRC += speed_control.c CSRC += main.c # C++ sources that can be compiled in ARM or THUMB mode depending on the global diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/main.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/main.c index 69e2766..ec95407 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/main.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/main.c @@ -1,6 +1,7 @@ /* - Template program using ChibiOS/RT -*/ + * Control Software for the Krobot Junior MotherBoard + * Xavier Lagorce + */ #include <stdio.h> #include <stdlib.h> @@ -12,8 +13,8 @@ #include "monitor.h" #include "encoder.h" -#include "motor.h" #include "cpu_load.h" +#include "speed_control.h" /* * Global variables @@ -27,10 +28,31 @@ static msg_t Thread1(void *arg) { (void)arg; while (TRUE) { + sc_setRefSpeed(MOTOR1, 0); + sc_setRefSpeed(MOTOR2, -360); + sc_setRefSpeed(MOTOR3, 360); + chThdSleepMilliseconds(2000); + + sc_setRefSpeed(MOTOR1, 360); + sc_setRefSpeed(MOTOR2, 0); + sc_setRefSpeed(MOTOR3, -360); + chThdSleepMilliseconds(2000); + + + sc_setRefSpeed(MOTOR1, -360); + sc_setRefSpeed(MOTOR2, 360); + sc_setRefSpeed(MOTOR3, 0); + chThdSleepMilliseconds(2000); + + sc_setRefSpeed(MOTOR1, 0); + sc_setRefSpeed(MOTOR2, 0); + sc_setRefSpeed(MOTOR3, 0); + palClearPad(IOPORT3, GPIOC_LED); - chThdSleepMilliseconds(500); + chThdSleepMilliseconds(1000); + palSetPad(IOPORT3, GPIOC_LED); - chThdSleepMilliseconds(500); + chThdSleepMilliseconds(1000); } return 0; } @@ -80,22 +102,20 @@ int main(int argc, char **argv) { /* * Activates the serial driver 2 using the driver default configuration. */ - sdStart(&SD2, NULL); + //sdStart(&SD2, NULL); /* * Initialise the monitor */ - monitorInit(); + //monitorInit(); /* - * Initialise the encoder Interface + * Initialise the speed controller */ - encodersInit(); + speedControlInit(); + + chThdSleepMilliseconds(2000); - /* - * Initialise the motor Interface - */ - motorsInit(); /* * Creates the blinker thread. diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c index 2acb14c..586e8dd 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.c @@ -78,36 +78,6 @@ void getHandler(BaseChannel *chp, int argc, char* argv[]) { (position)%10); }; -void resetHandler(BaseChannel *chp, int argc, char* argv[]) { - - if (argc != 1) { - shellPrintLine(chp, "Usage : reset numEncodeur."); - return; - } - switch (argv[0][0]) { - case '1': - resetEncoderPosition(ENCODER1); - shellPrintLine(chp, "Reset encodeur 1."); - break; - case '2': - resetEncoderPosition(ENCODER2); - shellPrintLine(chp, "Reset encodeur 2."); - break; - case '3': - resetEncoderPosition(ENCODER3); - shellPrintLine(chp, "Reset encodeur 3."); - break; - case 'a': - resetEncoderPosition(ENCODER1); - resetEncoderPosition(ENCODER2); - resetEncoderPosition(ENCODER3); - shellPrintLine(chp, "Reset de tous les encodeurs."); - break; - default: - shellPrintLine(chp, "Il n'y a que 3 encodeurs !"); - } -} - void setSpeedHandler(BaseChannel *chp, int argc, char* argv[]) { uint8_t motor = 0, i; @@ -141,7 +111,7 @@ void setSpeedHandler(BaseChannel *chp, int argc, char* argv[]) { } if (argv[1][0] == '-') speed = -speed; - motorSetSpeed(motor, speed); + sc_setRefSpeed(motor, speed); iprintf("set speed : %d%d%d%d%d\r\n", (speed/10000)%10, (speed/1000)%10, (speed/100)%10, @@ -149,42 +119,34 @@ void setSpeedHandler(BaseChannel *chp, int argc, char* argv[]) { (speed)%10); } -void motorEnableHandler(BaseChannel *chp, int argc, char* argv[]) { +void getSpeedHandler(BaseChannel *chp, int argc, char* argv[]) { - uint8_t motor = 0; + int speed; - if (argc != 2) { - shellPrintLine(chp, "Usage : motor numMoteur enabled."); + if (argc != 1) { + shellPrintLine(chp, "Usage : getSpeed numMoteur."); return; } switch (argv[0][0]) { case '1': - motor = MOTOR1; + speed = sc_getRealSpeed(MOTOR1); break; case '2': - motor = MOTOR2; + speed = sc_getRealSpeed(MOTOR2); break; case '3': - motor = MOTOR3; - break; - case 'a': - motor = MOTOR1 | MOTOR2 | MOTOR3; + speed = sc_getRealSpeed(MOTOR3); break; default: shellPrintLine(chp, "Mauvais moteur spécifié"); return; } - switch (argv[1][0]) { - case '0': - disableMotor(motor); - break; - case '1': - enableMotor(motor); - break; - default: - shellPrintLine(chp, "gné ?"); - return; - } + + iprintf("vitesse : %d%d%d%d%d\r\n", (speed/10000)%10, + (speed/1000)%10, + (speed/100)%10, + (speed/10)%10, + (speed)%10); } @@ -195,9 +157,8 @@ static const ShellCommand commands[] = { {"bonjour", bonjourHandler}, {"load", loadHandler}, {"get", getHandler}, - {"reset", resetHandler}, {"setSpeed", setSpeedHandler}, - {"motorEnable", motorEnableHandler}, + {"getSpeed", getSpeedHandler}, {NULL, NULL} }; @@ -208,6 +169,6 @@ static const ShellConfig shellConfig = { void monitorInit(void) { shellInit(); - shellCreate(&shellConfig, THD_WA_SIZE(512), NORMALPRIO); - cdtp = chThdCreateFromHeap(NULL, THD_WA_SIZE(512), NORMALPRIO + 1, consoleThread, NULL); + shellCreate(&shellConfig, THD_WA_SIZE(256), NORMALPRIO); + cdtp = chThdCreateFromHeap(NULL, THD_WA_SIZE(128), NORMALPRIO + 1, consoleThread, NULL); } diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.h index 13f273b..7651066 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/monitor.h @@ -21,6 +21,7 @@ #include "encoder.h" #include "motor.h" #include "cpu_load.h" +#include "speed_control.h" extern Thread *cdtp; diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.c new file mode 100644 index 0000000..38d9b26 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.c @@ -0,0 +1,156 @@ +/* + * Speed control + * Xavier Lagorce + */ + +#include "speed_control.h" + +#define MAX(x,y) ((x) > (y) ? (x) : (y)) +#define MIN(x,y) ((x) > (y) ? (y) : (x)) + +volatile int ref_speeds[3] = {0, 0, 0}; +volatile int last_errors[3] = {0, 0, 0}; +volatile int last_commands[3] = {0, 0, 0}; + +volatile int cur_speeds[3] = {0, 0, 0}; +volatile uint16_t prev_positions[3] = {0, 0, 0}; + +/* + * Speed controller thread + */ +static msg_t ThreadSpeedController(void *arg) { + + systime_t time; + int commands[3] = {0, 0, 0}; + int errors[3] = {0, 0, 0}; + uint16_t positions[3] = {0, 0, 0}; + + (void)arg; + time = chTimeNow(); + + while (TRUE) { + time += MS2ST(Te); + + positions[0] = getEncoderPosition(ENCODER1); + positions[1] = getEncoderPosition(ENCODER2); + positions[2] = getEncoderPosition(ENCODER3); + + cur_speeds[0] = (int16_t)(K_v*((int32_t)positions[0] - (int32_t)prev_positions[0])); + cur_speeds[1] = (int16_t)(K_v*((int32_t)positions[1] - (int32_t)prev_positions[1])); + cur_speeds[2] = (int16_t)(K_v*((int32_t)positions[2] - (int32_t)prev_positions[2])); + + errors[0] = ref_speeds[0] - cur_speeds[0]; + errors[1] = ref_speeds[1] - cur_speeds[1]; + errors[2] = ref_speeds[2] - cur_speeds[2]; + + //--> Command computation + commands[0] = (K_Pn + K_In)*errors[0] - K_Pn*last_errors[0] + last_commands[0]; + commands[1] = (K_Pn + K_In)*errors[1] - K_Pn*last_errors[1] + last_commands[1]; + commands[2] = (K_Pn + K_In)*errors[2] - K_Pn*last_errors[2] + last_commands[2]; + //--> End of command computation + + if (commands[0] >= 0) + commands[0] = MIN(MAX_COMMAND, commands[0]); + else + commands[0] = MAX(-MAX_COMMAND, commands[0]); + if (commands[1] >= 0) + commands[1] = MIN(MAX_COMMAND, commands[1]); + else + commands[1] = MAX(-MAX_COMMAND, commands[1]); + if (commands[2] >= 0) + commands[2] = MIN(MAX_COMMAND, commands[2]); + else + commands[2] = MAX(-MAX_COMMAND, commands[2]); + + last_commands[0] = commands[0]; + last_commands[1] = commands[1]; + last_commands[2] = commands[2]; + + if (commands[0] >= -DEAD_ZONE && commands[0] <= DEAD_ZONE) + commands[0] = 0; + if (commands[1] >= -DEAD_ZONE && commands[1] <= DEAD_ZONE) + commands[1] = 0; + if (commands[2] >= -DEAD_ZONE && commands[2] <= DEAD_ZONE) + commands[2] = 0; + + prev_positions[0] = positions[0]; + prev_positions[1] = positions[1]; + prev_positions[2] = positions[2]; + + last_errors[0] = errors[0]; + last_errors[1] = errors[1]; + last_errors[2] = errors[2]; + + + motorSetSpeed(MOTOR1, commands[0]); + motorSetSpeed(MOTOR2, commands[1]); + motorSetSpeed(MOTOR3, commands[2]); + + chThdSleepUntil(time); + } + return 0; +} + + +void speedControlInit(void) { + + encodersInit(); + motorsInit(); + + enableMotor(MOTOR1 | MOTOR2 | MOTOR3); + motorSetSpeed(MOTOR1 | MOTOR2 | MOTOR3, 0); + resetEncoderPosition(ENCODER1 | ENCODER2 | ENCODER3); + + prev_positions[0] = getEncoderPosition(ENCODER1); + prev_positions[1] = getEncoderPosition(ENCODER2); + prev_positions[2] = getEncoderPosition(ENCODER3); + + chThdCreateFromHeap(NULL, 256, HIGHPRIO, ThreadSpeedController, NULL); +} + +void sc_setRefSpeed(uint8_t motor, int speed) { + + if (motor & MOTOR1) { + ref_speeds[0] = speed; + } + if (motor & MOTOR2) { + ref_speeds[1] = speed; + } + if (motor & MOTOR3) { + ref_speeds[2] = speed; + } +} + +int sc_getRealSpeed(uint8_t motor) { + + switch(motor) { + case MOTOR1: + return cur_speeds[0]; + break; + case MOTOR2: + return cur_speeds[1]; + break; + case MOTOR3: + return cur_speeds[2]; + break; + default: + return 0; + } +} + +uint16_t sc_getPosition(uint8_t motor) { + + switch(motor) { + case MOTOR1: + return prev_positions[0]; + break; + case MOTOR2: + return prev_positions[1]; + break; + case MOTOR3: + return prev_positions[2]; + break; + default: + return 0; + } +} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.h new file mode 100644 index 0000000..9a39128 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/speed_control.h @@ -0,0 +1,31 @@ +/* + * Speed control + * Xavier Lagorce + */ + +#ifndef HEADER__SPEEDCONTROL +#define HEADER__SPEEDCONTROL + +#define K_P 20 +#define K_I 1 +#define Te 50 + +#define K_v (1000/Te) +#define K_Pn K_P +#define K_In 5//(K_I)*Te + +#define DEAD_ZONE 100 +#define MAX_COMMAND 35000 + +#include "ch.h" +#include "motor.h" +#include "encoder.h" + +extern volatile int ref_speeds[3]; + +void speedControlInit(void); +void sc_setRefSpeed(uint8_t motor, int speed); +int sc_getRealSpeed(uint8_t motor); +uint16_t sc_getPosition(uint8_t motor); + +#endif hooks/post-receive -- krobot |
From: Xavier L. <Ba...@us...> - 2010-04-19 16:52:05
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 5f90539cdc0f9083a613e7004fa441489a337190 (commit) via b6abcec288e34444de858b5279f2f8915c8cff4d (commit) from 1256ef0e489d201041ef5b9adab1b329cff3ef21 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 5f90539cdc0f9083a613e7004fa441489a337190 Author: Xavier Lagorce <Xav...@cr...> Date: Mon Apr 19 18:40:24 2010 +0200 Initial import of KrobotJr motherboard's Firmware Following last advances in krobot-ressources, this firmware is using ChibiOS/RT to provide multi-task operations on the STM32 ARM. Are implemented in this version : - Blinky "I'm alive" LED - Command shell on the Serial COM (8N1 - 38400 bauds) - H-Bridge control using semi-soft PWMs - Encoder Interface to read motor positions Present but not working - CPU Load computation The shell provides several commands to control the motherboard (use minicom or hyperterminal) : - help : list all commands - bonjour : say hello to the board - get : get motor positions - reset : reset one or more motor positions - motorEnable : enable/disable one or more H-bridge command - setSpeed : set one or more motor speed - load : get CPU load (not functional) The code is contained in several files and should be easy enough to understand. commit b6abcec288e34444de858b5279f2f8915c8cff4d Author: Xavier Lagorce <Xav...@cr...> Date: Mon Apr 19 18:39:11 2010 +0200 Ignore more file types ----------------------------------------------------------------------- Changes: diff --git a/.gitignore b/.gitignore index 8b505df..762d07b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,13 @@ *.cod *.lst *.err +*.o +*.bin +*.map +*.elf +*.a +*.fw +*.lst +*.dmp +*.hex +*.o.d diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/Makefile b/elec/boards/MotherBoard_KrobotJr2010/Firmware/Makefile new file mode 100644 index 0000000..1b61e32 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/Makefile @@ -0,0 +1,213 @@ +############################################################################## +# Build global options +# NOTE: Can be overridden externally. +# + +# Compiler options here. +ifeq ($(USE_OPT),) + USE_OPT = -O2 -ggdb -fomit-frame-pointer -mabi=apcs-gnu -falign-functions=16 +endif + +# C++ specific options here (added to USE_OPT). +ifeq ($(USE_CPPOPT),) + USE_CPPOPT = -fno-rtti +endif + +# Enable this if you want the linker to remove unused code and data +ifeq ($(USE_LINK_GC),) + USE_LINK_GC = yes +endif + +# If enabled, this option allows to compile the application in THUMB mode. +ifeq ($(USE_THUMB),) + USE_THUMB = yes +endif + +# Enable register caching optimization (read documentation). +ifeq ($(USE_CURRP_CACHING),) + USE_CURRP_CACHING = no +endif + +# +# Build global options +############################################################################## + +############################################################################## +# Architecture or project specific options +# + +# Enable this if you really want to use the STM FWLib. +ifeq ($(USE_FWLIB),) + USE_FWLIB = yes +endif + +# +# Architecture or project specific options +############################################################################## + +############################################################################## +# Project, sources and paths +# + +# Define project name here +PROJECT = krobotJr + +# Define linker script file here +LDSCRIPT= ch.ld + +# Imported source files +CHIBIOS = chibios +include $(CHIBIOS)/boards/OLIMEX_STM32_P103/board.mk +include $(CHIBIOS)/os/hal/platforms/STM32/platform.mk +include $(CHIBIOS)/os/hal/hal.mk +include $(CHIBIOS)/os/ports/GCC/ARMCM3/port.mk +include $(CHIBIOS)/os/kernel/kernel.mk +include $(CHIBIOS)/test/test.mk +include $(CHIBIOS)/ext/fatfs/fatfs.mk + +# C sources that can be compiled in ARM or THUMB mode depending on the global +# setting. +CSRC = $(PORTSRC) +CSRC += $(KERNSRC) +#CSRC += $(TESTSRC) +CSRC += $(HALSRC) +CSRC += $(PLATFORMSRC) +CSRC += $(BOARDSRC) +#CSRC += $(FATFSSRC) +CSRC += $(CHIBIOS)/os/various/evtimer.c +CSRC += $(CHIBIOS)/os/various/syscalls.c +CSRC += $(CHIBIOS)/os/various/shell.c +CSRC += monitor.c +CSRC += encoder.c +CSRC += motor.c +CSRC += cpu_load.c +CSRC += main.c + +# C++ sources that can be compiled in ARM or THUMB mode depending on the global +# setting. +CPPSRC = + +# C sources to be compiled in ARM mode regardless of the global setting. +# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler +# option that results in lower performance and larger code size. +ACSRC = + +# C++ sources to be compiled in ARM mode regardless of the global setting. +# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler +# option that results in lower performance and larger code size. +ACPPSRC = + +# C sources to be compiled in THUMB mode regardless of the global setting. +# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler +# option that results in lower performance and larger code size. +TCSRC = + +# C sources to be compiled in THUMB mode regardless of the global setting. +# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler +# option that results in lower performance and larger code size. +TCPPSRC = + +# List ASM source files here +ASMSRC = $(PORTASM) \ + $(CHIBIOS)/os/ports/GCC/ARMCM3/STM32F103/vectors.s + +INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ + $(HALINC) $(PLATFORMINC) $(BOARDINC) \ + $(FATFSINC) \ + $(CHIBIOS)/os/various + +# +# Project, sources and paths +############################################################################## + +############################################################################## +# Compiler settings +# + +MCU = cortex-m3 + +TRGT = arm-none-eabi- +CC = $(TRGT)gcc +CPPC = $(TRGT)g++ +# Enable loading with g++ only if you need C++ runtime support. +# NOTE: You can use C++ even without C++ support if you are careful. C++ +# runtime support makes code size explode. +LD = $(TRGT)gcc +#LD = $(TRGT)g++ +CP = $(TRGT)objcopy +AS = $(TRGT)gcc -x assembler-with-cpp +OD = $(TRGT)objdump +HEX = $(CP) -O ihex +BIN = $(CP) -O binary + +# ARM-specific options here +AOPT = + +# THUMB-specific options here +TOPT = -mthumb -DTHUMB + +# Define C warning options here +CWARN = -Wall -Wextra -Wstrict-prototypes + +# Define C++ warning options here +CPPWARN = -Wall -Wextra + +# +# Compiler settings +############################################################################## + +############################################################################## +# Start of default section +# + +# List all default C defines here, like -D_DEBUG=1 +DDEFS = -DSTDOUT_SD=SD2 -DSTDIN_SD=SD2 + +# List all default ASM defines here, like -D_DEBUG=1 +DADEFS = + +# List all default directories to look for include files here +DINCDIR = + +# List the default directory to look for the libraries here +DLIBDIR = + +# List all default libraries here +DLIBS = + +# +# End of default section +############################################################################## + +############################################################################## +# Start of user section +# + +# List all user C define here, like -D_DEBUG=1 +UDEFS = + +# Define ASM defines here +UADEFS = + +# List all user directories here +UINCDIR = + +# List the user directory to look for the libraries here +ULIBDIR = + +# List all user libraries here +ULIBS = + +# +# End of user defines +############################################################################## + +ifeq ($(USE_FWLIB),yes) + include $(CHIBIOS)/ext/stm32lib/stm32lib.mk + CSRC += $(STM32SRC) + INCDIR += $(STM32INC) + USE_OPT += -DUSE_STDPERIPH_DRIVER +endif + +include $(CHIBIOS)/os/ports/GCC/ARM/rules.mk +include jtag/flash.mk diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/ch.ld b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ch.ld new file mode 100644 index 0000000..196da88 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/ch.ld @@ -0,0 +1,101 @@ +/* + ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +/* + * ST32F103 memory setup. + */ +__main_stack_size__ = 0x0400; +__process_stack_size__ = 0x0400; +__stacks_total_size__ = __main_stack_size__ + __process_stack_size__; + +MEMORY +{ + flash : org = 0x08000000, len = 128k + ram : org = 0x20000000, len = 20k +} + +__ram_start__ = ORIGIN(ram); +__ram_size__ = LENGTH(ram); +__ram_end__ = __ram_start__ + __ram_size__; + +SECTIONS +{ + . = 0; + + .text : ALIGN(16) SUBALIGN(16) + { + _text = .; + KEEP(*(vectors)); + *(.text) + *(.text.*); + *(.rodata); + *(.rodata.*); + *(.glue_7t); + *(.glue_7); + *(.gcc*); + *(.ctors); + *(.dtors); + . = ALIGN(4); + _etext = .; + } > flash + + _textdata = _etext; + + .data : + { + _data = .; + *(.data) + . = ALIGN(4); + *(.data.*) + . = ALIGN(4); + *(.ramtext) + . = ALIGN(4); + _edata = .; + } > ram AT > flash + + .bss : + { + _bss_start = .; + *(.bss) + . = ALIGN(4); + *(.bss.*) + . = ALIGN(4); + *(COMMON) + . = ALIGN(4); + _bss_end = .; + } > ram + + /DISCARD/ : + { + *(.eh_*) + } +} + +PROVIDE(end = .); +_end = .; + +__heap_base__ = _end; +__heap_end__ = __ram_end__ - __stacks_total_size__; diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chconf.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chconf.h new file mode 100644 index 0000000..c4f536c --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chconf.h @@ -0,0 +1,471 @@ +/* + ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +/** + * @file templates/chconf.h + * @brief Configuration file template. + * @addtogroup config + * @{ + */ + +#ifndef _CHCONF_H_ +#define _CHCONF_H_ + +/*===========================================================================*/ +/* Kernel parameters. */ +/*===========================================================================*/ + +/** + * @brief System tick frequency. + * @details Frequency of the system timer that drives the system ticks. This + * setting also defines the system tick time unit. + */ +#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__) +#define CH_FREQUENCY 1000 +#endif + +/** + * @brief Round robin interval. + * @details This constant is the number of system ticks allowed for the + * threads before preemption occurs. Setting this value to zero + * disables the round robin mechanism. + * + * @note Disabling round robin makes the kernel more compact and generally + * faster but forbids multiple threads at the same priority level. + */ +#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__) +#define CH_TIME_QUANTUM 20 +#endif + +/** + * @brief Nested locks. + * @details If enabled then the use of nested @p chSysLock() / @p chSysUnlock() + * operations is allowed.<br> + * For performance and code size reasons the recommended setting + * is to leave this option disabled.<br> + * You may use this option if you need to merge ChibiOS/RT with + * external libraries that require nested lock/unlock operations. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__) +#define CH_USE_NESTED_LOCKS FALSE +#endif + +/** + * @brief Managed RAM size. + * @details Size of the RAM area to be managed by the OS. If set to zero + * then the whole available RAM is used. The core memory is made + * available to the heap allocator and/or can be used directly through + * the simplified core memory allocator. + * + * @note In order to let the OS manage the whole RAM the linker script must + * provide the @p __heap_base__ and @p __heap_end__ symbols. + * @note Requires @p CH_USE_COREMEM. + */ +#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__) +#define CH_MEMCORE_SIZE 0 +#endif + +/*===========================================================================*/ +/* Performance options. */ +/*===========================================================================*/ + +/** + * @brief OS optimization. + * @details If enabled then time efficient rather than space efficient code + * is used when two possible implementations exist. + * + * @note This is not related to the compiler optimization options. + * @note The default is @p TRUE. + */ +#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__) +#define CH_OPTIMIZE_SPEED TRUE +#endif + +/** + * @brief Exotic optimization. + * @details If defined then a CPU register is used as storage for the global + * @p currp variable. Caching this variable in a register greatly + * improves both space and time OS efficiency. A side effect is that + * one less register has to be saved during the context switch + * resulting in lower RAM usage and faster context switch. + * + * @note This option is only usable with the GCC compiler and is only useful + * on processors with many registers like ARM cores. + * @note If this option is enabled then ALL the libraries linked to the + * ChibiOS/RT code <b>must</b> be recompiled with the GCC option @p + * -ffixed-@<reg@>. + * @note This option must be enabled in the Makefile, it is listed here for + * documentation only. + */ +#if defined(__DOXYGEN__) +#define CH_CURRP_REGISTER_CACHE "reg" +#endif + +/*===========================================================================*/ +/* Subsystem options. */ +/*===========================================================================*/ + +/** + * @brief Threads synchronization APIs. + * @details If enabled then the @p chThdWait() function is included in + * the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__) +#define CH_USE_WAITEXIT TRUE +#endif + +/** + * @brief Semaphores APIs. + * @details If enabled then the Semaphores APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__) +#define CH_USE_SEMAPHORES TRUE +#endif + +/** + * @brief Semaphores queuing mode. + * @details If enabled then the threads are enqueued on semaphores by + * priority rather than in FIFO order. + * + * @note The default is @p FALSE. Enable this if you have special requirements. + * @note Requires @p CH_USE_SEMAPHORES. + */ +#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__) +#define CH_USE_SEMAPHORES_PRIORITY FALSE +#endif + +/** + * @brief Atomic semaphore API. + * @details If enabled then the semaphores the @p chSemWaitSignal() API + * is included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_SEMAPHORES. + */ +#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__) +#define CH_USE_SEMSW TRUE +#endif + +/** + * @brief Mutexes APIs. + * @details If enabled then the mutexes APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__) +#define CH_USE_MUTEXES TRUE +#endif + +/** + * @brief Conditional Variables APIs. + * @details If enabled then the conditional variables APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_MUTEXES. + */ +#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__) +#define CH_USE_CONDVARS TRUE +#endif + +/** + * @brief Conditional Variables APIs with timeout. + * @details If enabled then the conditional variables APIs with timeout + * specification are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_CONDVARS. + */ +#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__) +#define CH_USE_CONDVARS_TIMEOUT TRUE +#endif + +/** + * @brief Events Flags APIs. + * @details If enabled then the event flags APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__) +#define CH_USE_EVENTS TRUE +#endif + +/** + * @brief Events Flags APIs with timeout. + * @details If enabled then the events APIs with timeout specification + * are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_EVENTS. + */ +#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__) +#define CH_USE_EVENTS_TIMEOUT TRUE +#endif + +/** + * @brief Synchronous Messages APIs. + * @details If enabled then the synchronous messages APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__) +#define CH_USE_MESSAGES TRUE +#endif + +/** + * @brief Synchronous Messages queuing mode. + * @details If enabled then messages are served by priority rather than in + * FIFO order. + * + * @note The default is @p FALSE. Enable this if you have special requirements. + * @note Requires @p CH_USE_MESSAGES. + */ +#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__) +#define CH_USE_MESSAGES_PRIORITY FALSE +#endif + +/** + * @brief Mailboxes APIs. + * @details If enabled then the asynchronous messages (mailboxes) APIs are + * included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_SEMAPHORES. + */ +#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__) +#define CH_USE_MAILBOXES TRUE +#endif + +/** + * @brief I/O Queues APIs. + * @details If enabled then the I/O queues APIs are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_SEMAPHORES. + */ +#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__) +#define CH_USE_QUEUES TRUE +#endif + +/** + * @brief Core Memory Manager APIs. + * @details If enabled then the core memory manager APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__) +#define CH_USE_MEMCORE TRUE +#endif + +/** + * @brief Heap Allocator APIs. + * @details If enabled then the memory heap allocator APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_COREMEM and either @p CH_USE_MUTEXES or + * @p CH_USE_SEMAPHORES. + * @note Mutexes are recommended. + */ +#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__) +#define CH_USE_HEAP TRUE +#endif + +/** + * @brief C-runtime allocator. + * @details If enabled the the heap allocator APIs just wrap the C-runtime + * @p malloc() and @p free() functions. + * + * @note The default is @p FALSE. + * @note Requires @p CH_USE_HEAP. + * @note The C-runtime may or may not require @p CH_USE_COREMEM, see the + * appropriate documentation. + */ +#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) +#define CH_USE_MALLOC_HEAP FALSE +#endif + +/** + * @brief Memory Pools Allocator APIs. + * @details If enabled then the memory pools allocator APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__) +#define CH_USE_MEMPOOLS TRUE +#endif + +/** + * @brief Dynamic Threads APIs. + * @details If enabled then the dynamic threads creation APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_USE_WAITEXIT. + */ +#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__) +#define CH_USE_DYNAMIC TRUE +#endif + +/*===========================================================================*/ +/* Debug options. */ +/*===========================================================================*/ + +/** + * @brief Debug option, parameters checks. + * @details If enabled then the checks on the API functions input + * parameters are activated. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__) +#define CH_DBG_ENABLE_CHECKS FALSE +#endif + +/** + * @brief Debug option, consistency checks. + * @details If enabled then all the assertions in the kernel code are + * activated. This includes consistency checks inside the kernel, + * runtime anomalies and port-defined checks. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__) +#define CH_DBG_ENABLE_ASSERTS FALSE +#endif + +/** + * @brief Debug option, trace buffer. + * @details If enabled then the context switch circular trace buffer is + * activated. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__) +#define CH_DBG_ENABLE_TRACE FALSE +#endif + +/** + * @brief Debug option, stack checks. + * @details If enabled then a runtime stack check is performed. + * + * @note The default is @p FALSE. + * @note The stack check is performed in a architecture/port dependent way. It + * may not be implemented or some ports. + */ +#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__) +#define CH_DBG_ENABLE_STACK_CHECK FALSE +#endif + +/** + * @brief Debug option, stacks initialization. + * @details If enabled then the threads working area is filled with a byte + * value when a thread is created. This can be useful for the + * runtime measurement of the used stack. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__) +#define CH_DBG_FILL_THREADS FALSE +#endif + +/** + * @brief Debug option, threads profiling. + * @details If enabled then a field is added to the @p Thread structure that + * counts the system ticks occurred while executing the thread. + * + * @note The default is @p TRUE. + * @note This debug option is defaulted to TRUE because it is required by + * some test cases into the test suite. + */ +#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__) +#define CH_DBG_THREADS_PROFILING TRUE +#endif + +/*===========================================================================*/ +/* Kernel hooks. */ +/*===========================================================================*/ + +/** + * @brief Threads descriptor structure hook. + * @details User fields added to the end of the @p Thread structure. + */ +#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__) +#define THREAD_EXT_FIELDS \ +struct { \ + /* Add threads custom fields here.*/ \ +}; +#endif + +/** + * @brief Threads initialization hook. + * @details User initialization code added to the @p chThdInit() API. + * + * @note It is invoked from within @p chThdInit() and implicitily from all + * the threads creation APIs. + */ +#if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__) +#define THREAD_EXT_INIT(tp) { \ + /* Add threads initialization code here.*/ \ +} +#endif + +/** + * @brief Threads finalization hook. + * @details User finalization code added to the @p chThdExit() API. + * + * @note It is inserted into lock zone. + * @note It is also invoked when the threads simply return in order to + * terminate. + */ +#if !defined(THREAD_EXT_EXIT) || defined(__DOXYGEN__) +#define THREAD_EXT_EXIT(tp) { \ + /* Add threads finalization code here.*/ \ +} +#endif + +/** + * @brief Idle Loop hook. + * @details This hook is continuously invoked by the idle thread loop. + */ +#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__) +#define IDLE_LOOP_HOOK() { \ + /* Idle loop code here.*/ \ +} +#endif + +#endif /* _CHCONF_H_ */ + +/** @} */ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.c new file mode 100644 index 0000000..e7b8fca --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.c @@ -0,0 +1,91 @@ +/* + ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +#include "ch.h" +#include "hal.h" + +CH_IRQ_HANDLER(TIMER0_COMP_vect) { + + CH_IRQ_PROLOGUE(); + + chSysLockFromIsr(); + chSysTimerHandlerI(); + chSysUnlockFromIsr(); + + CH_IRQ_EPILOGUE(); +} + +/* + * Board initialization code. + */ +void hwinit(void) { + + /* + * I/O ports setup. + */ + DDRA = VAL_DDRA; + PORTA = VAL_PORTA; + DDRB = VAL_DDRB; + PORTB = VAL_PORTB; + DDRC = VAL_DDRC; + PORTC = VAL_PORTC; + DDRD = VAL_DDRD; + PORTD = VAL_PORTD; + DDRE = VAL_DDRE; + PORTE = VAL_PORTE; + DDRF = VAL_DDRF; + PORTF = VAL_PORTF; + DDRG = VAL_DDRG; + PORTG = VAL_PORTG; + + /* + * External interrupts setup, all disabled initially. + */ + EICRA = 0x00; + EICRB = 0x00; + EIMSK = 0x00; + + /* + * Enables Idle mode for SLEEP instruction. + */ + SMCR = (1 << SE); + + /* + * Timer 0 setup. + */ + TCCR0A = (1 << WGM01) | (0 << WGM00) | /* CTC mode. */ + (0 << COM0A1) | (0 << COM0A0) | /* OC0A disabled. */ + (0 << CS02) | (1 << CS01) | (1 << CS00); /* CLK/64 clock. */ + OCR0A = F_CPU / 64 / CH_FREQUENCY - 1; + TCNT0 = 0; /* Reset counter. */ + TIFR0 = (1 << OCF0A); /* Reset pending. */ + TIMSK0 = (1 << OCIE0A); /* IRQ on compare. */ + + /* + * HAL initialization. + */ + halInit(); +} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.h new file mode 100644 index 0000000..e1667f5 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.h @@ -0,0 +1,106 @@ +/* + ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +#ifndef _BOARD_H_ +#define _BOARD_H_ + +/* + * Setup for the Olimex LCP-P2148 proto board. + */ + +/* + * Board identifier. + */ +#define BOARD_OLIMEX_AVR_CAN + +/* + * All inputs with pullups. + */ +#define VAL_DDRA 0x00 +#define VAL_PORTA 0xFF + +/* + * All inputs with pullups. + */ +#define VAL_DDRB 0x00 +#define VAL_PORTB 0xFF + +/* + * All inputs with pullups. + */ +#define VAL_DDRC 0x00 +#define VAL_PORTC 0xFF + +/* PD7 PD6 PD5 PD4 PD3 PD2 PD1 PD0 + * IN IN OUT IN OUT IN IN IN + * DDRD 0 0 1 0 1 0 0 0 + * PU HiZ VAL PU VAL HiZ HiZ HiZ + * PORTD 1 0 ?1 1 1 0 0 0 + */ +#define VAL_DDRD 0x28 +#define VAL_PORTD 0xB8 + +/* PE7 PE6 BUT LED PE3 PE2 PE1 PE0 + * IN IN IN OUT IN IN OUT IN + * DDRE 0 0 0 1 0 0 1 0 + * PU PU HiZ VAL PU PU VAL HiZ + * PORTE 1 1 0 1 1 1 1 0 + */ +#define VAL_DDRE 0x12 +#define VAL_PORTE 0xDE + +/* TDI TDO TMS TCK PF3 PF2 PF1 PF0 + * x x x x IN IN IN IN + * DDRF 0 0 0 0 0 0 0 0 + * x x x x PU PU PU PU + * PORTF 0 0 0 0 1 1 1 1 + * + */ +#define VAL_DDRF 0x00 +#define VAL_PORTF 0x0F + +/* x x x x x PG2 PG1 PG0 + * x x x x x IN IN IN + * DDRG 0 0 0 0 0 0 0 0 + * x x x x x PU PU PU + * PORTG 0 0 0 0 0 1 1 1 + * + */ +#define VAL_DDRG 0x00 +#define VAL_PORTG 0x07 + +#define PORTE_LED (1 << 4) +#define PORTE_BUTTON (1 << 5) + +#ifdef __cplusplus +extern "C" { +#endif + void hwinit(void); +#ifdef __cplusplus +} +#endif + +#endif /* _BOARD_H_ */ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.mk b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.mk new file mode 100644 index 0000000..4d2d406 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_CAN/board.mk @@ -0,0 +1,5 @@ +# List of all the board related files. +BOARDSRC = ${CHIBIOS}/boards/OLIMEX_AVR_CAN/board.c + +# Required include directories +BOARDINC = ${CHIBIOS}/boards/OLIMEX_AVR_CAN diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.c new file mode 100644 index 0000000..c8f5f1b --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.c @@ -0,0 +1,91 @@ +/* + ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +#include "ch.h" +#include "hal.h" + +CH_IRQ_HANDLER(TIMER0_COMP_vect) { + + CH_IRQ_PROLOGUE(); + + chSysLockFromIsr(); + chSysTimerHandlerI(); + chSysUnlockFromIsr(); + + CH_IRQ_EPILOGUE(); +} + +/* + * Board initialization code. + */ +void hwinit(void) { + + /* + * I/O ports setup. + */ + DDRA = VAL_DDRA; + PORTA = VAL_PORTA; + DDRB = VAL_DDRB; + PORTB = VAL_PORTB; + DDRC = VAL_DDRC; + PORTC = VAL_PORTC; + DDRD = VAL_DDRD; + PORTD = VAL_PORTD; + DDRE = VAL_DDRE; + PORTE = VAL_PORTE; + DDRF = VAL_DDRF; + PORTF = VAL_PORTF; + DDRG = VAL_DDRG; + PORTG = VAL_PORTG; + + /* + * External interrupts setup, all disabled initially. + */ + EICRA = 0x00; + EICRB = 0x00; + EIMSK = 0x00; + + /* + * Enables Idle mode for SLEEP instruction. + */ + MCUCR = (1 << SE); + + /* + * Timer 0 setup. + */ + TCCR0 = (1 << WGM01) | (0 << WGM00) | /* CTC mode. */ + (0 << COM01) | (0 << COM00) | /* OC0A disabled. */ + (1 << CS02) | (0 << CS01) | (0 << CS00); /* CLK/64 clock. */ + OCR0 = F_CPU / 64 / CH_FREQUENCY - 1; + TCNT0 = 0; /* Reset counter. */ + TIFR = (1 << OCF0); /* Reset pending. */ + TIMSK = (1 << OCIE0); /* IRQ on compare. */ + + /* + * HAL initialization. + */ + halInit(); +} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.h new file mode 100644 index 0000000..c574410 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.h @@ -0,0 +1,130 @@ +/* + ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +#ifndef _BOARD_H_ +#define _BOARD_H_ + +/* + * Setup for the Olimex LCP-P2148 proto board. + */ + +/* + * Board identifier. + */ +#define BOARD_OLIMEX_AVR_MT_128 + +/* PA7 RLY DS B5 B4 B3 B2 B1 + * IN OUT IN IN IN IN IN IN + * DDRA 0 1 0 0 0 0 0 0 + * PU VAL HiZ HiZ HiZ HiZ HiZ HiZ + * PORTA 1 0 0 0 0 0 0 0 + */ +#define VAL_DDRA 0x40 +#define VAL_PORTA 0x80 + +/* + * All inputs with pullups. + */ +#define VAL_DDRB 0x00 +#define VAL_PORTB 0xFF + +/* D7 D6 D5 D4 PC3 E R/W RS + * OUT OUT OUT OUT IN OUT OUT OUT + * DDRC 1 1 1 1 0 1 1 1 + * PU PU PU PU PU VAL VAL VAL + * PORTC 0 0 0 0 1 0 0 0 + */ +#define VAL_DDRC 0xF7 +#define VAL_PORTC 0x08 + +/* PD7 PD6 PD5 PD4 TXD RXD PD1 PD0 + * IN IN IN IN OUT IN IN IN + * DDRD 0 0 0 0 1 0 0 0 + * PU PU PU PU VAL HiZ PU PU + * PORTD 1 1 1 1 1 0 1 1 + */ +#define VAL_DDRD 0x08 +#define VAL_PORTD 0xFB + +/* PE7 PE6 BZ2 BZ2 PE3 PE2 PE1 PE0 + * IN IN OUT OUT IN IN OUT IN + * DDRE 0 0 1 1 0 0 1 0 + * PU PU VAL VAL PU PU VAL PU + * PORTE 1 1 1 1 1 1 1 1 + */ +#define VAL_DDRE 0x32 +#define VAL_PORTE 0xFF + +/* TDI TDO TMS TCK PF3 PF2 PF1 PF0 + * x x x x IN IN IN IN + * DDRF 0 0 0 0 0 0 0 0 + * x x x x PU PU PU PU + * PORTF 0 0 0 0 1 1 1 1 + * + */ +#define VAL_DDRF 0x00 +#define VAL_PORTF 0x0F + +/* x x x x x PG2 PG1 PG0 + * x x x x x IN IN IN + * DDRG 0 0 0 0 0 0 0 0 + * x x x x x PU PU PU + * PORTG 0 0 0 0 0 1 1 1 + * + */ +#define VAL_DDRG 0x00 +#define VAL_PORTG 0x07 + +#define PORTA_BUTTON1 (1 << 0) +#define PORTA_BUTTON2 (1 << 1) +#define PORTA_BUTTON3 (1 << 2) +#define PORTA_BUTTON4 (1 << 3) +#define PORTA_BUTTON5 (1 << 4) +#define PORTA_DALLAS (1 << 5) +#define PORTA_RELAY (1 << 6) + +#define PORTC_44780_RS (1 << 0) +#define PORTC_44780_RW (1 << 1) +#define PORTC_44780_E (1 << 2) +#define PORTC_44780_D4 (1 << 4) +#define PORTC_44780_D5 (1 << 5) +#define PORTC_44780_D6 (1 << 6) +#define PORTC_44780_D7 (1 << 7) +#define PORTC_44780_DATA (PORTC_44780_D4 | PORTC_44780_D5 | \ + PORTC_44780_D6 | PORTC_44780_D7) + +#define PORTE_BUZZ1 (1 << 4) +#define PORTE_BUZZ2 (1 << 5) + +#ifdef __cplusplus +extern "C" { +#endif + void hwinit(void); +#ifdef __cplusplus +} +#endif + +#endif /* _BOARD_H_ */ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.mk b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.mk new file mode 100644 index 0000000..7b903ff --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_AVR_MT_128/board.mk @@ -0,0 +1,5 @@ +# List of all the board related files. +BOARDSRC = ${CHIBIOS}/boards/OLIMEX_AVR_MT_128/board.c + +# Required include directories +BOARDINC = ${CHIBIOS}/boards/OLIMEX_AVR_MT_128 diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.c new file mode 100644 index 0000000..c0cb482 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.c @@ -0,0 +1,86 @@ +/* + ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +#include "ch.h" +#include "hal.h" + +#define VAL_TC0_PRESCALER 0 + +/* + * Timer 0 IRQ handling here. + */ +static CH_IRQ_HANDLER(T0IrqHandler) { + + CH_IRQ_PROLOGUE(); + T0IR = 1; /* Clear interrupt on match MR0. */ + + chSysLockFromIsr(); + chSysTimerHandlerI(); + chSysUnlockFromIsr(); + + VICVectAddr = 0; + CH_IRQ_EPILOGUE(); +} + +/* + * Early initialization code. + * This initialization is performed just after reset before BSS and DATA + * segments initialization. + */ +void hwinit0(void) { + + lpc214x_clock_init(); +} + +/* + * Late initialization code. + * This initialization is performed after BSS and DATA segments initialization + * and before invoking the main() function. + */ +void hwinit1(void) { + + /* + * HAL initialization. + */ + halInit(); + + /* + * System Timer initialization, 1ms intervals. + */ + SetVICVector(T0IrqHandler, 0, SOURCE_Timer0); + VICIntEnable = INTMASK(SOURCE_Timer0); + TC *timer = T0Base; + timer->TC_PR = VAL_TC0_PRESCALER; + timer->TC_MR0 = (PCLK / CH_FREQUENCY) / (VAL_TC0_PRESCALER + 1); + timer->TC_MCR = 3; /* Interrupt and clear TC on match MR0. */ + timer->TC_TCR = 2; /* Reset counter and prescaler. */ + timer->TC_TCR = 1; /* Timer enabled. */ + + /* + * ChibiOS/RT initialization. + */ + chSysInit(); +} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.h new file mode 100644 index 0000000..5dfab1a --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.h @@ -0,0 +1,91 @@ +/* + ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +#ifndef _BOARD_H_ +#define _BOARD_H_ + +/* + * Setup for the Olimex LCP-P2148 proto board. + */ + +/* + * Board identifier. + */ +#define BOARD_OLIMEX_LCP_P2148 + +/* + * The following values are implementation dependent. You may change them in + * order to match your HW. + */ +#define FOSC 12000000 +#define CCLK 48000000 +#define PCLK 12000000 + +/* + * Pins configuration for Olimex LPC-P2148. + * + * PINSEL0 + * P0 P0 P0 P0 P0 P0 RXD TXD SSE MOS MIS SCK SDA SCL RXD TXD + * 15 14 13 12 11 10 1 1 L0 I0 O0 0 0 0 0 0 + * 00 00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 + * FIO0DIR (15...0) + * IN IN OUT OUT OUT OUT -- -- -- -- -- -- -- -- -- -- + * 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + * + * PINSEL1 + * P0 AD P0 P0 -- -- AO -- VB P0 P0 P0 MOS MIS SCK P0 + * 31 03 29 28 -- -- UT -- US 22 21 20 I1 O1 1 16 + * 00 01 00 00 00 00 10 00 01 00 00 00 10 10 10 00 + * FIO0DIR (31...16) + * OUT -- OUT OUT -- -- -- -- -- OUT OUT OUT -- -- -- IN + * 1 0 1 1 0 0 0 0 0 1 1 1 0 0 0 0 + * + * FIO1DIR (31...16) + * -- -- -- -- -- IN IN OUT OUT OUT OUT OUT OUT OUT OUT OUT + * 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 + */ +#define VAL_PINSEL0 0x00055555 +#define VAL_PINSEL1 0x100840A8 +#define VAL_PINSEL2 0x00000004 /* Do not modify */ +#define VAL_FIO0DIR 0xB0703C00 +#define VAL_FIO1DIR 0x01FF0000 +#define VAL_FIO0PIN 0xFFFFFFFF +#define VAL_FIO1PIN 0xFFFFFFFF + +#define PA_LED1 10 +#define PA_LED2 11 +#define PA_BUZZ1 12 +#define PA_BUZZ2 13 +#define PA_BSL 14 +#define PA_BUTTON1 15 +#define PA_BUTTON2 16 +#define PA_SSEL1 20 +#define PA_LEDUSB 31 + +#define PB_WP1 24 +#define PB_CP1 25 + +#endif /* _BOARD_H_ */ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.mk b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.mk new file mode 100644 index 0000000..d41ed5d --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/board.mk @@ -0,0 +1,8 @@ +# Board directory path +BOARDPATH = ${CHIBIOS}/boards/OLIMEX_LPC_P2148/ + +# List of all the mandatory board related files. +BOARDSRC = ${BOARDPATH}/board.c + +# Required include directories +BOARDINC = ${BOARDPATH} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.c new file mode 100644 index 0000000..32b808e --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.c @@ -0,0 +1,119 @@ +/* + ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +/* + * Buzzer driver for Olimex LPC-P2148. + * Uses the timer 1 for wave generation and a Virtual Timer for the sound + * duration. + * The driver also generates an event when the sound is done and the buzzer + * goes silent. + */ + +#include "ch.h" +#include "hal.h" + +#include "buzzer.h" + +EventSource BuzzerSilentEventSource; + +#define StartCounter(t) ((t)->TC_EMR = 0xF1, (t)->TC_TCR = 1) +#define StopCounter(t) ((t)->TC_EMR = 0, (t)->TC_TCR = 2) + +/** + * @brief Buzzer driver initialization. + */ +void buzzInit(void) { + + chEvtInit(&BuzzerSilentEventSource); + + /* + * Switches P0.12 and P0.13 to MAT1.0 and MAT1.1 functions. + * Enables Timer1 clock. + */ + PINSEL0 &= 0xF0FFFFFF; + PINSEL0 |= 0x0A000000; + PCONP = (PCONP & PCALL) | PCTIM1; + + /* + * Timer setup. + */ + TC *tc = T1Base; + StopCounter(tc); + tc->TC_CTCR = 0; /* Clock source is PCLK. */ + tc->TC_PR = 0; /* Prescaler disabled. */ + tc->TC_MCR = 2; /* Clear TC on match MR0. */ +} + +/** + * @brief Stops the sound. + * + * @param[in] p pointer to the timer + */ +static void stop(void *p) { + + StopCounter((TC *)p); + chEvtBroadcastI(&BuzzerSilentEventSource); +} + +/** + * @brief Plays a tone asynchronously. + * + * @param[in] freq approximated tone frequency + * @param[in] duration tone duration in systicks + */ +void buzzPlay(uint32_t freq, systime_t duration) { + static VirtualTimer bvt; + TC *tc = T1Base; + + chSysLock(); + + if (chVTIsArmedI(&bvt)) { /* If a sound is already being */ + chVTResetI(&bvt); /* played then aborts it. */ + StopCounter(tc); + } + + tc->TC_MR0 = tc->TC_MR1 = (PCLK / (freq * 2)); + StartCounter(tc); + chVTSetI(&bvt, duration, stop, tc); + + chSysUnlock(); +} + +/** + * @brief Plays a tone. + * + * @param[in] freq approximated tone frequency + * @param[in] duration tone duration in systicks + */ +void buzzPlayWait(uint32_t freq, systime_t duration) { + TC *tc = T1Base; + + StopCounter(tc); + tc->TC_MR0 = tc->TC_MR1 = (PCLK / (freq * 2)); + StartCounter(tc); + chThdSleep(duration); + StopCounter(tc); +} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.h new file mode 100644 index 0000000..1e13aa7 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_LPC_P2148/buzzer.h @@ -0,0 +1,42 @@ +/* + ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +#ifndef _BUZZER_H_ +#define _BUZZER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + void buzzInit(void); + void buzzPlay(uint32_t freq, systime_t duration); + void buzzPlayWait(uint32_t freq, systime_t duration); +#ifdef __cplusplus +} +#endif + +extern EventSource BuzzerSilentEventSource; + +#endif /* _BUZZER_H_ */ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.c new file mode 100644 index 0000000..6504dc0 --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.c @@ -0,0 +1,61 @@ +/* + ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +#include <signal.h> + +#include "ch.h" +#include "hal.h" + +CH_IRQ_HANDLER(TIMERA0_VECTOR) { + + CH_IRQ_PROLOGUE(); + + chSysLockFromIsr(); + chSysTimerHandlerI(); + chSysUnlockFromIsr(); + + CH_IRQ_EPILOGUE(); +} + +/* + * Hardware initialization goes here. + * NOTE: Interrupts are still disabled. + */ +void hwinit(void) { + + /* + * HAL initialization. + */ + halInit(); + + /* + * Timer 0 setup, uses SMCLK as source. + */ + TACCR0 = SMCLK / 4 / CH_FREQUENCY - 1;/* Counter limit. */ + TACTL = TACLR; /* Clean start. */ + TACTL = TASSEL_2 | ID_2 | MC_1; /* Src=SMCLK, ID=4, cmp=TACCR0. */ + TACCTL0 = CCIE; /* Interrupt on compare. */ +} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.h new file mode 100644 index 0000000..0922d9c --- /dev/null +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.h @@ -0,0 +1,87 @@ +/* + ChibiOS/RT - Copyright (C) 2010 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + --- + + A special exception to the GPL can be applied should you wish to distribute + a combined work that includes ChibiOS/RT, without being obliged to provide + the source code for any proprietary components. See the file exception.txt + for full details of how and when the exception can be applied. +*/ + +#ifndef _BOARD_H_ +#define _BOARD_H_ + +/* + * Setup for the Olimex MSP430-P1611 proto board. + */ + +/* + * Board identifier. + */ +#define BOARD_OLIMEX_MSP430_P1611 + +/* + * Clock constants. + */ +#define LFXT1CLK 32768 +#define XT2CLK 8000000 +#define DCOCLK 750000 + +/* + * Pin definitions for the Olimex MSP430-P1611 board. + */ +#define P3_O_TXD0 4 +#define P3_O_TXD0_MASK (1 << P3_O_TXD0) +#define P3_I_RXD0 5 +#define P3_I_RXD0_MASK (1 << P3_I_RXD0) +#define P6_O_LED 0 +#define P6_O_LED_MASK (1 << P6_O_LED) +#define P6_I_BUTTON 1 +#define P6_I_BUTTON_MASK (1 << P6_I_BUTTON) + +/* + * Initial I/O ports settings. + */ +#define VAL_P1OUT 0x00 +#define VAL_P1DIR 0xFF + +#define VAL_P2OUT 0x00 +#define VAL_P2DIR 0xFF + +#define VAL_P3OUT P3_O_TXD0_MASK +#define VAL_P3DIR ~P3_I_RXD0_MASK + +#define VAL_P4OUT 0x00 +#define VAL_P4DIR 0xFF + +#define VAL_P5OUT 0x00 +#define VAL_P5DIR 0xFF + +#define VAL_P6OUT P6_O_LED_MASK +#define VAL_P6DIR ~P6_I_BUTTON_MASK + +#ifdef __cplusplus +extern "C" { +#endif + void hwinit(void); +#ifdef __cplusplus +} +#endif + +#endif /* _BOARD_H_ */ diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.mk b/elec/boards/MotherBoard_KrobotJr2010/Firmware/chibios/boards/OLIMEX_MSP430_P1611/board.mk new file mode 100644 index 0000000..84acad8 --- /dev/null +++ b/elec/boards/MotherBoard_Krobo... [truncated message content] |
From: Jérémie D. <Ba...@us...> - 2010-04-18 14:57:21
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 1256ef0e489d201041ef5b9adab1b329cff3ef21 (commit) via bcd46c2c5803bd50ca3772949f753449837ff805 (commit) from 31edfc54f06d6f388a443d87e3644d1829505f63 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1256ef0e489d201041ef5b9adab1b329cff3ef21 Merge: 31edfc54f06d6f388a443d87e3644d1829505f63 bcd46c2c5803bd50ca3772949f753449837ff805 Author: Jérémie Dimino <dim@gaia.(none)> Date: Sun Apr 18 16:55:44 2010 +0200 Merge commit 'bcd46c2' commit bcd46c2c5803bd50ca3772949f753449837ff805 Author: Jérémie Dimino <dim@gaia.(none)> Date: Sun Apr 18 16:33:13 2010 +0200 update code for the new obus api ----------------------------------------------------------------------- Changes: diff --git a/info/control/Makefile b/info/control/Makefile index bbaf447..fd92830 100644 --- a/info/control/Makefile +++ b/info/control/Makefile @@ -7,7 +7,7 @@ PREFIX := $(HOME) -OC := ocamlbuild -Is common,lib_krobot +OC := ocamlbuild -Is common,protocol,lib-krobot OF := ocamlfind ifeq ($(TERM),dumb) @@ -25,15 +25,15 @@ clean: .PHONY: install install: $(OF) install krobot META \ - lib_krobot/krobot.mli \ - $(wildcard _build/lib_krobot/*.cmi) \ - $(wildcard _build/lib_krobot/*.cmx) \ + lib-krobot/krobot.mli \ + $(wildcard _build/lib-krobot/*.cmi) \ + $(wildcard _build/lib-krobot/*.cmx) \ $(wildcard _build/*.cma) \ $(wildcard _build/*.cmxa) \ $(wildcard _build/*.cmxs) \ $(wildcard _build/*.a) - install -m 0755 _build/card_tools/krobot_send_firmware.best $(PREFIX)/bin/krobot-send-firmware - install -m 0755 _build/card_tools/krobot_dump_memory.best $(PREFIX)/bin/krobot-dump-memory + install -m 0755 _build/card-tools/krobot_send_firmware.best $(PREFIX)/bin/krobot-send-firmware + install -m 0755 _build/card-tools/krobot_dump_memory.best $(PREFIX)/bin/krobot-dump-memory install -m 0755 _build/tools/krobot_forward_dbus.best $(PREFIX)/bin/krobot-forward-dbus install -m 0755 _build/clients/krobot_info.best $(PREFIX)/bin/krobot-info install -m 0755 _build/clients/krobot_joy_control.best $(PREFIX)/bin/krobot-joystick diff --git a/info/control/README b/info/control/README index a595631..c952455 100644 --- a/info/control/README +++ b/info/control/README @@ -1,6 +1,6 @@ Organisation des dossiers: -* "card_tools" contient des outils pour les cartes usb, notamment pour +* "card-tools" contient des outils pour les cartes usb, notamment pour flasher les firmwares * "clients" contient les divers programmes pour monitorer et @@ -11,7 +11,7 @@ Organisation des dossiers: * "driver" contient le driver qui accède au cartes usb -* "lib_krobot" contient la librairie cliente pour utiliser le robot, +* "lib-krobot" contient la librairie cliente pour utiliser le robot, qui se connecte au driver via D-Bus * "services" contient des services tels que l'arrêt des moteurs en cas diff --git a/info/control/_tags b/info/control/_tags index 23ffcf3..937c55b 100644 --- a/info/control/_tags +++ b/info/control/_tags @@ -1,27 +1,30 @@ # -*- conf -*- -"common": include -"lib_krobot": include - # +------------------------------------------------------------------+ # | Krobot library | # +------------------------------------------------------------------+ -<lib_krobot/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log, pkg_obus.syntax -<lib_krobot/**>: pkg_lwt.unix, pkg_obus +<lib-krobot/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log +<lib-krobot/**>: pkg_lwt.unix, pkg_obus + +# +------------------------------------------------------------------+ +# | Protocol | +# +------------------------------------------------------------------+ + +<protocol/krobot_interfaces.*>: pkg_obus # +------------------------------------------------------------------+ # | Card tools | # +------------------------------------------------------------------+ -<card_tools/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log -<card_tools/**>: thread, pkg_usb, pkg_lwt.unix +<card-tools/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log +<card-tools/**>: thread, pkg_usb, pkg_lwt.unix # +------------------------------------------------------------------+ # | Clients | # +------------------------------------------------------------------+ -<clients/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log, pkg_obus.syntax +<clients/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log <clients/**>: pkg_lwt.unix, pkg_obus <clients/krobot_joy_control.*>: pkg_sdl <clients/krobot_controller.*>: pkg_lwt.text @@ -32,14 +35,14 @@ # | Services | # +------------------------------------------------------------------+ -<services/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log, pkg_obus.syntax +<services/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log <services/**>: pkg_lwt.unix, pkg_obus # +------------------------------------------------------------------+ # | Common | # +------------------------------------------------------------------+ -<common/krobot_{types,util}.{ml,mli}>: syntax_camlp4o, pkg_obus.syntax, pkg_lwt.syntax +<common/krobot_{types,util}.{ml,mli}>: syntax_camlp4o, pkg_lwt.syntax <common/krobot_{types,util}.*>: pkg_obus <common/var.*>: pkg_react @@ -47,19 +50,19 @@ # | Driver | # +------------------------------------------------------------------+ -<driver/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log, pkg_obus.syntax +<driver/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log <driver/**>: thread, pkg_lwt.unix, pkg_obus, pkg_usb # +------------------------------------------------------------------+ # | Tools | # +------------------------------------------------------------------+ -<tools/krobot_forward_dbus.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log, pkg_obus.syntax +<tools/krobot_forward_dbus.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log <tools/krobot_forward_dbus.*>: pkg_obus # +------------------------------------------------------------------+ # | Tests | # +------------------------------------------------------------------+ -<tests/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log, pkg_obus.syntax +<tests/**/*.ml>: syntax_camlp4o, pkg_lwt.syntax, pkg_lwt.syntax.log <tests/**>: pkg_lwt.unix, pkg_obus diff --git a/info/control/card-tools/krobot_boardname.mli b/info/control/card-tools/krobot_boardname.mli new file mode 100644 index 0000000..51dc1b5 --- /dev/null +++ b/info/control/card-tools/krobot_boardname.mli @@ -0,0 +1,12 @@ +(* + * krobot_boardname.mli + * -------------------- + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + +val get_board_name : string -> string option + (** [get_board_name dump] recherche dans le [dump] mémoire (peut + être également un fichier .hex chargé) le nom de la carte. *) diff --git a/info/control/card-tools/krobot_boardname.mll b/info/control/card-tools/krobot_boardname.mll new file mode 100644 index 0000000..96b39b6 --- /dev/null +++ b/info/control/card-tools/krobot_boardname.mll @@ -0,0 +1,22 @@ +(* + * krobot_boardname.mll + * -------------------- + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + + +let boardname_regex = ("Carte " | "Robot Interface" | "Battery Monitoring ") [^'\n']+ + +rule boardname = parse + | (boardname_regex as name) '\n' { Some name } + | _ { boardname lexbuf } + | eof { None } + +{ + let get_board_name str = + let lexbuf = Lexing.from_string str in + boardname lexbuf +} diff --git a/info/control/card-tools/krobot_bootloader.ml b/info/control/card-tools/krobot_bootloader.ml new file mode 100644 index 0000000..1deb632 --- /dev/null +++ b/info/control/card-tools/krobot_bootloader.ml @@ -0,0 +1,184 @@ +(* + * krobot_bootloader.ml + * -------------------- + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + +open Lwt +open Lwt_io + +(* Code très inspiré de kard.ml, mais mis à part car le mode de + communication avec la carte est différent (bulk au lieu + d'interrupt). *) + +type t = { + mutable is_open : bool; + (* La carte est-elle ouverte ? *) + + handle : USB.handle; + (* Handle pour le périphérique usb *) + + kernel_active : bool; + (* Est-ce qu'un driver noyau était attaché à la carte avant qu'on + l'utilise ? *) +} + +type error = + | IncompleteWrite of int * int + | IncompleteRead of int * int + | UnexpectedReply of string * string + | WriteError of string * string + +let string_of_error = function + | IncompleteWrite (a, b) -> Printf.sprintf "%d byte(s) written instead of %d" a b + | IncompleteRead (a, b) -> Printf.sprintf "%d byte(s) read instead of %d" a b + | UnexpectedReply (a, b) -> Printf.sprintf "received unexpected reply %S instead of %S" a b + | WriteError (a, b) -> Printf.sprintf "written: %S, read back: %S" a b + +exception Error of error + +let failwith e = fail (Error e) + +let close k = + if k.is_open then begin + lwt _ = USB.release_interface k.handle 0 in + lwt _ = USB.reset_device k.handle in + (*if k.kernel_active then USB.attach_kernel_driver k.handle 0;*) + (*USB.close k.handle;*) + k.is_open <- false; + return () + end else return () + +let open_card () = + let handle = USB.open_device_with + ~vendor_id:PcInterface.usb_vid + ~product_id:PcInterface.usb_pid_bootloader + in + let kernel_active = USB.kernel_driver_active handle 0 in + if kernel_active then USB.detach_kernel_driver handle 0; + lwt _ = USB.set_configuration handle 1 in + lwt _ = USB.claim_interface handle 0 in + let k = { is_open = true; + handle = handle; + kernel_active = kernel_active } in + let _ = Lwt_sequence.add_l (fun _ -> close k) Lwt_main.exit_hooks in + return k + +let header_length = 5 + +let put_message buffer cmd length address data = + let body_length = String.length data in + assert (String.length buffer >= header_length+body_length); + let set i n = buffer.[i] <- char_of_int n in + set 0 cmd; + assert (length < 0x100); + set 1 length; + assert (address <= 0x1000000); + set 2 (address land 0xff); + set 3 ((address lsr 8) land 0xff); + set 4 ((address lsr 16) land 0xff); + String.blit data 0 buffer 5 body_length + +let send_receive_packet k send_buffer send_length receive_buffer receive_length send_delay receive_delay = + let handle = k.handle and endpoint = 1 in + lwt sent = USB.bulk_send ~handle ~endpoint ~timeout:1. send_buffer 0 send_length in + if sent <> send_length then + failwith (IncompleteWrite (sent, send_length)) + else begin + lwt received = USB.bulk_recv ~handle ~endpoint ~timeout:3. receive_buffer 0 receive_length in + if received <> receive_length then + failwith (IncompleteRead (received, receive_length)) + else + return () + end + +let get_flash k ~address ~length = + let response_length = 64 in + let increment = response_length-header_length in + assert (increment < 256); + let send_buffer = String.create header_length in + let receive_buffer = String.create response_length in + let result_buffer = String.create length in + let rec loop offset total_length = + if total_length <= 0 then + return result_buffer + else begin + let length = min increment total_length in + let response_length = length+header_length in + let address = address+offset in + put_message send_buffer PcInterface.read_flash length address ""; + lwt () = send_receive_packet k send_buffer header_length receive_buffer response_length 1. 3. in + let receive_header = String.sub receive_buffer 0 header_length in + if receive_header <> send_buffer then + failwith (UnexpectedReply (receive_header, send_buffer)) + else begin + String.blit receive_buffer header_length result_buffer offset length; + loop (offset+length) (total_length-length); + end + end + in loop 0 length + +let erase_flash k ~address ~length = + let response_length = 1 in + (* les effacements se font par blocs de 64 octets *) + let increment = 64 in + let send_buffer = String.create header_length in + let receive_buffer = String.create response_length in + let rec loop offset total_length = + if total_length <= 0 then + return () + else begin + let address = address+offset in + put_message send_buffer PcInterface.erase_flash 1 address ""; + lwt () = send_receive_packet k send_buffer header_length receive_buffer response_length 1. 5. in + if int_of_char receive_buffer.[0] <> PcInterface.erase_flash then + failwith (UnexpectedReply (receive_buffer, String.make 1 (char_of_int PcInterface.erase_flash))) + else + loop (offset+increment) (total_length-increment); + end + in loop 0 length + +let reference = String.make 16 '\255' + +let write_flash k ~address data offset length = + let send_length = 64 and receive_length = 1 in + (* les écritures se font par blocs de 16 octets *) + let increment = 16 in + let send_buffer = String.create send_length in + let receive_buffer = String.create receive_length in + let rec loop address offset total_length = + (* address: sur le PIC, offset: dans data, total_length: taille restante *) + if total_length <= 0 then + return () + else begin + let packet = String.make increment '\255' in + String.blit data offset packet 0 (min total_length increment); + if packet = reference then begin + (* le paquet n'a pas de contenu, on l'ignore *) + (* lwt () = printf "Skipping address 0x%06X...\n" address in *) + loop (address+increment) (offset+increment) (total_length-increment) + end else begin + (* lwt () = printf "Processing address 0x%06X...\n" address in *) + put_message send_buffer PcInterface.write_flash increment address packet; + lwt () = send_receive_packet k send_buffer send_length receive_buffer receive_length 0.5 1. in + if int_of_char receive_buffer.[0] <> PcInterface.write_flash then + failwith (UnexpectedReply (receive_buffer, String.make 1 (char_of_int PcInterface.erase_flash))) + else begin + lwt written = get_flash k ~address ~length:increment in + if written <> packet then + failwith (WriteError (packet, written)) + else + loop (address+increment) (offset+increment) (total_length-increment) + end + end + end + in loop address offset length + +let reset_board k = + let send_buffer = String.create 64 and receive_buffer = String.create 64 in + send_buffer.[0] <- char_of_int PcInterface.reset; + lwt () = send_receive_packet k send_buffer 1 receive_buffer 64 5. 5. in + return () diff --git a/info/control/card-tools/krobot_dump_memory.ml b/info/control/card-tools/krobot_dump_memory.ml new file mode 100644 index 0000000..91b80d1 --- /dev/null +++ b/info/control/card-tools/krobot_dump_memory.ml @@ -0,0 +1,28 @@ +(* + * krobot_dump_memory.ml + * --------------------- + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + +open Printf +open Lwt +open Lwt_io + +lwt () = + lwt k = Krobot_bootloader.open_card () in + try_lwt + lwt data = Krobot_bootloader.get_flash k ~address:0x0 ~length:0x8000 in + let msg = match Krobot_boardname.get_board_name data with + | Some s -> sprintf "Board: %S" s + | None -> "Unable to identify board!" + in + lwt () = eprintlf "%s" msg in + (if Unix.isatty Unix.stdout then hexdump else write) stdout data >> flush stdout + with + | Krobot_bootloader.Error e -> + eprintlf "%s" (Krobot_bootloader.string_of_error e) + | e -> + eprintlf "%s" (Printexc.to_string e) diff --git a/info/control/card-tools/krobot_hexfile.ml b/info/control/card-tools/krobot_hexfile.ml new file mode 100644 index 0000000..2d2c361 --- /dev/null +++ b/info/control/card-tools/krobot_hexfile.ml @@ -0,0 +1,112 @@ +(* + * krobot_hexfile.ml + * ----------------- + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + +open Lwt +open Lwt_io + +type hex_record = + | Data of int * string + | ExtendedLinearAddress of int + | EndOfFile of int + +let string_of_hexline str = + let n = String.length str in + assert (n > 0 && n mod 2 = 1 && str.[0] = ':'); + let m = n/2 in + let result = String.create m in + for i = 0 to m-1 do + let j = 2*i+1 in + result.[i] <- char_of_int (int_of_string ("0x"^(String.sub str j 2))) + done; + result + +let compute_checksum str = + let rec aux i accu = + if i < 0 then + (-accu) land 0xff + else + aux (i-1) (accu+(int_of_char str.[i])) + in aux (String.length str - 2) 0 + +let parse_line str = + let str = string_of_hexline str in + let get i = int_of_char str.[i] in + let n = String.length str in + assert (n >= 5 && compute_checksum str = int_of_char str.[n-1]); + let count = get 0 in + assert (count+5 = n); + let address = ((get 1) lsl 8) lor (get 2) in + let record_type = get 3 in + let data = String.sub str 4 count in + match record_type with + | 0x00 -> + Data (address, data) + | 0x01 -> + assert (count = 0); + EndOfFile address + | 0x04 -> + assert (count = 2 && address = 0); + let msb = int_of_char data.[0] and lsb = int_of_char data.[1] in + (* check for possible overflow *) + assert (msb land 0x80 = 0); + ExtendedLinearAddress ((msb lsl 8) lor lsb) + | _ -> assert false + +let parse_file file = + let ic = Lwt_io.open_file ~mode:input file in + let lines = Lwt_io.read_lines ic in + let lines = Lwt_stream.map parse_line lines in + lwt lines = Lwt_stream.get_while (fun _ -> true) lines in + lwt _ = Lwt_io.close ic in + return lines + +let print_record = function + | Data (address, data) -> + Printf.printf "DAT %04x" address; + String.iter (fun c -> Printf.printf " %02x" (int_of_char c)) data; + Printf.printf "\n" + | ExtendedLinearAddress address -> + Printf.printf "ELA %04x\n" address + | EndOfFile address -> + Printf.printf "EOF %04x\n" address + +let validate_and_copy hex addr_base buffer offset length = + assert (offset+length <= String.length buffer); + let min_address = addr_base+offset in + let max_address = min_address+length in + let addr_high = ref 0 in + let execute_record = function + | Data (address, data) -> + assert (address land 0xFFFF = address); + let address = !addr_high lor address in + if address < min_address || address >= max_address then + Printf.eprintf + "0x%04x is outside range, all bytes dropped\n" + address + else begin + let length = + let n = String.length data in + if address+n >= max_address then begin + Printf.eprintf + "some bytes at address 0x%04x are outside range (dropped)\n" + address; + max_address-address + end else n + in + let offset2 = address-addr_base in + String.blit data 0 buffer offset2 length; + end + | ExtendedLinearAddress address -> + assert (address land 0x8000 = 0); + addr_high := address lsl 16 + | EndOfFile address -> + assert (address = 0); + raise Exit + in + try List.iter execute_record hex with Exit -> () diff --git a/info/control/card-tools/krobot_hexfile.mli b/info/control/card-tools/krobot_hexfile.mli new file mode 100644 index 0000000..932e32e --- /dev/null +++ b/info/control/card-tools/krobot_hexfile.mli @@ -0,0 +1,26 @@ +(* + * krobot_hexfile.mli + * ------------------ + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + +type hex_record = + | Data of int * string + | ExtendedLinearAddress of int + | EndOfFile of int + +val parse_file : string -> hex_record list Lwt.t + +val print_record : hex_record -> unit + (** Prints one record on standard output. *) + +val validate_and_copy : hex_record list -> int -> string -> int -> int -> unit + (** [validate_and_copy hex addr_base buffer offset length] copies + the contents of the (parsed) [hex] file to [buffer]. [offset] + and [length] denote the valid range inside [buffer] that can be + written. [addr_base] is the address [buffer] is mapped to on the + microcontroller. Bytes outside the range are ignored (and a + warning is printed on standard error. *) diff --git a/info/control/card-tools/krobot_send_firmware.ml b/info/control/card-tools/krobot_send_firmware.ml new file mode 100644 index 0000000..82261c5 --- /dev/null +++ b/info/control/card-tools/krobot_send_firmware.ml @@ -0,0 +1,69 @@ +(* + * krobot_send_firmware.ml + * ----------------------- + * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> + * Licence : BSD3 + * + * This file is a part of Krobot. + *) + +open Lwt +open Lwt_io + +let do_flash force filename = + lwt hex = Krobot_hexfile.parse_file filename in + let memory = + let buffer = String.make 0x8000 '\255' in + Krobot_hexfile.validate_and_copy hex 0x0 buffer 0 0x8000; + buffer + in + let firmware_name = Krobot_boardname.get_board_name memory in + lwt () = match firmware_name with + | Some s -> printf "Detected firmware: %S\n" s + | None -> printf "Unable to identify firmware!\n" + in + let address = 0x800 and length = 0x8000-0x800 in + lwt k = Krobot_bootloader.open_card () in + lwt () = printf "Card opened\n" in + lwt data = Krobot_bootloader.get_flash k ~address:0x0 ~length:0x8000 in + let board_name = Krobot_boardname.get_board_name data in + lwt () = match board_name with + | Some s -> printf "Detected card: %S\n" s + | None -> printf "Unable to identify card!\n" + in + lwt () = + if not force && (board_name = None || firmware_name = None || board_name <> firmware_name) then begin + lwt () = eprintf "board name and firmware name do not match, use --force\n" in + exit 1 + end else return () + in + lwt () = Krobot_bootloader.erase_flash k ~address ~length in + lwt () = printf "Flash erased\n" in + lwt () = Krobot_bootloader.write_flash k ~address memory address length in + lwt () = printf "Flashing completed\n" in + lwt () = Krobot_bootloader.reset_board k in + return () + +lwt () = + let force = ref false in + let filename = ref None in + let speclist = [ + "--force", Arg.Set force, "Force flashing even if board id and firmware id do not match"; + ] in + Arg.parse speclist + (fun s -> + match !filename with + | None -> filename := Some s + | Some _ -> raise (Arg.Bad s)) + "Send a firmware to a board in bootloader mode"; + let filename = match !filename with + | None -> Printf.eprintf "You must specify a .hex file!\n"; exit 1 + | Some s -> s + in + try_lwt + do_flash !force filename + with + | Krobot_bootloader.Error e -> + eprintl (Krobot_bootloader.string_of_error e) + | e -> + eprintl (Printexc.to_string e) diff --git a/info/control/card_tools/krobot_boardname.mli b/info/control/card_tools/krobot_boardname.mli deleted file mode 100644 index 51dc1b5..0000000 --- a/info/control/card_tools/krobot_boardname.mli +++ /dev/null @@ -1,12 +0,0 @@ -(* - * krobot_boardname.mli - * -------------------- - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - -val get_board_name : string -> string option - (** [get_board_name dump] recherche dans le [dump] mémoire (peut - être également un fichier .hex chargé) le nom de la carte. *) diff --git a/info/control/card_tools/krobot_boardname.mll b/info/control/card_tools/krobot_boardname.mll deleted file mode 100644 index 96b39b6..0000000 --- a/info/control/card_tools/krobot_boardname.mll +++ /dev/null @@ -1,22 +0,0 @@ -(* - * krobot_boardname.mll - * -------------------- - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - - -let boardname_regex = ("Carte " | "Robot Interface" | "Battery Monitoring ") [^'\n']+ - -rule boardname = parse - | (boardname_regex as name) '\n' { Some name } - | _ { boardname lexbuf } - | eof { None } - -{ - let get_board_name str = - let lexbuf = Lexing.from_string str in - boardname lexbuf -} diff --git a/info/control/card_tools/krobot_bootloader.ml b/info/control/card_tools/krobot_bootloader.ml deleted file mode 100644 index 1deb632..0000000 --- a/info/control/card_tools/krobot_bootloader.ml +++ /dev/null @@ -1,184 +0,0 @@ -(* - * krobot_bootloader.ml - * -------------------- - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - -open Lwt -open Lwt_io - -(* Code très inspiré de kard.ml, mais mis à part car le mode de - communication avec la carte est différent (bulk au lieu - d'interrupt). *) - -type t = { - mutable is_open : bool; - (* La carte est-elle ouverte ? *) - - handle : USB.handle; - (* Handle pour le périphérique usb *) - - kernel_active : bool; - (* Est-ce qu'un driver noyau était attaché à la carte avant qu'on - l'utilise ? *) -} - -type error = - | IncompleteWrite of int * int - | IncompleteRead of int * int - | UnexpectedReply of string * string - | WriteError of string * string - -let string_of_error = function - | IncompleteWrite (a, b) -> Printf.sprintf "%d byte(s) written instead of %d" a b - | IncompleteRead (a, b) -> Printf.sprintf "%d byte(s) read instead of %d" a b - | UnexpectedReply (a, b) -> Printf.sprintf "received unexpected reply %S instead of %S" a b - | WriteError (a, b) -> Printf.sprintf "written: %S, read back: %S" a b - -exception Error of error - -let failwith e = fail (Error e) - -let close k = - if k.is_open then begin - lwt _ = USB.release_interface k.handle 0 in - lwt _ = USB.reset_device k.handle in - (*if k.kernel_active then USB.attach_kernel_driver k.handle 0;*) - (*USB.close k.handle;*) - k.is_open <- false; - return () - end else return () - -let open_card () = - let handle = USB.open_device_with - ~vendor_id:PcInterface.usb_vid - ~product_id:PcInterface.usb_pid_bootloader - in - let kernel_active = USB.kernel_driver_active handle 0 in - if kernel_active then USB.detach_kernel_driver handle 0; - lwt _ = USB.set_configuration handle 1 in - lwt _ = USB.claim_interface handle 0 in - let k = { is_open = true; - handle = handle; - kernel_active = kernel_active } in - let _ = Lwt_sequence.add_l (fun _ -> close k) Lwt_main.exit_hooks in - return k - -let header_length = 5 - -let put_message buffer cmd length address data = - let body_length = String.length data in - assert (String.length buffer >= header_length+body_length); - let set i n = buffer.[i] <- char_of_int n in - set 0 cmd; - assert (length < 0x100); - set 1 length; - assert (address <= 0x1000000); - set 2 (address land 0xff); - set 3 ((address lsr 8) land 0xff); - set 4 ((address lsr 16) land 0xff); - String.blit data 0 buffer 5 body_length - -let send_receive_packet k send_buffer send_length receive_buffer receive_length send_delay receive_delay = - let handle = k.handle and endpoint = 1 in - lwt sent = USB.bulk_send ~handle ~endpoint ~timeout:1. send_buffer 0 send_length in - if sent <> send_length then - failwith (IncompleteWrite (sent, send_length)) - else begin - lwt received = USB.bulk_recv ~handle ~endpoint ~timeout:3. receive_buffer 0 receive_length in - if received <> receive_length then - failwith (IncompleteRead (received, receive_length)) - else - return () - end - -let get_flash k ~address ~length = - let response_length = 64 in - let increment = response_length-header_length in - assert (increment < 256); - let send_buffer = String.create header_length in - let receive_buffer = String.create response_length in - let result_buffer = String.create length in - let rec loop offset total_length = - if total_length <= 0 then - return result_buffer - else begin - let length = min increment total_length in - let response_length = length+header_length in - let address = address+offset in - put_message send_buffer PcInterface.read_flash length address ""; - lwt () = send_receive_packet k send_buffer header_length receive_buffer response_length 1. 3. in - let receive_header = String.sub receive_buffer 0 header_length in - if receive_header <> send_buffer then - failwith (UnexpectedReply (receive_header, send_buffer)) - else begin - String.blit receive_buffer header_length result_buffer offset length; - loop (offset+length) (total_length-length); - end - end - in loop 0 length - -let erase_flash k ~address ~length = - let response_length = 1 in - (* les effacements se font par blocs de 64 octets *) - let increment = 64 in - let send_buffer = String.create header_length in - let receive_buffer = String.create response_length in - let rec loop offset total_length = - if total_length <= 0 then - return () - else begin - let address = address+offset in - put_message send_buffer PcInterface.erase_flash 1 address ""; - lwt () = send_receive_packet k send_buffer header_length receive_buffer response_length 1. 5. in - if int_of_char receive_buffer.[0] <> PcInterface.erase_flash then - failwith (UnexpectedReply (receive_buffer, String.make 1 (char_of_int PcInterface.erase_flash))) - else - loop (offset+increment) (total_length-increment); - end - in loop 0 length - -let reference = String.make 16 '\255' - -let write_flash k ~address data offset length = - let send_length = 64 and receive_length = 1 in - (* les écritures se font par blocs de 16 octets *) - let increment = 16 in - let send_buffer = String.create send_length in - let receive_buffer = String.create receive_length in - let rec loop address offset total_length = - (* address: sur le PIC, offset: dans data, total_length: taille restante *) - if total_length <= 0 then - return () - else begin - let packet = String.make increment '\255' in - String.blit data offset packet 0 (min total_length increment); - if packet = reference then begin - (* le paquet n'a pas de contenu, on l'ignore *) - (* lwt () = printf "Skipping address 0x%06X...\n" address in *) - loop (address+increment) (offset+increment) (total_length-increment) - end else begin - (* lwt () = printf "Processing address 0x%06X...\n" address in *) - put_message send_buffer PcInterface.write_flash increment address packet; - lwt () = send_receive_packet k send_buffer send_length receive_buffer receive_length 0.5 1. in - if int_of_char receive_buffer.[0] <> PcInterface.write_flash then - failwith (UnexpectedReply (receive_buffer, String.make 1 (char_of_int PcInterface.erase_flash))) - else begin - lwt written = get_flash k ~address ~length:increment in - if written <> packet then - failwith (WriteError (packet, written)) - else - loop (address+increment) (offset+increment) (total_length-increment) - end - end - end - in loop address offset length - -let reset_board k = - let send_buffer = String.create 64 and receive_buffer = String.create 64 in - send_buffer.[0] <- char_of_int PcInterface.reset; - lwt () = send_receive_packet k send_buffer 1 receive_buffer 64 5. 5. in - return () diff --git a/info/control/card_tools/krobot_dump_memory.ml b/info/control/card_tools/krobot_dump_memory.ml deleted file mode 100644 index 91b80d1..0000000 --- a/info/control/card_tools/krobot_dump_memory.ml +++ /dev/null @@ -1,28 +0,0 @@ -(* - * krobot_dump_memory.ml - * --------------------- - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - -open Printf -open Lwt -open Lwt_io - -lwt () = - lwt k = Krobot_bootloader.open_card () in - try_lwt - lwt data = Krobot_bootloader.get_flash k ~address:0x0 ~length:0x8000 in - let msg = match Krobot_boardname.get_board_name data with - | Some s -> sprintf "Board: %S" s - | None -> "Unable to identify board!" - in - lwt () = eprintlf "%s" msg in - (if Unix.isatty Unix.stdout then hexdump else write) stdout data >> flush stdout - with - | Krobot_bootloader.Error e -> - eprintlf "%s" (Krobot_bootloader.string_of_error e) - | e -> - eprintlf "%s" (Printexc.to_string e) diff --git a/info/control/card_tools/krobot_hexfile.ml b/info/control/card_tools/krobot_hexfile.ml deleted file mode 100644 index 2d2c361..0000000 --- a/info/control/card_tools/krobot_hexfile.ml +++ /dev/null @@ -1,112 +0,0 @@ -(* - * krobot_hexfile.ml - * ----------------- - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - -open Lwt -open Lwt_io - -type hex_record = - | Data of int * string - | ExtendedLinearAddress of int - | EndOfFile of int - -let string_of_hexline str = - let n = String.length str in - assert (n > 0 && n mod 2 = 1 && str.[0] = ':'); - let m = n/2 in - let result = String.create m in - for i = 0 to m-1 do - let j = 2*i+1 in - result.[i] <- char_of_int (int_of_string ("0x"^(String.sub str j 2))) - done; - result - -let compute_checksum str = - let rec aux i accu = - if i < 0 then - (-accu) land 0xff - else - aux (i-1) (accu+(int_of_char str.[i])) - in aux (String.length str - 2) 0 - -let parse_line str = - let str = string_of_hexline str in - let get i = int_of_char str.[i] in - let n = String.length str in - assert (n >= 5 && compute_checksum str = int_of_char str.[n-1]); - let count = get 0 in - assert (count+5 = n); - let address = ((get 1) lsl 8) lor (get 2) in - let record_type = get 3 in - let data = String.sub str 4 count in - match record_type with - | 0x00 -> - Data (address, data) - | 0x01 -> - assert (count = 0); - EndOfFile address - | 0x04 -> - assert (count = 2 && address = 0); - let msb = int_of_char data.[0] and lsb = int_of_char data.[1] in - (* check for possible overflow *) - assert (msb land 0x80 = 0); - ExtendedLinearAddress ((msb lsl 8) lor lsb) - | _ -> assert false - -let parse_file file = - let ic = Lwt_io.open_file ~mode:input file in - let lines = Lwt_io.read_lines ic in - let lines = Lwt_stream.map parse_line lines in - lwt lines = Lwt_stream.get_while (fun _ -> true) lines in - lwt _ = Lwt_io.close ic in - return lines - -let print_record = function - | Data (address, data) -> - Printf.printf "DAT %04x" address; - String.iter (fun c -> Printf.printf " %02x" (int_of_char c)) data; - Printf.printf "\n" - | ExtendedLinearAddress address -> - Printf.printf "ELA %04x\n" address - | EndOfFile address -> - Printf.printf "EOF %04x\n" address - -let validate_and_copy hex addr_base buffer offset length = - assert (offset+length <= String.length buffer); - let min_address = addr_base+offset in - let max_address = min_address+length in - let addr_high = ref 0 in - let execute_record = function - | Data (address, data) -> - assert (address land 0xFFFF = address); - let address = !addr_high lor address in - if address < min_address || address >= max_address then - Printf.eprintf - "0x%04x is outside range, all bytes dropped\n" - address - else begin - let length = - let n = String.length data in - if address+n >= max_address then begin - Printf.eprintf - "some bytes at address 0x%04x are outside range (dropped)\n" - address; - max_address-address - end else n - in - let offset2 = address-addr_base in - String.blit data 0 buffer offset2 length; - end - | ExtendedLinearAddress address -> - assert (address land 0x8000 = 0); - addr_high := address lsl 16 - | EndOfFile address -> - assert (address = 0); - raise Exit - in - try List.iter execute_record hex with Exit -> () diff --git a/info/control/card_tools/krobot_hexfile.mli b/info/control/card_tools/krobot_hexfile.mli deleted file mode 100644 index 932e32e..0000000 --- a/info/control/card_tools/krobot_hexfile.mli +++ /dev/null @@ -1,26 +0,0 @@ -(* - * krobot_hexfile.mli - * ------------------ - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - -type hex_record = - | Data of int * string - | ExtendedLinearAddress of int - | EndOfFile of int - -val parse_file : string -> hex_record list Lwt.t - -val print_record : hex_record -> unit - (** Prints one record on standard output. *) - -val validate_and_copy : hex_record list -> int -> string -> int -> int -> unit - (** [validate_and_copy hex addr_base buffer offset length] copies - the contents of the (parsed) [hex] file to [buffer]. [offset] - and [length] denote the valid range inside [buffer] that can be - written. [addr_base] is the address [buffer] is mapped to on the - microcontroller. Bytes outside the range are ignored (and a - warning is printed on standard error. *) diff --git a/info/control/card_tools/krobot_send_firmware.ml b/info/control/card_tools/krobot_send_firmware.ml deleted file mode 100644 index 82261c5..0000000 --- a/info/control/card_tools/krobot_send_firmware.ml +++ /dev/null @@ -1,69 +0,0 @@ -(* - * krobot_send_firmware.ml - * ----------------------- - * Copyright : (c) 2009, Stéphane Glondu <st...@gl...> - * Licence : BSD3 - * - * This file is a part of Krobot. - *) - -open Lwt -open Lwt_io - -let do_flash force filename = - lwt hex = Krobot_hexfile.parse_file filename in - let memory = - let buffer = String.make 0x8000 '\255' in - Krobot_hexfile.validate_and_copy hex 0x0 buffer 0 0x8000; - buffer - in - let firmware_name = Krobot_boardname.get_board_name memory in - lwt () = match firmware_name with - | Some s -> printf "Detected firmware: %S\n" s - | None -> printf "Unable to identify firmware!\n" - in - let address = 0x800 and length = 0x8000-0x800 in - lwt k = Krobot_bootloader.open_card () in - lwt () = printf "Card opened\n" in - lwt data = Krobot_bootloader.get_flash k ~address:0x0 ~length:0x8000 in - let board_name = Krobot_boardname.get_board_name data in - lwt () = match board_name with - | Some s -> printf "Detected card: %S\n" s - | None -> printf "Unable to identify card!\n" - in - lwt () = - if not force && (board_name = None || firmware_name = None || board_name <> firmware_name) then begin - lwt () = eprintf "board name and firmware name do not match, use --force\n" in - exit 1 - end else return () - in - lwt () = Krobot_bootloader.erase_flash k ~address ~length in - lwt () = printf "Flash erased\n" in - lwt () = Krobot_bootloader.write_flash k ~address memory address length in - lwt () = printf "Flashing completed\n" in - lwt () = Krobot_bootloader.reset_board k in - return () - -lwt () = - let force = ref false in - let filename = ref None in - let speclist = [ - "--force", Arg.Set force, "Force flashing even if board id and firmware id do not match"; - ] in - Arg.parse speclist - (fun s -> - match !filename with - | None -> filename := Some s - | Some _ -> raise (Arg.Bad s)) - "Send a firmware to a board in bootloader mode"; - let filename = match !filename with - | None -> Printf.eprintf "You must specify a .hex file!\n"; exit 1 - | Some s -> s - in - try_lwt - do_flash !force filename - with - | Krobot_bootloader.Error e -> - eprintl (Krobot_bootloader.string_of_error e) - | e -> - eprintl (Printexc.to_string e) diff --git a/info/control/clients/krobot_controller.ml b/info/control/clients/krobot_controller.ml index f6d3fbd..be77781 100644 --- a/info/control/clients/krobot_controller.ml +++ b/info/control/clients/krobot_controller.ml @@ -232,10 +232,10 @@ let rec draw krobot = | `Absent -> [fg lred; text name] | `Present -> [text name] in - lwt interface_state = OBus_property.get (Krobot.Card.state (krobot, `Interface)) - and sensor_state = OBus_property.get (Krobot.Card.state (krobot, `Sensor)) - and motor_state = OBus_property.get (Krobot.Card.state (krobot, `Motor)) - and monitoring_state = OBus_property.get (Krobot.Card.state (krobot, `Monitoring)) in + lwt interface_state = OBus_property.get (Krobot.Card.state krobot `Interface) + and sensor_state = OBus_property.get (Krobot.Card.state krobot `Sensor) + and motor_state = OBus_property.get (Krobot.Card.state krobot `Motor) + and monitoring_state = OBus_property.get (Krobot.Card.state krobot `Monitoring) in Draw.textc zone x 0 (text_of_state "interface" interface_state); Draw.textc zone x 1 (text_of_state "sensor" sensor_state); Draw.textc zone x 2 (text_of_state "motor" motor_state); @@ -419,16 +419,16 @@ lwt () = and () = notify =|< OBus_property.monitor (Krobot.jack krobot)*) and () = notify =|< OBus_property.monitor (Krobot.inhibit_forward_until krobot) and () = notify =|< OBus_property.monitor (Krobot.inhibit_backward_until krobot) - and () = notify =|< OBus_property.monitor (Krobot.Card.state (krobot, `Interface)) - and () = notify =|< OBus_property.monitor (Krobot.Card.state (krobot, `Sensor)) - and () = notify =|< OBus_property.monitor (Krobot.Card.state (krobot, `Motor)) in + and () = notify =|< OBus_property.monitor (Krobot.Card.state krobot `Interface) + and () = notify =|< OBus_property.monitor (Krobot.Card.state krobot `Sensor) + and () = notify =|< OBus_property.monitor (Krobot.Card.state krobot `Motor) in notify services; List.iter (fun card -> Lwt_event.always_notify (fun error -> log_add_line [fg lred; textf "error on card %s: %s" (Krobot.Card.name card) error]) - (OBus_signal.event (Krobot.Card.errors (krobot, card)))) + (OBus_signal.event (Krobot.Card.errors krobot card))) [`Interface; `Sensor; `Motor; `Monitoring]; (* Redraw immedlatly the screen when [signal] changes: *) diff --git a/info/control/clients/krobot_info.ml b/info/control/clients/krobot_info.ml index 496a66e..bcebf65 100644 --- a/info/control/clients/krobot_info.ml +++ b/info/control/clients/krobot_info.ml @@ -13,10 +13,10 @@ open Lwt open Lwt_io let print_card krobot card = - OBus_property.get (Krobot.Card.state (krobot, card)) >>= function + OBus_property.get (Krobot.Card.state krobot card) >>= function | `Present -> - lwt firmware_build = Krobot.Card.get_firmware_build (krobot, card) - and board_info = Krobot.Card.get_board_info (krobot, card) in + lwt firmware_build = Krobot.Card.get_firmware_build krobot card + and board_info = Krobot.Card.get_board_info krobot card in let name = Krobot.Card.name card in lwt () = printl "==========" in lwt () = printlf "card.%s.state = present" name in diff --git a/info/control/clients/krobot_script.ml b/info/control/clients/krobot_script.ml index a3922dc..639a230 100644 --- a/info/control/clients/krobot_script.ml +++ b/info/control/clients/krobot_script.ml @@ -9,13 +9,164 @@ open Lwt open Lwt_term -open Krobot_script_types module TextSet = Set.Make(Text) let set_of_list l = List.fold_left (fun set x -> TextSet.add x set) TextSet.empty l (* +-----------------------------------------------------------------+ + | Types | + +-----------------------------------------------------------------+ *) + +type logger = Lwt_term.styled_text -> unit Lwt.t + +(* Type of an argument *) +type arg_type = + | Int + | Float + | String + | Keyword of string list + +type command = { + c_name : string; + (* The command name *) + + c_path : string list; + (* The path of the command *) + + c_exec : (string * string) list -> logger -> Krobot.t -> unit Lwt.t; + (* The command implementation. It takes as argument the list of + parameters. *) + + c_args : (string * arg_type) list; + (* Argument description, used for completion. *) +} + +(* An argument description *) +type 'a arg = { + a_type : arg_type; + a_name : string; + a_cast : string -> 'a; + a_default : 'a option; +} + +(* A function description *) +type 'a func = { + f_args : (string * arg_type) list; + (* Arguments of the function, for completion *) + + f_func : (string * string) list -> 'a -> unit Lwt.t; + (* [f_func args f] parses arguments [args] and apply them to [f] *) +} + +(* All registred commands *) +let commands = ref [] + +(* Register a command *) +let register ?(path=[]) name func f = + let command = { + c_name = name; + c_path = path; + c_exec = (fun args logger krobot -> func.f_func args (f logger krobot)); + c_args = func.f_args; + } in + commands := command :: !commands + +exception Argument_error of string + (* Exception raised when there is a problem with an argument *) + +let arg_error msg = raise (Argument_error msg) + +(* Returns the value associated to [key] if any, and the list without + the first occurence of [key] *) +let rec assoc_remove key = function + | [] -> + (None, []) + | (key', value) :: rest when key = key' -> + (Some value, rest) + | pair :: rest -> + let result, l = assoc_remove key rest in + (result, pair :: l) + +let ( --> ) arg func = { + f_args = (arg.a_name, arg.a_type) :: func.f_args; + f_func = + fun args f -> + let result, args = assoc_remove arg.a_name args in + match result with + | Some str -> + func.f_func args (f (arg.a_cast str)) + | None -> + match arg.a_default with + | Some value -> + func.f_func args (f value) + | None -> + Printf.ksprintf arg_error "argument '%s' is mandatory" arg.a_name +} + +let f0 = { + f_args = []; + f_func = + fun args f -> + match args with + | [] -> + f + | (key, _) :: _ -> + Printf.ksprintf arg_error "unused argument '%s'" key +} + +let f1 arg0 = arg0 --> f0 +let f2 arg0 arg1 = arg0 --> (f1 arg1) +let f3 arg0 arg1 arg2 = arg0 --> (f2 arg1 arg2) +let f4 arg0 arg1 arg2 arg3 = arg0 --> (f3 arg1 arg2 arg3) +let f5 arg0 arg1 arg2 arg3 arg4 = arg0 --> (f4 arg1 arg2 arg3 arg4) +let f6 arg0 arg1 arg2 arg3 arg4 arg5 = arg0 --> (f5 arg1 arg2 arg3 arg4 arg5) + +(* +-----------------------------------------------------------------+ + | Arguments | + +-----------------------------------------------------------------+ *) + +let int ?default name = { + a_name = name; + a_type = Int; + a_cast = (fun str -> + try + int_of_string str + with Failure _ -> + Printf.ksprintf arg_error "invalid value for argument '%s': an integer was expected" name); + a_default = default; +} + +let string ?default name = { + a_name = name; + a_type = String; + a_cast = (fun str -> str); + a_default = default; +} + +let float ?default name = { + a_name = name; + a_type = Float; + a_cast = (fun str -> + try + float_of_string str + with Failure _ -> + Printf.ksprintf arg_error "invalid value for argument '%s': a float was expected" name); + a_default = default; +} + +let keyword ?default name keywords = { + a_name = name; + a_type = Keyword(List.map fst keywords); + a_cast = (fun key -> + try + List.assoc key keywords + with Not_found -> + Printf.ksprintf arg_error "invalid value for '%s'" name); + a_default = default; +} + +(* +-----------------------------------------------------------------+ | Completion | +-----------------------------------------------------------------+ *) @@ -235,11 +386,11 @@ let () = ("monitoring", `Monitoring)] in register ~path:["card"] "bootloader" (f1 card) - (fun logger krobot card -> Krobot.Card.bootloader (krobot, card)); + (fun logger krobot card -> Krobot.Card.bootloader krobot card); register ~path:["card"] "reset" (f1 card) - (fun logger krobot card -> Krobot.Card.reset (krobot, card)); + (fun logger krobot card -> Krobot.Card.reset krobot card); register ~path:["card"] "test" (f1 card) - (fun logger krobot card -> Krobot.Card.test (krobot, card)); + (fun logger krobot card -> Krobot.Card.test krobot card); (* +---------------------------------------------------------------+ | Range finders | @@ -278,7 +429,7 @@ let () = and velocity = int ~default:50 "velocity" and timeout = int ~default:100 "timeout" and goto_mode = keyword ~default:`Now "mode" [("now", `Now); ("action", `Action)] in - +(* register ~path:["ax12"] "goto" (f4 id position velocity goto_mode) (fun logger krobot id position velocity goto_mode -> Krobot_unsafe.AX12.goto krobot id position velocity goto_mode); @@ -313,7 +464,7 @@ let () = register ~path:["ax12"] "action" (f1 (int ~default:254 "id")) (fun logger krobot id -> Krobot_unsafe.AX12.action krobot id); - +*) (* +---------------------------------------------------------------+ | Grip | +---------------------------------------------------------------+ *) @@ -354,5 +505,51 @@ let () = (fun logger krobot -> Krobot.claws_take krobot) +(* +-----------------------------------------------------------------+ + | Unsafe commands | + +-----------------------------------------------------------------+ *) +(* + +let arg_type_of_proto env = function + | Protocol.Sint8 | Protocol.Uint8 + | Protocol.Sint16 | Protocol.Uint16 + | Protocol.Sint32 | Protocol.Uint32 -> + Int + | Protocol.String -> + String + | Protocol.Bool -> + Keyword ["true"; "false"] + | Protocol.Enum(_, l) -> + Keyword (List.map fst l) + | Protocol.Bit_mask _ -> + Int + | Protocol.Array _ -> + Int + | Protocol.Tuple _ -> + Int + | Protocol.Alias name -> + env (String_map.find name env) + +open Protocol + +let register_command component env cmd = + let cmd = { + c_args = + List.map + (fun (arg, typ) -> + (arg, arg_type_of_proto env typ)) + cmd.send; + c_name = cmd.name; + c_path = ["unsafe"; component]; + c_exec = fun args logger krobot -> + + } + in + commands := cmd :: !commands + +let make_interface + +let () = -let () = Krobot_script_unsafe.register () + f_args : (string * arg_type) list; +*) diff --git a/info/control/clients/krobot_script_types.ml b/info/control/clients/krobot_script_types.ml deleted file mode 100644 index caed0fb..0000000 --- a/info/control/clients/krobot_script_types.ml +++ /dev/null @@ -1,160 +0,0 @@ -(* - * krobot_script_types.ml - * ---------------------- - * Copyright : (c) 2010, Jeremie Dimino <je...@di...> - * Licence : BSD3 - * - * This file is a part of [kro]bot. - *) - -(* +-----------------------------------------------------------------+ - | Types | - +-----------------------------------------------------------------+ *) - -type logger = Lwt_term.styled_text -> unit Lwt.t - -(* Type of an argument *) -type arg_type = - | Int - | Float - | String - | Keyword of string list - -type command = { - c_name : string; - (* The command name *) - - c_path : string list; - (* The path of the command *) - - c_exec : (string * string) list -> logger -> Krobot.t -> unit Lwt.t; - (* The command implementation. It takes as argument the list of - parameters. *) - - c_args : (string * arg_type) list; - (* Argument description, used for completion. *) -} - -(* An argument description *) -type 'a arg = { - a_type : arg_type; - a_name : string; - a_cast : string -> 'a; - a_default : 'a option; -} - -(* A function description *) -type 'a func = { - f_args : (string * arg_type) list; - (* Arguments of the function, for completion *) - - f_func : (string * string) list -> 'a -> unit Lwt.t; - (* [f_func args f] parses arguments [args] and apply them to [f] *) -} - -(* All registred commands *) -let commands = ref [] - -(* Register a command *) -let register ?(path=[]) name func f = - let command = { - c_name = name; - c_path = path; - c_exec = (fun args logger krobot -> func.f_func args (f logger krobot)); - c_args = func.f_args; - } in - commands := command :: !commands - -exception Argument_error of string - (* Exception raised when there is a problem with an argument *) - -let arg_error msg = raise (Argument_error msg) - -(* Returns the value associated to [key] if any, and the list without - the first occurence of [key] *) -let rec assoc_remove key = function - | [] -> - (None, []) - | (key', value) :: rest when key = key' -> - (Some value, rest) - | pair :: rest -> - let result, l = assoc_remove key rest in - (result, pair :: l) - -let ( --> ) arg func = { - f_args = (arg.a_name, arg.a_type) :: func.f_args; - f_func = - fun args f -> - let result, args = assoc_remove arg.a_name args in - match result with - | Some str -> - func.f_func args (f (arg.a_cast str)) - | None -> - match arg.a_default with - | Some value -> - func.f_func args (f value) - | None -> - Printf.ksprintf arg_error "argument '%s' is mandatory" arg.a_name -} - -let f0 = { - f_args = []; - f_func = - fun args f -> - match args with - | [] -> - f - | (key, _) :: _ -> - Printf.ksprintf arg_error "unused argument '%s'" key -} - -let f1 arg0 = arg0 --> f0 -let f2 arg0 arg1 = arg0 --> (f1 arg1) -let f3 arg0 arg1 arg2 = arg0 --> (f2 arg1 arg2) -let f4 arg0 arg1 arg2 arg3 = arg0 --> (f3 arg1 arg2 arg3) -let f5 arg0 arg1 arg2 arg3 arg4 = arg0 --> (f4 arg1 arg2 arg3 arg4) -let f6 arg0 arg1 arg2 arg3 arg4 arg5 = arg0 --> (f5 arg1 arg2 arg3 arg4 arg5) - -(* +-----------------------------------------------------------------+ - | Arguments | - +-----------------------------------------------------------------+ *) - -let int ?default name = { - a_name = name; - a_type = Int; - a_cast = (fun str -> - try - int_of_string str - with Failure _ -> - Printf.ksprintf arg_error "invalid value for argument '%s': an integer was expected" name); - a_default = default; -} - -let string ?default name = { - a_name = name; - a_type = String; - a_cast = (fun str -> str); - a_default = default; -} - -let float ?default name = { - a_name = name; - a_type = Float; - a_cast = (fun str -> - try - float_of_string str - with Failure _ -> - Printf.ksprintf arg_error "invalid value for argument '%s': a float was expected" name); - a_default = default; -} - -let keyword ?default name keywords = { - a_name = name; - a_type = Keyword(List.map fst keywords); - a_cast = (fun key -> - try - List.assoc key keywords - with Not_found -> - Printf.ksprintf arg_error "invalid value for '%s'" name); - a_default = default; -} diff --git a/info/control/common/krobot_types.ml b/info/control/common/krobot_types.ml index b10800c..4d3215c 100644 --- a/info/control/common/krobot_types.ml +++ b/info/control/common/krobot_types.ml @@ -7,39 +7,66 @@ * This file is a part of [kro]bot. *) -open OBus_pervasives +(* Note: integers value must be taken from PcInterface.h *) + +let make_map l = + ((fun x -> + let rec loop = function + | [] -> failwith "Krobot_types: invalid value" + | (x', y) :: _ when x = x' -> y + | _ :: l -> loop l + in + loop l), + (fun y -> + let rec loop = function + | [] -> failwith "Krobot_types: invalid value" + | (x, y') :: _ when y = y' -> x + | _ :: l -> loop l + in + loop l)) type move_result = [ `OK | `Stopped ] -let obus_move_result = - OBus_type.mapping obus_int [(`OK, 0); (`Stopped, 1)] +let int32_of_move_result, move_result_of_int32 = + make_map [ + `OK, 0l; + `Stopped, 1l; + ] type motor = [ `Left | `Right | `Both ] -let obus_motor = OBus_type.mapping obus_int - [(`Left, -1); - (`Both, 0); - (`Right, 1)] +let int32_of_motor, motor_of_int32 = + make_map [ + `Left, Int32.of_int PcInterface.motor_left; + `Both, Int32.of_int PcInterface.motor_both; + `Right, Int32.of_int PcInterface.motor_right + ] type stop_mode = [ `Off | `Abrupt | `Smooth ] -let obus_stop_mode = OBus_type.mapping obus_int - [(`Off, 0); - (`Abrupt, 1); - (`Smooth, 2)] +let int32_of_stop_mode, stop_mode_of_int32 = + make_map [ + `Off, Int32.of_int PcInterface.traj_stop_motor_off; + `Abrupt, Int32.of_int PcInterface.traj_stop_abrupt; + `Smooth, Int32.of_int PcInterface.traj_stop_smooth; + ] type card_state = [ `Present | `Absent ] -let obus_card_state = OBus_type.mapping obus_int - [(`Present, 0); - (`Absent, 1)] +let int32_of_card_state, card_state_of_int32 = + make_map [ + `Present, 0l; + `Absent, 1l; + ] type goto_mode = [ `Straight | `Curve_right | `Curve_left ] -let obus_goto_mode = OBus_type.mapping obus_int - [(`Straight, 0); - (`Curve_right, 1); - (`Curve_left, 2)] +let int32_of_goto_mode, goto_mode_of_int32 = + make_map [ + `Straight, 0l; + `Curve_right, 1l; + `Curve_left, 2l; + ] type ax12_stats = { ax12_position : int; @@ -49,27 +76,33 @@ type ax12_stats = { ax12_temperature : int; ax12_cw_angle_limit : int; ax12_ccw_angle_limit : int; -} with obus +} type exec_mode = [ `Now | `Action ] -let obus_exec_mode = OBus_type.mapping obus_int - [(`Now, 0); (`Action, 1)] +let int32_of_exec_mode, exec_mode_of_int32 = + make_map [ + `Now, Int32.of_int PcInterface.ax12_exec_now; + `Action, Int32.of_int PcInterface.ax12_exec_action; + ] type direction = [ `Forward | `Backward ] -let obus_direction = OBus_type.mapping obus_int - [(`Forward, 0); (`Backward, 1)] +let int32_of_direction, direction_of_int32 = + make_map [ + `Forward, 1l; + `Backward, -1l; + ] type ax12_action = { aa_id : int; aa_position : int; aa_velocity : int; -} with obus +} type motor_config = { motor_kp : int; motor_ki : int; motor_kd : int; motor_li : int; -} with obus +} diff --git a/info/control/common/krobot_types.mli b/info/control/common/krobot_types.mli index 56d042b..3bc674f 100644 --- a/info/control/common/krobot_types.mli +++ b/info/control/common/krobot_types.mli @@ -7,35 +7,53 @@ * This file is a part of [kro]bot. *) -(** Common types with their obus type combinators *) +(** Common types *) (** This types are used by the driver and the client... [truncated message content] |
From: Olivier B. <Ba...@us...> - 2010-04-17 14:21:02
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 31edfc54f06d6f388a443d87e3644d1829505f63 (commit) from 2b6c7dfb2636bdac047f6a806115ce8ba6f94f22 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 31edfc54f06d6f388a443d87e3644d1829505f63 Author: unknown <Olivier@.(none)> Date: Sat Apr 17 16:20:35 2010 +0200 Added RX-64 Interface PCB ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/Interface_RX64/PCB/INTERFACE_RX64-1_0-MAX232D.MAX b/elec/boards/Interface_RX64/PCB/INTERFACE_RX64-1_0-MAX232D.MAX new file mode 100644 index 0000000..c193b45 Binary files /dev/null and b/elec/boards/Interface_RX64/PCB/INTERFACE_RX64-1_0-MAX232D.MAX differ diff --git a/elec/boards/Interface_RX64/PCB/INTERFACE_RX64-1_0-MAX232DW.MAX b/elec/boards/Interface_RX64/PCB/INTERFACE_RX64-1_0-MAX232DW.MAX new file mode 100644 index 0000000..788a14d Binary files /dev/null and b/elec/boards/Interface_RX64/PCB/INTERFACE_RX64-1_0-MAX232DW.MAX differ diff --git a/elec/boards/Interface_RX64/PCB/INTERFACE_RX64.MNL b/elec/boards/Interface_RX64/PCB/INTERFACE_RX64.MNL new file mode 100644 index 0000000..1e3aa28 Binary files /dev/null and b/elec/boards/Interface_RX64/PCB/INTERFACE_RX64.MNL differ diff --git a/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64.BOM b/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64.BOM new file mode 100644 index 0000000..e184cde --- /dev/null +++ b/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64.BOM @@ -0,0 +1,40 @@ +RX-64 Interface Revised: Saturday, April 17, 2010 + Revision: 1.0 + + + + + + + +Bill Of Materials April 17,2010 15:29:55 Page1 + +Item Quantity Reference Part +______________________________________________ + +1 4 C1,C2,C3,C4 1u +2 4 C5,C6,C7,C8 4.7u +3 1 C9 330u +4 1 C10 2.2u +5 3 C11,C12,C14 100n +6 1 C13 0.33u +7 1 D1 LED transmit mode +8 1 D2 LED bus power +9 1 D3 10BQ040 +10 1 D4 LED 5 V +11 2 J1,J3 Bus RX-64 +12 1 J2 Terminate +13 1 J4 DC Power +14 1 J5 CON6A +15 1 P1 Serial port +16 1 Q1 BC857 +17 2 R1,R2 1.2k +18 1 R3 120 +19 4 R4,R5,R6,R8 2.2k +20 2 R7,R11 680 +21 1 R10 2.4k +22 1 R12 4.46k 1% (1k - 10k) +23 1 U1 75176 +24 1 U2 MAX232 +25 1 U3 PTN78060H +26 1 U4 LM7805C/TO220 diff --git a/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64.DSN b/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64.DSN index 8c12ccf..5b4980d 100644 Binary files a/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64.DSN and b/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64.DSN differ diff --git a/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64_0.DBK b/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64_0.DBK index 0ec1416..82b13c2 100644 Binary files a/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64_0.DBK and b/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64_0.DBK differ diff --git a/elec/boards/Interface_RX64/Schematic/Interface_RX64.opj b/elec/boards/Interface_RX64/Schematic/Interface_RX64.opj index 97ab604..0c2233c 100644 --- a/elec/boards/Interface_RX64/Schematic/Interface_RX64.opj +++ b/elec/boards/Interface_RX64/Schematic/Interface_RX64.opj @@ -18,8 +18,34 @@ (ANNOTATE_No_Page_Number_Change "FALSE") (ANNOTATE_Property_Combine "{Value}{Source Package}{POWER_GROUP}") (ANNOTATE_IncludeNonPrimitive "TRUE") - (ANNOTATE_Refdes_Control_Required "FALSE")) - (Folder "Outputs") + (ANNOTATE_Refdes_Control_Required "FALSE") + (Netlist_TAB "3") + (LAYOUT_Netlist_File + "C:\krobot\elec\boards\Interface_RX64\PCB\INTERFACE_RX64.MNL") + (LAYOUT_PCB_Footprint "{PCB Footprint}") + (TRUE) + (LAYOUT_Units "0") + (FALSE) + (FALSE) + (FALSE) + (BOM_Scope "0") + (BOM_Mode "0") + (BOM_Report_File + "C:\KROBOT\ELEC\BOARDS\INTERFACE_RX64\SCHEMATIC\INTERFACE_RX64.BOM") + (BOM_Merge_Include "FALSE") + (BOM_Property_Combine_7.0 "{Item}\t{Quantity}\t{Reference}\t{Value}") + (BOM_Header "Item\tQuantity\tReference\tPart") + (BOM_Include_File + "C:\KROBOT\ELEC\BOARDS\INTERFACE_RX64\SCHEMATIC\INTERFACE_RX64.INC") + (BOM_Include_File_Combine_7.0 "{Item}\t{Quantity}\t{Reference}\t{Value}") + (BOM_One_Part_Per_Line "FALSE") + (Open_BOM_in_Excel "FALSE") + (BOM_View_Output "FALSE")) + (Folder "Outputs" + (File "..\pcb\interface_rx64.mnl" + (Type "LAYOUT Netlist File")) + (File ".\interface_rx64.bom" + (Type "Report"))) (Folder "PSpice Resources" (Folder "Simulation Profiles") (Folder "Model Libraries" @@ -30,6 +56,28 @@ (Sort User))) (DefaultLibraryBrowseDirectory "library\PSpice") (PartMRUSelector + (BC857/PLP + (FullPartName "BC857/PLP.Normal") + (LibraryName + "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\PSPICE\PHIL_BJT.OLB") + (DeviceIndex "0")) + (BC857 + (FullPartName "BC857.Normal") + (LibraryName + "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\PSPICE\INFINEON_S_AFBJT.OLB") + (DeviceIndex "0")) + (CON6A + (FullPartName "CON6A.Normal") + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\CONNECTOR.OLB") + (DeviceIndex "0")) + (10BQ040 + (FullPartName "10BQ040.Normal") + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\PSPICE\IRF.OLB") + (DeviceIndex "0")) + ("RESISTOR VAR" + (FullPartName "RESISTOR VAR.Normal") + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\DISCRETE.OLB") + (DeviceIndex "0")) (BC557 (FullPartName "BC557.Normal") (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\TRANSISTOR.OLB") @@ -66,11 +114,7 @@ (Path "Design Resources") (Path "Design Resources" "C:\krobot\elec\boards\Interface_RX64\Schematic\interface_rx64.dsn") - (Path "Design Resources" - "C:\krobot\elec\boards\Interface_RX64\Schematic\interface_rx64.dsn" - "SCHEMATIC1") - (Select "Design Resources" - "C:\krobot\elec\boards\Interface_RX64\Schematic\interface_rx64.dsn")) + (Path "Outputs")) (HierarchyView) (Doc (Type "COrCapturePMDoc") diff --git a/elec/boards/Interface_RX64/Schematic/PDF/Interface_RX64-1.0.pdf b/elec/boards/Interface_RX64/Schematic/PDF/Interface_RX64-1.0.pdf index e38b843..a3aca9e 100644 Binary files a/elec/boards/Interface_RX64/Schematic/PDF/Interface_RX64-1.0.pdf and b/elec/boards/Interface_RX64/Schematic/PDF/Interface_RX64-1.0.pdf differ diff --git a/elec/lib/OrCAD/KROBOT.LLB b/elec/lib/OrCAD/KROBOT.LLB index 67b670a..2c045c6 100644 Binary files a/elec/lib/OrCAD/KROBOT.LLB and b/elec/lib/OrCAD/KROBOT.LLB differ hooks/post-receive -- krobot |
From: oiffrig <Ba...@us...> - 2010-04-14 20:09:24
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 2b6c7dfb2636bdac047f6a806115ce8ba6f94f22 (commit) from 7c1772702d7a499ec6e688a8f9a91f545511f161 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 2b6c7dfb2636bdac047f6a806115ce8ba6f94f22 Author: Olivier Iffrig <if...@cr...> Date: Wed Apr 14 22:08:09 2010 +0200 Correction du positionnement des AX-12 sur la plaque ----------------------------------------------------------------------- Changes: diff --git a/meca/2010_Junior/Ascenseur.CATProduct b/meca/2010_Junior/Ascenseur.CATProduct index aa5108b..c777f6c 100644 Binary files a/meca/2010_Junior/Ascenseur.CATProduct and b/meca/2010_Junior/Ascenseur.CATProduct differ diff --git a/meca/2010_Junior/Assemblage.CATProduct b/meca/2010_Junior/Assemblage.CATProduct index 0265ed0..f35f43b 100644 Binary files a/meca/2010_Junior/Assemblage.CATProduct and b/meca/2010_Junior/Assemblage.CATProduct differ diff --git a/meca/2010_Junior/Etage 1.CATPart b/meca/2010_Junior/Etage 1.CATPart index ee9ce8b..e6d488d 100644 Binary files a/meca/2010_Junior/Etage 1.CATPart and b/meca/2010_Junior/Etage 1.CATPart differ diff --git a/meca/2010_Junior/Pince.CATProduct b/meca/2010_Junior/Pince.CATProduct index e4ae38b..4dae23f 100644 Binary files a/meca/2010_Junior/Pince.CATProduct and b/meca/2010_Junior/Pince.CATProduct differ diff --git a/meca/2010_Junior/Plaque pinces.CATPart b/meca/2010_Junior/Plaque pinces.CATPart index 2e081f5..d432908 100644 Binary files a/meca/2010_Junior/Plaque pinces.CATPart and b/meca/2010_Junior/Plaque pinces.CATPart differ diff --git a/meca/2010_Junior/Sol.CATPart b/meca/2010_Junior/Sol.CATPart new file mode 100644 index 0000000..319c789 Binary files /dev/null and b/meca/2010_Junior/Sol.CATPart differ hooks/post-receive -- krobot |
From: Olivier B. <Ba...@us...> - 2010-04-11 17:58:26
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 7c1772702d7a499ec6e688a8f9a91f545511f161 (commit) from 0b331c6010986998758ff5da2825209200562d32 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7c1772702d7a499ec6e688a8f9a91f545511f161 Author: unknown <Olivier@.(none)> Date: Sun Apr 11 19:57:52 2010 +0200 Added first draft of RX-64 Interface board (well, actually it's more a release candidate already, for the schematic) ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64.DSN b/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64.DSN new file mode 100644 index 0000000..8c12ccf Binary files /dev/null and b/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64.DSN differ diff --git a/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64_0.DBK b/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64_0.DBK new file mode 100644 index 0000000..0ec1416 Binary files /dev/null and b/elec/boards/Interface_RX64/Schematic/INTERFACE_RX64_0.DBK differ diff --git a/elec/boards/Interface_RX64/Schematic/Interface_RX64.opj b/elec/boards/Interface_RX64/Schematic/Interface_RX64.opj new file mode 100644 index 0000000..97ab604 --- /dev/null +++ b/elec/boards/Interface_RX64/Schematic/Interface_RX64.opj @@ -0,0 +1,92 @@ +(ExpressProject "Interface_RX64" + (ProjectVersion "19981106") + (ProjectType "Analog or A/D Mixed Mode") + (Folder "Design Resources" + (Folder "Library" + (File "c:\krobot\elec\lib\orcad\krobot.olb" + (Type "Schematic Library"))) + (NoModify) + (File ".\interface_rx64.dsn" + (Type "Schematic Design")) + (BuildFileAddedOrDeleted "x") + (CompileFileAddedOrDeleted "x") + (ANNOTATE_Scope "0") + (ANNOTATE_Mode "1") + (ANNOTATE_Action "0") + (Annotate_Page_Order "0") + (ANNOTATE_Reset_References_to_1 "FALSE") + (ANNOTATE_No_Page_Number_Change "FALSE") + (ANNOTATE_Property_Combine "{Value}{Source Package}{POWER_GROUP}") + (ANNOTATE_IncludeNonPrimitive "TRUE") + (ANNOTATE_Refdes_Control_Required "FALSE")) + (Folder "Outputs") + (Folder "PSpice Resources" + (Folder "Simulation Profiles") + (Folder "Model Libraries" + (Sort User)) + (Folder "Stimulus Files" + (Sort User)) + (Folder "Include Files" + (Sort User))) + (DefaultLibraryBrowseDirectory "library\PSpice") + (PartMRUSelector + (BC557 + (FullPartName "BC557.Normal") + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\TRANSISTOR.OLB") + (DeviceIndex "0")) + (PTN78060 + (FullPartName "PTN78060.Normal") + (LibraryName "C:\KROBOT\ELEC\LIB\ORCAD\KROBOT.OLB") + (DeviceIndex "0")) + (R + (FullPartName "R.Normal") + (LibraryName + "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\PSPICE\ANALOG.OLB") + (DeviceIndex "0")) + (JUMPER1 + (FullPartName "JUMPER1.Normal") + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\CONNECTOR.OLB") + (DeviceIndex "0")) + (75176 + (FullPartName "75176.Normal") + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\MISC3.OLB") + (DeviceIndex "0")) + (VCC_ARROW + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\CAPSYM.OLB") + (DeviceIndex "0")) + (GND + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\CAPSYM.OLB") + (DeviceIndex "0")) + (CON4 + (FullPartName "CON4.Normal") + (LibraryName "C:\ORCAD\ORCAD_16.0\TOOLS\CAPTURE\LIBRARY\CONNECTOR.OLB") + (DeviceIndex "0"))) + (GlobalState + (FileView + (Path "Design Resources") + (Path "Design Resources" + "C:\krobot\elec\boards\Interface_RX64\Schematic\interface_rx64.dsn") + (Path "Design Resources" + "C:\krobot\elec\boards\Interface_RX64\Schematic\interface_rx64.dsn" + "SCHEMATIC1") + (Select "Design Resources" + "C:\krobot\elec\boards\Interface_RX64\Schematic\interface_rx64.dsn")) + (HierarchyView) + (Doc + (Type "COrCapturePMDoc") + (Frame + (Placement "44 0 1 -1 -1 -1 -1 0 318 0 998")) + (Tab 0)) + (Doc + (Type "COrSchematicDoc") + (Frame + (Placement "44 0 1 -1 -1 -1 -1 319 1885 1 1068") + (Scroll "0 0") + (Zoom "136") + (Occurrence "/")) + (Path "C:\KROBOT\ELEC\BOARDS\INTERFACE_RX64\SCHEMATIC\INTERFACE_RX64.DSN") + (Schematic "SCHEMATIC1") + (Page "PAGE1"))) + (LastUsedLibraryBrowseDirectory + "C:\OrCAD\OrCAD_16.0\tools\capture\library\pspice") + (MPSSessionName "Olivier")) diff --git a/elec/boards/Interface_RX64/Schematic/PDF/Interface_RX64-1.0.pdf b/elec/boards/Interface_RX64/Schematic/PDF/Interface_RX64-1.0.pdf new file mode 100644 index 0000000..e38b843 Binary files /dev/null and b/elec/boards/Interface_RX64/Schematic/PDF/Interface_RX64-1.0.pdf differ diff --git a/elec/lib/OrCAD/KROBOT.OLB b/elec/lib/OrCAD/KROBOT.OLB index 5cbb280..61c2138 100644 Binary files a/elec/lib/OrCAD/KROBOT.OLB and b/elec/lib/OrCAD/KROBOT.OLB differ hooks/post-receive -- krobot |
From: oiffrig <Ba...@us...> - 2010-04-11 12:27:08
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 0b331c6010986998758ff5da2825209200562d32 (commit) from 643f8ebac80f42764a1bca95dd47bfee26441261 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0b331c6010986998758ff5da2825209200562d32 Author: Olivier Iffrig <if...@cr...> Date: Sun Apr 11 14:24:59 2010 +0200 Nouvelle méca pour le robot Junior (avec ascenseur + 3 pinces) ----------------------------------------------------------------------- Changes: diff --git a/meca/2010_Junior/Ascenseur.CATProduct b/meca/2010_Junior/Ascenseur.CATProduct new file mode 100644 index 0000000..aa5108b Binary files /dev/null and b/meca/2010_Junior/Ascenseur.CATProduct differ diff --git a/meca/2010_Junior/Assemblage.CATProduct b/meca/2010_Junior/Assemblage.CATProduct index 6c658aa..0265ed0 100644 Binary files a/meca/2010_Junior/Assemblage.CATProduct and b/meca/2010_Junior/Assemblage.CATProduct differ diff --git a/meca/2010_Junior/Axe entrainement porte.CATPart b/meca/2010_Junior/Axe entrainement porte.CATPart deleted file mode 100644 index 13bf5fb..0000000 Binary files a/meca/2010_Junior/Axe entrainement porte.CATPart and /dev/null differ diff --git a/meca/2010_Junior/Axe porte.CATPart b/meca/2010_Junior/Axe porte.CATPart deleted file mode 100644 index 2744d94..0000000 Binary files a/meca/2010_Junior/Axe porte.CATPart and /dev/null differ diff --git a/meca/2010_Junior/Baguette entrainement porte.CATPart b/meca/2010_Junior/Baguette entrainement porte.CATPart deleted file mode 100644 index 646e00a..0000000 Binary files a/meca/2010_Junior/Baguette entrainement porte.CATPart and /dev/null differ diff --git a/meca/2010_Junior/Base.CATPart b/meca/2010_Junior/Base.CATPart index f143d03..50d846a 100644 Binary files a/meca/2010_Junior/Base.CATPart and b/meca/2010_Junior/Base.CATPart differ diff --git a/meca/2010_Junior/Bras.CATProduct b/meca/2010_Junior/Bras.CATProduct deleted file mode 100644 index e32e2f8..0000000 Binary files a/meca/2010_Junior/Bras.CATProduct and /dev/null differ diff --git a/meca/2010_Junior/Entrainement porte.CATProduct b/meca/2010_Junior/Entrainement porte.CATProduct deleted file mode 100644 index cadab97..0000000 Binary files a/meca/2010_Junior/Entrainement porte.CATProduct and /dev/null differ diff --git a/meca/2010_Junior/Etage 1.CATPart b/meca/2010_Junior/Etage 1.CATPart index e38dd3d..ee9ce8b 100644 Binary files a/meca/2010_Junior/Etage 1.CATPart and b/meca/2010_Junior/Etage 1.CATPart differ diff --git a/meca/2010_Junior/Etage 2.CATPart b/meca/2010_Junior/Etage 2.CATPart new file mode 100644 index 0000000..3e069f0 Binary files /dev/null and b/meca/2010_Junior/Etage 2.CATPart differ diff --git a/meca/2010_Junior/Guide porte.CATPart b/meca/2010_Junior/Guide porte.CATPart deleted file mode 100644 index cc4fa83..0000000 Binary files a/meca/2010_Junior/Guide porte.CATPart and /dev/null differ diff --git a/meca/2010_Junior/L bras 2.CATPart b/meca/2010_Junior/L bras 2.CATPart deleted file mode 100644 index ef93858..0000000 Binary files a/meca/2010_Junior/L bras 2.CATPart and /dev/null differ diff --git a/meca/2010_Junior/L bras.CATPart b/meca/2010_Junior/L bras.CATPart deleted file mode 100644 index a69c1f6..0000000 Binary files a/meca/2010_Junior/L bras.CATPart and /dev/null differ diff --git a/meca/2010_Junior/L plan incline long.CATPart b/meca/2010_Junior/L plan incline long.CATPart deleted file mode 100644 index abffec5..0000000 Binary files a/meca/2010_Junior/L plan incline long.CATPart and /dev/null differ diff --git a/meca/2010_Junior/L plan incline.CATPart b/meca/2010_Junior/L plan incline.CATPart deleted file mode 100644 index fd0b939..0000000 Binary files a/meca/2010_Junior/L plan incline.CATPart and /dev/null differ diff --git a/meca/2010_Junior/Pince.CATProduct b/meca/2010_Junior/Pince.CATProduct new file mode 100644 index 0000000..e4ae38b Binary files /dev/null and b/meca/2010_Junior/Pince.CATProduct differ diff --git a/meca/2010_Junior/Plaque horizontale.CATPart b/meca/2010_Junior/Plaque horizontale.CATPart deleted file mode 100644 index 196ecdd..0000000 Binary files a/meca/2010_Junior/Plaque horizontale.CATPart and /dev/null differ diff --git a/meca/2010_Junior/Plaque pinces.CATPart b/meca/2010_Junior/Plaque pinces.CATPart new file mode 100644 index 0000000..2e081f5 Binary files /dev/null and b/meca/2010_Junior/Plaque pinces.CATPart differ diff --git a/meca/2010_Junior/Plaque porte.CATPart b/meca/2010_Junior/Plaque porte.CATPart deleted file mode 100644 index 9887153..0000000 Binary files a/meca/2010_Junior/Plaque porte.CATPart and /dev/null differ diff --git a/meca/2010_Junior/Plaque verticale.CATPart b/meca/2010_Junior/Plaque verticale.CATPart deleted file mode 100644 index 1d7975e..0000000 Binary files a/meca/2010_Junior/Plaque verticale.CATPart and /dev/null differ diff --git a/meca/2010_Junior/Porte.CATProduct b/meca/2010_Junior/Porte.CATProduct deleted file mode 100644 index 786d4b2..0000000 Binary files a/meca/2010_Junior/Porte.CATProduct and /dev/null differ diff --git a/meca/2010_Junior/U bras.CATPart b/meca/2010_Junior/U bras.CATPart deleted file mode 100644 index 3a0e885..0000000 Binary files a/meca/2010_Junior/U bras.CATPart and /dev/null differ diff --git a/meca/Common/Axe L12-50.CATPart b/meca/Common/Axe L12-50.CATPart new file mode 100644 index 0000000..2f66d98 Binary files /dev/null and b/meca/Common/Axe L12-50.CATPart differ diff --git a/meca/Common/Corps L12-50.CATPart b/meca/Common/Corps L12-50.CATPart new file mode 100644 index 0000000..dc5eae2 Binary files /dev/null and b/meca/Common/Corps L12-50.CATPart differ diff --git a/meca/Common/Fixation L12-50.CATPart b/meca/Common/Fixation L12-50.CATPart new file mode 100644 index 0000000..cb0a649 Binary files /dev/null and b/meca/Common/Fixation L12-50.CATPart differ diff --git a/meca/Common/KB-8-WW.CATPart b/meca/Common/KB-8-WW.CATPart new file mode 100644 index 0000000..41b4460 Binary files /dev/null and b/meca/Common/KB-8-WW.CATPart differ diff --git a/meca/Common/L12-50.CATProduct b/meca/Common/L12-50.CATProduct new file mode 100644 index 0000000..e51a9dd Binary files /dev/null and b/meca/Common/L12-50.CATProduct differ diff --git a/meca/Common/Z-8-1000A 190mm M4.CATPart b/meca/Common/Z-8-1000A 190mm M4.CATPart new file mode 100644 index 0000000..4db40dd Binary files /dev/null and b/meca/Common/Z-8-1000A 190mm M4.CATPart differ hooks/post-receive -- krobot |
From: Jérémie D. <Ba...@us...> - 2010-04-07 19:12:24
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 643f8ebac80f42764a1bca95dd47bfee26441261 (commit) from 1bd61bc9f4c1d64e4c371681792b22414565379f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 643f8ebac80f42764a1bca95dd47bfee26441261 Author: Jérémie Dimino <je...@di...> Date: Wed Apr 7 21:11:57 2010 +0200 add the module Var ----------------------------------------------------------------------- Changes: diff --git a/info/control/common/var.ml b/info/control/common/var.ml new file mode 100644 index 0000000..178e7cd --- /dev/null +++ b/info/control/common/var.ml @@ -0,0 +1,21 @@ +(* + * var.ml + * ------ + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +type 'a t = { + signal : 'a React.signal; + setter : 'a -> unit; +} + +let create value = + let signal, setter = React.S.create value in + { signal = signal; setter = setter } + +let signal var = var.signal +let get var = React.S.value var.signal +let set var value = var.setter value diff --git a/info/control/common/var.mli b/info/control/common/var.mli new file mode 100644 index 0000000..d3777e1 --- /dev/null +++ b/info/control/common/var.mli @@ -0,0 +1,17 @@ +(* + * var.mli + * ------- + * Copyright : (c) 2010, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(** A pair of a signal and its setter *) + +type 'a t + +val create : 'a -> 'a t +val signal : 'a t -> 'a React.signal +val get : 'a t -> 'a +val set : 'a t -> 'a -> unit hooks/post-receive -- krobot |