Did usb_hid, usb_midi, ustack, wiznet
This commit is contained in:
parent
e4589543fb
commit
6490137812
|
@ -27,27 +27,28 @@
|
|||
#include "py/objproperty.h"
|
||||
#include "shared-bindings/usb_hid/Device.h"
|
||||
|
||||
//| .. currentmodule:: usb_hid
|
||||
//| class Device:
|
||||
//| """.. currentmodule:: usb_hid
|
||||
//|
|
||||
//| :class:`Device` -- HID Device
|
||||
//| ============================================
|
||||
//| :class:`Device` -- HID Device
|
||||
//| ============================================
|
||||
//|
|
||||
//| Usage::
|
||||
//| Usage::
|
||||
//|
|
||||
//| import usb_hid
|
||||
//| import usb_hid
|
||||
//|
|
||||
//| mouse = usb_hid.devices[0]
|
||||
//| mouse = usb_hid.devices[0]
|
||||
//|
|
||||
//| mouse.send_report()
|
||||
//| mouse.send_report()"""
|
||||
//|
|
||||
|
||||
//| .. class:: Device()
|
||||
//| def __init__(self, ):
|
||||
//| """Not currently dynamically supported."""
|
||||
//| ...
|
||||
//|
|
||||
//| Not currently dynamically supported.
|
||||
//|
|
||||
//| .. method:: send_report(buf)
|
||||
//|
|
||||
//| Send a HID report.
|
||||
//| def send_report(self, buf: Any) -> Any:
|
||||
//| """Send a HID report."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t usb_hid_device_send_report(mp_obj_t self_in, mp_obj_t buffer) {
|
||||
usb_hid_device_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
@ -60,9 +61,8 @@ STATIC mp_obj_t usb_hid_device_send_report(mp_obj_t self_in, mp_obj_t buffer) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(usb_hid_device_send_report_obj, usb_hid_device_send_report);
|
||||
|
||||
//| .. attribute:: usage_page
|
||||
//|
|
||||
//| The usage page of the device as an `int`. Can be thought of a category. (read-only)
|
||||
//| usage_page: Any = ...
|
||||
//| """The usage page of the device as an `int`. Can be thought of a category. (read-only)"""
|
||||
//|
|
||||
STATIC mp_obj_t usb_hid_device_obj_get_usage_page(mp_obj_t self_in) {
|
||||
usb_hid_device_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
@ -77,12 +77,11 @@ const mp_obj_property_t usb_hid_device_usage_page_obj = {
|
|||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
//| .. attribute:: usage
|
||||
//|
|
||||
//| The functionality of the device as an int. (read-only)
|
||||
//| usage: Any = ...
|
||||
//| """The functionality of the device as an int. (read-only)
|
||||
//|
|
||||
//| For example, Keyboard is 0x06 within the generic desktop usage page 0x01.
|
||||
//| Mouse is 0x02 within the same usage page.
|
||||
//| Mouse is 0x02 within the same usage page."""
|
||||
//|
|
||||
STATIC mp_obj_t usb_hid_device_obj_get_usage(mp_obj_t self_in) {
|
||||
usb_hid_device_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
|
|
@ -31,27 +31,27 @@
|
|||
#include "shared-bindings/usb_hid/__init__.h"
|
||||
#include "shared-bindings/usb_hid/Device.h"
|
||||
|
||||
//| :mod:`usb_hid` --- USB Human Interface Device
|
||||
//| """:mod:`usb_hid` --- USB Human Interface Device
|
||||
//| ===========================================================
|
||||
//|
|
||||
//| .. module:: usb_hid
|
||||
//| :synopsis: USB Human Interface Device
|
||||
//| :platform: SAMD21
|
||||
//|
|
||||
//| The `usb_hid` module allows you to output data as a HID device.
|
||||
//| The `usb_hid` module allows you to output data as a HID device."""
|
||||
//|
|
||||
|
||||
//| .. attribute:: usb_hid.devices
|
||||
//|
|
||||
//| Tuple of all active HID device interfaces.
|
||||
//| usb_hid.devices: Any = ...
|
||||
//| """Tuple of all active HID device interfaces."""
|
||||
//|
|
||||
|
||||
//| Libraries
|
||||
//| """Libraries
|
||||
//|
|
||||
//| .. toctree::
|
||||
//| :maxdepth: 3
|
||||
//|
|
||||
//| Device
|
||||
//| Device"""
|
||||
//|
|
||||
STATIC const mp_rom_map_elem_t usb_hid_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_devices), MP_ROM_PTR(&common_hal_usb_hid_devices) },
|
||||
|
|
|
@ -35,39 +35,39 @@
|
|||
#include "py/stream.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
|
||||
//| .. currentmodule:: usb_midi
|
||||
//| class PortIn:
|
||||
//| """.. currentmodule:: usb_midi
|
||||
//|
|
||||
//| :class:`PortIn` -- receives midi commands over USB
|
||||
//| ===================================================
|
||||
//| :class:`PortIn` -- receives midi commands over USB
|
||||
//| ==================================================="""
|
||||
//|
|
||||
//| .. class:: PortIn()
|
||||
//| def __init__(self, ):
|
||||
//| """You cannot create an instance of `usb_midi.PortIn`.
|
||||
//|
|
||||
//| You cannot create an instance of `usb_midi.PortIn`.
|
||||
//|
|
||||
//| PortIn objects are constructed for every corresponding entry in the USB
|
||||
//| descriptor and added to the ``usb_midi.ports`` tuple.
|
||||
//| PortIn objects are constructed for every corresponding entry in the USB
|
||||
//| descriptor and added to the ``usb_midi.ports`` tuple."""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
// These are standard stream methods. Code is in py/stream.c.
|
||||
//
|
||||
//| .. method:: read(nbytes=None)
|
||||
//| def read(self, nbytes: Any = None) -> Any:
|
||||
//| """Read characters. If ``nbytes`` is specified then read at most that many
|
||||
//| bytes. Otherwise, read everything that arrives until the connection
|
||||
//| times out. Providing the number of bytes expected is highly recommended
|
||||
//| because it will be faster.
|
||||
//|
|
||||
//| Read characters. If ``nbytes`` is specified then read at most that many
|
||||
//| bytes. Otherwise, read everything that arrives until the connection
|
||||
//| times out. Providing the number of bytes expected is highly recommended
|
||||
//| because it will be faster.
|
||||
//| :return: Data read
|
||||
//| :rtype: bytes or None"""
|
||||
//| ...
|
||||
//|
|
||||
//| :return: Data read
|
||||
//| :rtype: bytes or None
|
||||
//| def readinto(self, buf: Any, nbytes: Any = None) -> Any:
|
||||
//| """Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
|
||||
//| that many bytes. Otherwise, read at most ``len(buf)`` bytes.
|
||||
//|
|
||||
//| .. method:: readinto(buf, nbytes=None)
|
||||
//|
|
||||
//| Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
|
||||
//| that many bytes. Otherwise, read at most ``len(buf)`` bytes.
|
||||
//|
|
||||
//| :return: number of bytes read and stored into ``buf``
|
||||
//| :rtype: bytes or None
|
||||
//| :return: number of bytes read and stored into ``buf``
|
||||
//| :rtype: bytes or None"""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
// These three methods are used by the shared stream methods.
|
||||
|
|
|
@ -35,28 +35,27 @@
|
|||
#include "py/stream.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
|
||||
//| .. currentmodule:: usb_midi
|
||||
//| class PortOut:
|
||||
//| """.. currentmodule:: usb_midi
|
||||
//|
|
||||
//| :class:`PortOut` -- sends midi messages to a computer over USB
|
||||
//| ==============================================================
|
||||
//| :class:`PortOut` -- sends midi messages to a computer over USB
|
||||
//| =============================================================="""
|
||||
//|
|
||||
//| .. class:: PortOut()
|
||||
//| def __init__(self, ):
|
||||
//| """You cannot create an instance of `usb_midi.PortOut`.
|
||||
//|
|
||||
//| You cannot create an instance of `usb_midi.PortOut`.
|
||||
//|
|
||||
//| PortOut objects are constructed for every corresponding entry in the USB
|
||||
//| descriptor and added to the ``usb_midi.ports`` tuple.
|
||||
//| PortOut objects are constructed for every corresponding entry in the USB
|
||||
//| descriptor and added to the ``usb_midi.ports`` tuple."""
|
||||
//|
|
||||
|
||||
// These are standard stream methods. Code is in py/stream.c.
|
||||
//
|
||||
//| .. method:: write(buf)
|
||||
//| def write(self, buf: Any) -> Any:
|
||||
//| """Write the buffer of bytes to the bus.
|
||||
//|
|
||||
//| Write the buffer of bytes to the bus.
|
||||
//|
|
||||
//| :return: the number of bytes written
|
||||
//| :rtype: int or None
|
||||
//| :return: the number of bytes written
|
||||
//| :rtype: int or None"""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
STATIC mp_uint_t usb_midi_portout_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) {
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include "py/runtime.h"
|
||||
|
||||
//| :mod:`usb_midi` --- MIDI over USB
|
||||
//| """:mod:`usb_midi` --- MIDI over USB
|
||||
//| =================================================
|
||||
//|
|
||||
//| .. module:: usb_midi
|
||||
|
@ -49,7 +49,7 @@
|
|||
//| :maxdepth: 3
|
||||
//|
|
||||
//| PortIn
|
||||
//| PortOut
|
||||
//| PortOut"""
|
||||
//|
|
||||
//|
|
||||
mp_map_elem_t usb_midi_module_globals_table[] = {
|
||||
|
|
|
@ -31,17 +31,20 @@
|
|||
|
||||
#include "shared-bindings/ustack/__init__.h"
|
||||
|
||||
//| :mod:`ustack` --- Stack information and analysis
|
||||
|
||||
|
||||
|
||||
//| """:mod:`ustack` --- Stack information and analysis
|
||||
//| ========================================================
|
||||
//|
|
||||
//| .. module:: ustack
|
||||
//| :synopsis: stack information functions
|
||||
//| :synopsis: stack information functions"""
|
||||
//|
|
||||
|
||||
#if MICROPY_MAX_STACK_USAGE
|
||||
//| .. function:: max_stack_usage()
|
||||
//|
|
||||
//| Return the maximum excursion of the stack so far.
|
||||
//| def max_stack_usage() -> Any:
|
||||
//| """Return the maximum excursion of the stack so far."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t max_stack_usage(void) {
|
||||
return MP_OBJ_NEW_SMALL_INT(shared_module_ustack_max_stack_usage());
|
||||
|
@ -50,21 +53,21 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(max_stack_usage_obj, max_stack_usage);
|
|||
|
||||
#endif // MICROPY_MAX_STACK_USAGE
|
||||
|
||||
//| .. function:: stack_size()
|
||||
//|
|
||||
//| Return the size of the entire stack.
|
||||
//| Same as in micropython.mem_info(), but returns a value instead
|
||||
//| of just printing it.
|
||||
//| def stack_size() -> Any:
|
||||
//| """Return the size of the entire stack.
|
||||
//| Same as in micropython.mem_info(), but returns a value instead
|
||||
//| of just printing it."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t stack_size(void) {
|
||||
return MP_OBJ_NEW_SMALL_INT(shared_module_ustack_stack_size());
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(stack_size_obj, stack_size);
|
||||
|
||||
//| .. function:: stack_usage()
|
||||
//|
|
||||
//| Return how much stack is currently in use.
|
||||
//| Same as micropython.stack_use(); duplicated here for convenience.
|
||||
//| def stack_usage() -> Any:
|
||||
//| """Return how much stack is currently in use.
|
||||
//| Same as micropython.stack_use(); duplicated here for convenience."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t stack_usage(void) {
|
||||
return MP_OBJ_NEW_SMALL_INT(shared_module_ustack_stack_usage());
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include "shared-module/network/__init__.h"
|
||||
|
||||
//| :mod:`wiznet` --- Support for WizNet hardware
|
||||
//| """:mod:`wiznet` --- Support for WizNet hardware
|
||||
//| =============================================
|
||||
//|
|
||||
//| .. module:: wiznet
|
||||
|
@ -49,7 +49,7 @@
|
|||
//| .. toctree::
|
||||
//| :maxdepth: 3
|
||||
//|
|
||||
//| wiznet5k
|
||||
//| wiznet5k"""
|
||||
//|
|
||||
|
||||
extern const mod_network_nic_type_t mod_network_nic_type_wiznet5k;
|
||||
|
|
|
@ -46,25 +46,26 @@
|
|||
#include "shared-module/network/__init__.h"
|
||||
#include "shared-module/wiznet/wiznet5k.h"
|
||||
|
||||
//| .. currentmodule:: wiznet
|
||||
//| class WIZNET5K:
|
||||
//| """.. currentmodule:: wiznet
|
||||
//|
|
||||
//| :class:`WIZNET5K` -- wrapper for Wiznet 5500 Ethernet interface
|
||||
//| ===============================================================
|
||||
//| :class:`WIZNET5K` -- wrapper for Wiznet 5500 Ethernet interface
|
||||
//| ==============================================================="""
|
||||
//|
|
||||
//| .. class:: WIZNET5K(spi, cs, rst, dhcp=True)
|
||||
//| def __init__(self, spi: busio.SPI, cs: microcontroller.Pin, rst: microcontroller.Pin, dhcp: bool = True):
|
||||
//| """Create a new WIZNET5500 interface using the specified pins
|
||||
//|
|
||||
//| Create a new WIZNET5500 interface using the specified pins
|
||||
//| :param ~busio.SPI spi: spi bus to use
|
||||
//| :param ~microcontroller.Pin cs: pin to use for Chip Select
|
||||
//| :param ~microcontroller.Pin rst: pin to use for Reset (optional)
|
||||
//| :param bool dhcp: boolean flag, whether to start DHCP automatically (optional, keyword only, default True)
|
||||
//|
|
||||
//| :param ~busio.SPI spi: spi bus to use
|
||||
//| :param ~microcontroller.Pin cs: pin to use for Chip Select
|
||||
//| :param ~microcontroller.Pin rst: pin to use for Reset (optional)
|
||||
//| :param bool dhcp: boolean flag, whether to start DHCP automatically (optional, keyword only, default True)
|
||||
//|
|
||||
//| * The reset pin is optional: if supplied it is used to reset the
|
||||
//| wiznet board before initialization.
|
||||
//| * The SPI bus will be initialized appropriately by this library.
|
||||
//| * At present, the WIZNET5K object is a singleton, so only one WizNet
|
||||
//| interface is supported at a time.
|
||||
//| * The reset pin is optional: if supplied it is used to reset the
|
||||
//| wiznet board before initialization.
|
||||
//| * The SPI bus will be initialized appropriately by this library.
|
||||
//| * At present, the WIZNET5K object is a singleton, so only one WizNet
|
||||
//| interface is supported at a time."""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
|
@ -86,9 +87,8 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, cons
|
|||
return ret;
|
||||
}
|
||||
|
||||
//| .. attribute:: connected
|
||||
//|
|
||||
//| (boolean, readonly) is this device physically connected?
|
||||
//| connected: Any = ...
|
||||
//| """(boolean, readonly) is this device physically connected?"""
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t wiznet5k_connected_get_value(mp_obj_t self_in) {
|
||||
|
@ -104,11 +104,10 @@ const mp_obj_property_t wiznet5k_connected_obj = {
|
|||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
//| .. attribute:: dhcp
|
||||
//| dhcp: Any = ...
|
||||
//| """(boolean, readwrite) is DHCP active on this device?
|
||||
//|
|
||||
//| (boolean, readwrite) is DHCP active on this device?
|
||||
//|
|
||||
//| * set to True to activate DHCP, False to turn it off
|
||||
//| * set to True to activate DHCP, False to turn it off"""
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t wiznet5k_dhcp_get_value(mp_obj_t self_in) {
|
||||
|
@ -138,13 +137,13 @@ const mp_obj_property_t wiznet5k_dhcp_obj = {
|
|||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
//| .. method:: ifconfig(params=None)
|
||||
//| def ifconfig(self, params: Any = None) -> Any:
|
||||
//| """Called without parameters, returns a tuple of
|
||||
//| (ip_address, subnet_mask, gateway_address, dns_server)
|
||||
//|
|
||||
//| Called without parameters, returns a tuple of
|
||||
//| (ip_address, subnet_mask, gateway_address, dns_server)
|
||||
//|
|
||||
//| Or can be called with the same tuple to set those parameters.
|
||||
//| Setting ifconfig parameters turns DHCP off, if it was on.
|
||||
//| Or can be called with the same tuple to set those parameters.
|
||||
//| Setting ifconfig parameters turns DHCP off, if it was on."""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t wiznet5k_ifconfig(size_t n_args, const mp_obj_t *args) {
|
||||
|
|
Loading…
Reference in New Issue