diff options
-rw-r--r-- | stmhal/help.c | 29 | ||||
-rw-r--r-- | stmhal/main.c | 13 | ||||
-rw-r--r-- | stmhal/pybcdc.h | 92 |
3 files changed, 123 insertions, 11 deletions
diff --git a/stmhal/help.c b/stmhal/help.c index 25d3fcb57e..76dcb2f4ee 100644 --- a/stmhal/help.c +++ b/stmhal/help.c @@ -14,27 +14,36 @@ STATIC const char *help_text = "Specific commands for the board:\n" " pyb.info() -- print some general information\n" " pyb.gc() -- run the garbage collector\n" -" pyb.repl_info(<val>) -- enable/disable printing of info after each command\n" -" pyb.delay(<n>) -- wait for n milliseconds\n" -" pyb.udelay(<n>) -- wait for n microseconds\n" +" pyb.repl_info(val) -- enable/disable printing of info after each command\n" +" pyb.delay(n) -- wait for n milliseconds\n" +" pyb.udelay(n) -- wait for n microseconds\n" " pyb.switch() -- return True/False if switch pressed or not\n" -" pyb.Led(<n>) -- create Led object for LED n (n=1,2,3,4)\n" +" pyb.switch(f) -- call the given function when the switch is pressed\n" +" pyb.Led(n) -- create Led object for LED n (n=1,2,3,4)\n" " Led methods: on(), off(), toggle(), intensity(<n>)\n" -" pyb.Servo(<n>) -- create Servo object for servo n (n=1,2,3,4)\n" -" Servo methods: angle(<x>)\n" +" pyb.Servo(n) -- create Servo object for servo n (n=1,2,3,4)\n" +" Servo methods: calibrate(...), pulse_width([p]), angle([x, [t]]), speed([x, [t]])\n" " pyb.Accel() -- create an Accelerometer object\n" -" Accelerometer methods: x(), y(), z(), tilt()\n" +" Accelerometer methods: x(), y(), z(), tilt(), filtered_xyz()\n" " pyb.rng() -- get a 30-bit hardware random number\n" -" pyb.gpio(<port>) -- get port value (port='A4' for example)\n" -" pyb.gpio(<port>, <val>) -- set port value, True or False, 1 or 0\n" -" pyb.ADC(<port>) -- make an analog port object (port='C0' for example)\n" +" pyb.gpio_in(port, [m]) -- set IO port to input, mode m\n" +" pyb.gpio_out(port, [m]) -- set IO port to output, mode m\n" +" pyb.gpio(port) -- get digital port value\n" +" pyb.gpio(port, val) -- set digital port value, True or False, 1 or 0\n" +" pyb.ADC(port) -- make an analog port object\n" " ADC methods: read()\n" "\n" +"Ports are numbered X1-X12, X17-X22, Y1-Y12, or by their MCU name\n" +"Port input modes are: pyb.PULL_NONE, pyb.PULL_UP, pyb.PULL_DOWN\n" +"Port output modes are: pyb.PUSH_PULL, pyb.OPEN_DRAIN\n" +"\n" "Control commands:\n" " CTRL-A -- on a blank line, enter raw REPL mode\n" " CTRL-B -- on a blank line, enter normal REPL mode\n" " CTRL-C -- interrupt a running program\n" " CTRL-D -- on a blank line, do a soft reset of the board\n" +"\n" +"For further help on a specific object, type help(obj)\n" ; STATIC void pyb_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) { diff --git a/stmhal/main.c b/stmhal/main.c index e5ba67dc1d..64d9022aef 100644 --- a/stmhal/main.c +++ b/stmhal/main.c @@ -133,6 +133,10 @@ static const char fresh_main_py[] = "# main.py -- put your code here!\n" ; +static const char fresh_pybcdc_inf[] = +#include "pybcdc.h" +; + int main(void) { // TODO disable JTAG @@ -206,7 +210,9 @@ soft_reset: } HAL_Delay(20); if (i % 30 == 29) { - reset_mode = (reset_mode + 1) & 7; + if (++reset_mode > 3) { + reset_mode = 1; + } led_state(2, reset_mode & 1); led_state(3, reset_mode & 2); led_state(4, reset_mode & 4); @@ -310,6 +316,11 @@ soft_reset: // TODO check we could write n bytes f_close(&fp); + // create .inf driver file + f_open(&fp, "0:/pybcdc.inf", FA_WRITE | FA_CREATE_ALWAYS); + f_write(&fp, fresh_pybcdc_inf, sizeof(fresh_pybcdc_inf) - 1 /* don't count null terminator */, &n); + f_close(&fp); + // keep LED on for at least 200ms sys_tick_wait_at_least(start_tick, 200); led_state(PYB_LED_R2, 0); diff --git a/stmhal/pybcdc.h b/stmhal/pybcdc.h new file mode 100644 index 0000000000..44685a05ba --- /dev/null +++ b/stmhal/pybcdc.h @@ -0,0 +1,92 @@ +"; Windows USB CDC ACM Setup File\r\n" +"; Based on INF files which were:\r\n" +"; Copyright (c) 2000 Microsoft Corporation\r\n" +"; Copyright (C) 2007 Microchip Technology Inc.\r\n" +"; Likely to be covered by the MLPL as found at:\r\n" +"; <http://msdn.microsoft.com/en-us/cc300389.aspx#MLPL>.\r\n" +"\r\n" +"[Version]\r\n" +"Signature=\"$Windows NT$\"\r\n" +"Class=Ports\r\n" +"ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}\r\n" +"Provider=%MFGNAME%\r\n" +"LayoutFile=layout.inf\r\n" +"DriverVer=03/11/2010,5.1.2600.3\r\n" +"\r\n" +"[Manufacturer]\r\n" +"%MFGNAME%=DeviceList, NTamd64\r\n" +"\r\n" +"[DestinationDirs]\r\n" +"DefaultDestDir=12\r\n" +"\r\n" +";---------------------------------------------------------------------\r\n" +"; Windows 2000/XP/Server2003/Vista/Server2008/7 - 32bit Sections\r\n" +"\r\n" +"[DriverInstall.nt]\r\n" +"include=mdmcpq.inf\r\n" +"CopyFiles=DriverCopyFiles.nt\r\n" +"AddReg=DriverInstall.nt.AddReg\r\n" +"\r\n" +"[DriverCopyFiles.nt]\r\n" +"usbser.sys,,,0x20\r\n" +"\r\n" +"[DriverInstall.nt.AddReg]\r\n" +"HKR,,DevLoader,,*ntkern\r\n" +"HKR,,NTMPDriver,,usbser.sys\r\n" +"HKR,,EnumPropPages32,,\"MsPorts.dll,SerialPortPropPageProvider\"\r\n" +"\r\n" +"[DriverInstall.nt.Services]\r\n" +"AddService=usbser, 0x00000002, DriverService.nt\r\n" +"\r\n" +"[DriverService.nt]\r\n" +"DisplayName=%SERVICE%\r\n" +"ServiceType=1\r\n" +"StartType=3\r\n" +"ErrorControl=1\r\n" +"ServiceBinary=%12%\\usbser.sys\r\n" +"\r\n" +";---------------------------------------------------------------------\r\n" +"; Windows XP/Server2003/Vista/Server2008/7 - 64bit Sections\r\n" +"\r\n" +"[DriverInstall.NTamd64]\r\n" +"include=mdmcpq.inf\r\n" +"CopyFiles=DriverCopyFiles.NTamd64\r\n" +"AddReg=DriverInstall.NTamd64.AddReg\r\n" +"\r\n" +"[DriverCopyFiles.NTamd64]\r\n" +"usbser.sys,,,0x20\r\n" +"\r\n" +"[DriverInstall.NTamd64.AddReg]\r\n" +"HKR,,DevLoader,,*ntkern\r\n" +"HKR,,NTMPDriver,,usbser.sys\r\n" +"HKR,,EnumPropPages32,,\"MsPorts.dll,SerialPortPropPageProvider\"\r\n" +"\r\n" +"[DriverInstall.NTamd64.Services]\r\n" +"AddService=usbser, 0x00000002, DriverService.NTamd64\r\n" +"\r\n" +"[DriverService.NTamd64]\r\n" +"DisplayName=%SERVICE%\r\n" +"ServiceType=1\r\n" +"StartType=3\r\n" +"ErrorControl=1\r\n" +"ServiceBinary=%12%\\usbser.sys\r\n" +"\r\n" +";---------------------------------------------------------------------\r\n" +"; Vendor and Product ID Definitions\r\n" +"\r\n" +"[SourceDisksFiles]\r\n" +"[SourceDisksNames]\r\n" +"[DeviceList]\r\n" +"%DESCRIPTION%=DriverInstall, USB\\VID_0483&PID_5740&MI_00, USB\\VID_0483&PID_5740&MI_01\r\n" +"\r\n" +"[DeviceList.NTamd64]\r\n" +"%DESCRIPTION%=DriverInstall, USB\\VID_0483&PID_5740&MI_00, USB\\VID_0483&PID_5740&MI_01\r\n" +"\r\n" +";---------------------------------------------------------------------\r\n" +"; String Definitions\r\n" +"\r\n" +"[Strings]\r\n" +"MFGFILENAME=\"pybcdc\"\r\n" +"MFGNAME=\"Micro Python\"\r\n" +"DESCRIPTION=\"Pyboard USB Comm Port\"\r\n" +"SERVICE=\"USB Serial Driver\"\r\n" |