Commit Graph

232 Commits

Author SHA1 Message Date
Glenn Ruben Bakke 5fb937f147 nrf5/modules/pin: Adding on() and off() methods to Pin object to be forward compatible with upstream master. Legacy high() and low() methods are kept. 2017-05-28 21:11:03 +02:00
Glenn Ruben Bakke f3909c49f5 nrf5/modules/spi: Remove pyb abstraction from SPI module, as there was a bug in transfer of bytes due to casting errors. The update removes the pyb_spi_obj_t wrapper going directly on the machine_hard_spi_obj_t as base for machine SPI objects. SDCard mounting is also tested. 2017-05-28 19:35:07 +02:00
Glenn Ruben Bakke aba5fcbf0f nrf5/main: Move initializaton of modmusic to the module itself. Upon init of the module, the hardware, pwm and ticker will be started. Could be moved back to main if pwm or ticker should be shared among more modules and have to be initialized more global. 2017-05-25 00:25:14 +02:00
Glenn Ruben Bakke d9813910da nrf5/modules/machine/timer: If timer is used in combination with SOFT_PWM (implicitly use of ticker.c) guard the Timer1 instance from being instantiated trough python timer module. Also disable implementation of the HAL IRQ handler which is for now explicitly implemented in ticker.c for Timer1. 2017-05-25 00:25:14 +02:00
Glenn Ruben Bakke aa9ad6be01 nrf5/modules/music: Update ticker and modmusic to share global ticks counter as a volatile variable. Use Timer1 hardware peripheral instead of instance 0. Timer0 is not free if used in combination with a bluetooth stack. Update IRQ priority to levels that are compatible in use with a bluetooth stack for both nrf51 and nrf52. Apply nrf51 PAN fixes for Timer1 instead of original Timer0. 2017-05-25 00:25:14 +02:00
Glenn Ruben Bakke c7cc57eaa0 nrf5/modules/machine: Updating IRQ levels in SPI with IRQ priorities compatible with Bluetooth stacks. 2017-05-25 00:24:50 +02:00
Glenn Ruben Bakke 952c14c4bf nrf5/modules/machine: Quickfix. Update timer object to not allow instanciation of Timer(0) if SOFT_PWM is enabled by board. 2017-05-18 23:11:41 +02:00
Glenn Ruben Bakke 234c9f3688 nrf5/drivers/softpwm: Renaming pwm_init to softpwm_init to not collide on symbol name with pwm_init in nrf52 machine PWM object. 2017-05-18 23:11:41 +02:00
Glenn Ruben Bakke 6330fd4f31 nrf5/modules/music: Expose public init function for music module. 2017-05-18 23:11:41 +02:00
Glenn Ruben Bakke d412241143 nrf5/modules/music: Update modmusic to use updated includes. Add extern ticks. Add function which implements initialization of pwm and ticker, register ticker callback, and start the pwm and ticker. This corresponds to microbit port main.cpp init. 2017-05-18 23:11:41 +02:00
Glenn Ruben Bakke 02e215dc59 nrf5/modules/ubluepy: Making peripheral conn_handle volatile. Upon connection event, the variable is accessed in thread mode. However, the main-loop is blocking on conn_handle != 0xFFFF. If this is not volatile, optimized code will not exit the loop. 2017-05-15 23:01:29 +02:00
Glenn Ruben Bakke 63805bac9c nrf5/modules/ubluepy: Correcting alignment of enum values in modubluepy.h. 2017-05-14 19:58:10 +02:00
Glenn Ruben Bakke 8f423c26d0 nrf5/modules/ubluepy: Pass on buffer to write in characteristic write central mode. 2017-05-14 19:58:10 +02:00
Glenn Ruben Bakke ceb2602005 nrf5/modules/ubluepy: Updating characteristic object write function to be role aware. Either peripheral or central (gatts or gattc). Adding dummy call to attr_c_write if central is compiled in. Still in progress to be implemented. 2017-05-14 19:58:10 +02:00
Glenn Ruben Bakke fd52691f02 nrf5/drivers/bluetooth: Renaming attr_write and attr_notify to attr_s_write and attr_s_notify to prepare for introduction of attribute write for gatt client. 2017-05-14 19:58:10 +02:00
Glenn Ruben Bakke 5d9c191a19 nrf5/modules/ubluepy: Fixing type in ubluepy_peripheral.c. 2017-05-14 19:58:10 +02:00
Glenn Ruben Bakke cf0d2bb457 nrf5/modules/ubluepy: Setting peripheral role upon advertise() or connect(). 2017-05-14 19:58:10 +02:00
Glenn Ruben Bakke f8c0ff6413 nrf5/drivers/bluetooth: Adding role member to peripheral object to indicate whether Peripheral object is Peripheral or Central role. 2017-05-14 19:58:10 +02:00
Glenn Ruben Bakke 78c0821216 nrf5/modules/ubluepy: Continue characteristic discovery until nothing more is found during connect proceedure. 2017-05-14 18:06:42 +02:00
Glenn Ruben Bakke 370c20ff6c nrf5/modules/ubluepy: Continue primary service discovery until nothing more is found in connect proceedure. 2017-05-13 18:12:15 +02:00
Glenn Ruben Bakke 3420843774 nrf5/modules/ubluepy: Remove duplication GAP event handler registration in peripheral.connect(). 2017-05-13 16:17:03 +02:00
glennrub 4584ef4ace Support address types (#18)
* nrf5/modules/ubluepy: Adding new enumeration of address types.

* nrf5/modules/ubluepy: Adding constants that can be used from micropython for public and random static address types.

* nrf5/modules/ubluepy: Adding support for optionally setting address type in Peripheral.connect(). Public address is used as default. Address types can be retrieved from 'constants'. Either constants.ADDR_TYPE_PUBLIC or constants.ADDR_TYPE_RANDOM_STATIC.

* nrf5/modules/ubluepy: Register central GAP event handler before issuing connect to a peripheral. Has to be done before connect() function as a connected event will be propergated upon successfull connection. The handler will set the connection handle which gets connect function out of the busy loop waiting for connection to succeed.

* nrf5/modules/ubluepy: Removing duplicate setting of GAP event handler in connect().
2017-05-13 16:12:14 +02:00
Glenn Ruben Bakke 0865fbd92d nrf5/modules/ubluepy: Register central GAP event handler before issuing connect to a peripheral. Has to be done before connect() function as a connected event will be propergated upon successfull connection. The handler will set the connection handle which gets connect function out of the busy loop waiting for connection to succeed. 2017-05-13 15:06:58 +02:00
Glenn Ruben Bakke 18e73d4214 nrf5/modules/ubluepy: Fixing compilation bug of wrong variable name when registering gattc event handler in ublupy peripheral connect function (central mode). 2017-05-12 20:11:30 +02:00
Glenn Ruben Bakke d61dcf18fb nrf5/bluetooth: Moving help_sd.h and modble.c to modules/ble. 2017-05-11 19:13:20 +02:00
Glenn Ruben Bakke b245011259 nrf5/modules/machine: bugfix after changing to MP_ROM_PTR in machine module local dict. 2017-05-11 00:08:44 +02:00
Glenn Ruben Bakke 54656044f7 nrf5: Syncing code with upstream master and converting all module and method tables to use MP_ROM macros. Also adding explicit casting of local dicts to (mp_obj_dict_t*). 2017-05-09 22:54:58 +02:00
Glenn Ruben Bakke 00d96f5695 nrf5/modules/timer: Fixing bug in timer_find(). Function allowed to locate index out of range and started to look up in config pointer (index == size of array). 2017-05-08 23:32:42 +02:00
Glenn Ruben Bakke 1063a44ec6 nrf5/modules/timer: Remove test which is covered by timer_find() function in the line below. 2017-05-08 23:31:14 +02:00
Glenn Ruben Bakke 2cf9e3e625 nrf5/modules/timer: Adding locals dict table and adding start/stop template functions. Also adding constants for oneshot and periodic to locals dict. 2017-05-08 23:24:15 +02:00
Glenn Ruben Bakke 9e6cca66b4 nrf5/modules/timer: Adding timer module to modmachine. 2017-05-08 23:09:15 +02:00
Glenn Ruben Bakke d3509517f5 nrf5/modules/music: Adding config guard in musictunes.c and adding import of mphal.h. 2017-05-08 22:05:23 +02:00
Glenn Ruben Bakke a84ed760b5 nrf5/modules/music: Including mphal.h before config guard in modmusic.c. Also changed name on config guard to MICROPY_PY_MUSIC. Missing PWM functions during linkage will show up if PWM module has not not configured. 2017-05-08 22:03:33 +02:00
Glenn Ruben Bakke c3ccef800d nrf5/modules/music: Backing up progress in music module. 2017-05-08 21:22:53 +02:00
Glenn Ruben Bakke 10cbc83cf0 nrf5/pwm: Updating config name of PWM to hardware PWM to prepare for introduction of soft variant. 2017-05-08 21:10:18 +02:00
Glenn Ruben Bakke 311ae77dc0 nrf5/modules/music: Backing up progress in modmusic. 2017-05-04 00:18:05 +02:00
Glenn Ruben Bakke a7f10336e1 nrf5/modules/music: backing up porting progress in modmusic.c. 2017-05-02 22:40:31 +02:00
Glenn Ruben Bakke d170ca5d03 nrf5/modules/music: Commenting out backend function calls in modmusic.c to make module compile for now. 2017-05-02 21:50:54 +02:00
Glenn Ruben Bakke 57442c2b25 nrf5/modules/music: Updating music module to use pin_obj_t instad of microbit_pin_obj_t. Update include to drivers/pwm.h to resolve some undefined functions. 2017-05-02 01:09:59 +02:00
Glenn Ruben Bakke 10e6b4309b nrf5/modules/music: Removing c++ extern definition. Updating include list in modmusic.c. Removing module name from module struct. 2017-05-01 19:55:43 +02:00
Glenn Ruben Bakke 01441c8f59 nrf5/modules/music: Removing include of modmicrobit.h in musictunes.c. 2017-05-01 19:52:40 +02:00
Glenn Ruben Bakke e766c7ebbe nrf5/modules/music: Adding header to expose extern structs defined in musictunes.c 2017-05-01 19:51:47 +02:00
Glenn Ruben Bakke eedd9eabe9 nrf5/modules/music: Renaming microbitmusic files to modmusic/music. 2017-05-01 19:11:44 +02:00
Glenn Ruben Bakke 20bdb7dc90 nrf5/modules/music: Renaming microbit module to music. 2017-05-01 19:08:36 +02:00
Glenn Ruben Bakke f9b9d59434 nrf5/modules/microbit: Copying microbit music module to the port. 2017-05-01 19:06:49 +02:00
Glenn Ruben Bakke 1c756af9a4 nrf5/modules/timer: Adding timer3 and timer4 to timer object in case of nrf52 target. 2017-04-30 20:18:46 +02:00
Glenn Ruben Bakke a0638880b3 nrf5/modules/timer: Optimizing timer object structure and updating the module to use new hal_timer_init structures and parameters. 2017-04-30 20:15:03 +02:00
Glenn Ruben Bakke 7449f8d861 nrf5/hal/timer: Changing hardcoded hal timer instance base to a lookup, so that IRQ num can be detected automatically without the need of using struct param on it. Size of binary does not increase when using Os. 2017-04-30 19:42:19 +02:00
Glenn Ruben Bakke 071e551b79 nrf5/modules/machine: Updating PWM module with two new kwargs parameters. One for setting pulse with more fine grained. This value should not exceed the period value. Also, adding support for setting PWM mode, whether it is LOW duty cycle or HIGH duty cycle. By default, high to low is set (this could be changed). 2017-04-18 21:00:52 +02:00
Glenn Ruben Bakke 1e79bdf0b4 nrf5/modules/machine: Updating Pin module to register a IRQ callback upon GPIO polarity change events. 2017-04-11 13:58:58 +02:00