Requested changes, general cleanup

crypto-aes
Hierophect 3 years ago
parent 172ab190b5
commit a63df51893
  1. 3
      .gitmodules
  2. 2
      main.c
  3. 10
      ports/stm32f4/Makefile
  4. 2
      ports/stm32f4/background.h
  5. 217
      ports/stm32f4/boards/DIS_F411RE/stm32f4xx_it.c
  6. 70
      ports/stm32f4/boards/DIS_F411RE/stm32f4xx_it.h
  7. 18
      ports/stm32f4/boards/DIS_F412ZG/mpconfigboard.mk
  8. 217
      ports/stm32f4/boards/DIS_F412ZG/stm32f4xx_it.c
  9. 70
      ports/stm32f4/boards/DIS_F412ZG/stm32f4xx_it.h
  10. 0
      ports/stm32f4/boards/stm32f411re_discovery/board.c
  11. 0
      ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h
  12. 2
      ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.mk
  13. 0
      ports/stm32f4/boards/stm32f411re_discovery/pins.c
  14. 2
      ports/stm32f4/boards/stm32f411re_discovery/stm32f4xx_hal_conf.h
  15. 0
      ports/stm32f4/boards/stm32f411re_discovery/stm32f4xx_hal_msp.c
  16. 0
      ports/stm32f4/boards/stm32f412zg_discovery/board.c
  17. 0
      ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h
  18. 13
      ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk
  19. 0
      ports/stm32f4/boards/stm32f412zg_discovery/pins.c
  20. 0
      ports/stm32f4/boards/stm32f412zg_discovery/stm32f4xx_hal_conf.h
  21. 0
      ports/stm32f4/boards/stm32f412zg_discovery/stm32f4xx_hal_msp.c
  22. 112
      ports/stm32f4/common-hal/analogio/AnalogIn.c
  23. 39
      ports/stm32f4/common-hal/analogio/AnalogIn.h
  24. 48
      ports/stm32f4/common-hal/analogio/AnalogOut.c
  25. 1
      ports/stm32f4/common-hal/analogio/__init__.c
  26. 152
      ports/stm32f4/common-hal/bleio/Adapter.c
  27. 37
      ports/stm32f4/common-hal/bleio/Adapter.h
  28. 98
      ports/stm32f4/common-hal/bleio/Broadcaster.c
  29. 47
      ports/stm32f4/common-hal/bleio/Broadcaster.h
  30. 287
      ports/stm32f4/common-hal/bleio/Characteristic.c
  31. 46
      ports/stm32f4/common-hal/bleio/Characteristic.h
  32. 140
      ports/stm32f4/common-hal/bleio/CharacteristicBuffer.c
  33. 43
      ports/stm32f4/common-hal/bleio/CharacteristicBuffer.h
  34. 42
      ports/stm32f4/common-hal/bleio/Descriptor.c
  35. 40
      ports/stm32f4/common-hal/bleio/Descriptor.h
  36. 601
      ports/stm32f4/common-hal/bleio/Device.c
  37. 346
      ports/stm32f4/common-hal/bleio/Peripheral.c
  38. 53
      ports/stm32f4/common-hal/bleio/Peripheral.h
  39. 108
      ports/stm32f4/common-hal/bleio/Scanner.c
  40. 100
      ports/stm32f4/common-hal/bleio/Service.c
  41. 98
      ports/stm32f4/common-hal/bleio/UUID.c
  42. 48
      ports/stm32f4/common-hal/bleio/UUID.h
  43. 68
      ports/stm32f4/common-hal/bleio/__init__.c
  44. 42
      ports/stm32f4/common-hal/bleio/__init__.h
  45. 252
      ports/stm32f4/common-hal/busio/I2C.c
  46. 47
      ports/stm32f4/common-hal/busio/I2C.h
  47. 33
      ports/stm32f4/common-hal/busio/OneWire.h
  48. 337
      ports/stm32f4/common-hal/busio/SPI.c
  49. 49
      ports/stm32f4/common-hal/busio/SPI.h
  50. 332
      ports/stm32f4/common-hal/busio/UART.c
  51. 52
      ports/stm32f4/common-hal/busio/UART.h
  52. 1
      ports/stm32f4/common-hal/busio/__init__.c
  53. 1
      ports/stm32f4/common-hal/digitalio/DigitalInOut.c
  54. 7
      ports/stm32f4/common-hal/digitalio/DigitalInOut.h
  55. 140
      ports/stm32f4/common-hal/displayio/ParallelBus.c
  56. 45
      ports/stm32f4/common-hal/displayio/ParallelBus.h
  57. 1
      ports/stm32f4/common-hal/microcontroller/Pin.c
  58. 6
      ports/stm32f4/common-hal/microcontroller/Processor.h
  59. 294
      ports/stm32f4/common-hal/neopixel_write/__init__.c
  60. 45
      ports/stm32f4/common-hal/nvm/ByteArray.c
  61. 6
      ports/stm32f4/common-hal/nvm/ByteArray.h
  62. 86
      ports/stm32f4/common-hal/os/__init__.c
  63. 275
      ports/stm32f4/common-hal/pulseio/PWMOut.c
  64. 45
      ports/stm32f4/common-hal/pulseio/PWMOut.h
  65. 282
      ports/stm32f4/common-hal/pulseio/PulseIn.c
  66. 53
      ports/stm32f4/common-hal/pulseio/PulseIn.h
  67. 164
      ports/stm32f4/common-hal/pulseio/PulseOut.c
  68. 42
      ports/stm32f4/common-hal/pulseio/PulseOut.h
  69. 1
      ports/stm32f4/common-hal/pulseio/__init__.c
  70. 116
      ports/stm32f4/common-hal/rotaryio/IncrementalEncoder.c
  71. 46
      ports/stm32f4/common-hal/rotaryio/IncrementalEncoder.h
  72. 1
      ports/stm32f4/common-hal/rotaryio/__init__.c
  73. 90
      ports/stm32f4/common-hal/rtc/RTC.c
  74. 33
      ports/stm32f4/common-hal/rtc/RTC.h
  75. 0
      ports/stm32f4/common-hal/rtc/__init__.c
  76. 6
      ports/stm32f4/common-hal/supervisor/Runtime.h
  77. 116
      ports/stm32f4/common-hal/touchio/TouchIn.c
  78. 43
      ports/stm32f4/common-hal/touchio/TouchIn.h
  79. 1
      ports/stm32f4/common-hal/touchio/__init__.c
  80. 74
      ports/stm32f4/mpconfigport.mk
  81. 4
      ports/stm32f4/mphalport.h
  82. 38
      ports/stm32f4/peripherals/stm32f4/cache.c
  83. 28
      ports/stm32f4/peripherals/stm32f4/cache.h
  84. 38
      ports/stm32f4/peripherals/stm32f4/clocks.c
  85. 4
      ports/stm32f4/peripherals/stm32f4/clocks.h
  86. 4
      ports/stm32f4/peripherals/stm32f4/gpio.h
  87. 95
      ports/stm32f4/peripherals/stm32f4/nvm.c
  88. 34
      ports/stm32f4/peripherals/stm32f4/nvm.h
  89. 3
      ports/stm32f4/peripherals/stm32f4/pins.h
  90. 63
      ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c
  91. 137
      ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c
  92. 15
      ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.c
  93. 16
      ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.h
  94. 40
      ports/stm32f4/peripherals/stm32f4/stm32f412zg/power.c
  95. 75
      ports/stm32f4/peripherals/stm32f4/stm32f412zx/clocks.c
  96. 218
      ports/stm32f4/peripherals/stm32f4/stm32f412zx/gpio.c
  97. 2
      ports/stm32f4/peripherals/stm32f4/stm32f412zx/pins.c
  98. 2
      ports/stm32f4/peripherals/stm32f4/stm32f412zx/pins.h
  99. 88
      ports/stm32f4/peripherals/stm32f4/timers.c
  100. 2
      ports/stm32f4/stm32f4
  101. Some files were not shown because too many files have changed in this diff Show More

3
.gitmodules vendored

@ -77,7 +77,6 @@
path = lib/tinyusb
url = https://github.com/hathach/tinyusb.git
branch = develop
ignore = dirty
[submodule "tools/huffman"]
path = tools/huffman
url = https://github.com/tannewt/huffman.git
@ -98,4 +97,4 @@
url = https://github.com/python-ugame/circuitpython-stage.git
[submodule "ports/stm32f4/stm32f4"]
path = ports/stm32f4/stm32f4
url = https://github.com/hierophect/stm32f4.git
url = https://github.com/adafruit/stm32f4.git

@ -190,7 +190,9 @@ void cleanup_after_vm(supervisor_allocation* heap) {
supervisor_move_memory();
reset_port();
#if CIRCUITPY_BOARD
reset_board_busses();
#endif
reset_board();
reset_status_led();
}

@ -40,6 +40,7 @@ include ../../py/mkenv.mk
include boards/$(BOARD)/mpconfigboard.mk
# Port-specific
include mpconfigport.mk
# CircuitPython-specific
include $(TOP)/py/circuitpy_mpconfig.mk
@ -99,9 +100,6 @@ ifeq ($(MCU_SUB_VARIANT), stm32f411xe)
C_DEFS = \
-DUSE_HAL_DRIVER \
-DSTM32F411xE
CIRCUITPY_BOARD = 0
CIRCUITPY_DIGITALIO = 0
CIRCUITPY_MICROCONTROLLER = 0
endif
#TODO: Add ASM Flags? -Werror
@ -185,7 +183,8 @@ SRC_C += \
mphalport.c \
tick.c \
boards/$(BOARD)/board.c \
boards/$(BOARD)/pins.c \
peripherals/stm32f4/$(MCU_SUB_VARIANT)/clocks.c \
peripherals/stm32f4/$(MCU_SUB_VARIANT)/gpio.c \
lib/libc/string0.c \
lib/mp-readline/readline.c \
lib/oofatfs/ff.c \
@ -204,7 +203,8 @@ SRC_C += lib/tinyusb/src/portable/st/stm32f4/dcd_stm32f4.c
endif
ifeq ($(MCU_SUB_VARIANT), stm32f412zx)
SRC_C += peripherals/stm32f4/stm32f412zg/pins.c
SRC_C += peripherals/stm32f4/stm32f412zx/pins.c
SRC_C += boards/$(BOARD)/pins.c
endif
SRC_S = \

@ -32,4 +32,4 @@
void background_tasks_reset(void);
void run_background_tasks(void);
#endif // MICROPY_INCLUDED_NRF_BACKGROUND_H
#endif // MICROPY_INCLUDED_STM32F4_BACKGROUND_H

@ -1,217 +0,0 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f4xx_it.c
* @brief Interrupt Service Routines.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32f4xx_it.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */
/* USER CODE END TD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
/* USER CODE BEGIN EV */
/* USER CODE END EV */
/******************************************************************************/
/* Cortex-M4 Processor Interruption and Exception Handlers */
/******************************************************************************/
/**
* @brief This function handles Non maskable interrupt.
*/
void NMI_Handler(void)
{
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
/* USER CODE END NonMaskableInt_IRQn 0 */
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
/* USER CODE END NonMaskableInt_IRQn 1 */
}
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
}
}
/**
* @brief This function handles Memory management fault.
*/
void MemManage_Handler(void)
{
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
/* USER CODE END MemoryManagement_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
/* USER CODE END W1_MemoryManagement_IRQn 0 */
}
}
/**
* @brief This function handles Pre-fetch fault, memory access fault.
*/
void BusFault_Handler(void)
{
/* USER CODE BEGIN BusFault_IRQn 0 */
/* USER CODE END BusFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
/* USER CODE END W1_BusFault_IRQn 0 */
}
}
/**
* @brief This function handles Undefined instruction or illegal state.
*/
void UsageFault_Handler(void)
{
/* USER CODE BEGIN UsageFault_IRQn 0 */
/* USER CODE END UsageFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
/* USER CODE END W1_UsageFault_IRQn 0 */
}
}
/**
* @brief This function handles System service call via SWI instruction.
*/
void SVC_Handler(void)
{
/* USER CODE BEGIN SVCall_IRQn 0 */
/* USER CODE END SVCall_IRQn 0 */
/* USER CODE BEGIN SVCall_IRQn 1 */
/* USER CODE END SVCall_IRQn 1 */
}
/**
* @brief This function handles Debug monitor.
*/
void DebugMon_Handler(void)
{
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
/* USER CODE END DebugMonitor_IRQn 0 */
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
/* USER CODE END DebugMonitor_IRQn 1 */
}
/**
* @brief This function handles Pendable request for system service.
*/
void PendSV_Handler(void)
{
/* USER CODE BEGIN PendSV_IRQn 0 */
/* USER CODE END PendSV_IRQn 0 */
/* USER CODE BEGIN PendSV_IRQn 1 */
/* USER CODE END PendSV_IRQn 1 */
}
/**
* @brief This function handles System tick timer.
*/
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
/* USER CODE BEGIN SysTick_IRQn 1 */
/* USER CODE END SysTick_IRQn 1 */
}
/******************************************************************************/
/* STM32F4xx Peripheral Interrupt Handlers */
/* Add here the Interrupt Handlers for the used peripherals. */
/* For the available peripheral interrupt handler names, */
/* please refer to the startup file (startup_stm32f4xx.s). */
/******************************************************************************/
/**
* @brief This function handles USB On The Go FS global interrupt.
*/
void OTG_FS_IRQHandler(void)
{
/* USER CODE BEGIN OTG_FS_IRQn 0 */
/* USER CODE END OTG_FS_IRQn 0 */
HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS);
/* USER CODE BEGIN OTG_FS_IRQn 1 */
/* USER CODE END OTG_FS_IRQn 1 */
}
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

@ -1,70 +0,0 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f4xx_it.h
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_IT_H
#define __STM32F4xx_IT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
/* USER CODE END EM */
/* Exported functions prototypes ---------------------------------------------*/
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void OTG_FS_IRQHandler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
#ifdef __cplusplus
}
#endif
#endif /* __STM32F4xx_IT_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

@ -1,18 +0,0 @@
USB_VID = 0x239A
USB_PID = 0x802A
USB_PRODUCT = "A glorious potato"
USB_MANUFACTURER = "Adafruit Industries LLC"
#USB_VID = 0x483
#USB_PID = 0x572B
#USB_PRODUCT = "STM32 Human Interface Potato"
#USB_MANUFACTURER = "STMicroelectronics"
MCU_SERIES = m4
MCU_VARIANT = stm32f4
MCU_SUB_VARIANT = stm32f412zx
CMSIS_MCU = STM32F412xG
LD_FILE = boards/STM32F412ZGTx_FLASH.ld
TEXT0_ADDR = 0x08000000
TEXT1_ADDR = 0x08020000

@ -1,217 +0,0 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f4xx_it.c
* @brief Interrupt Service Routines.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"
#include "stm32f4xx_it.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */
/* USER CODE END TD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
/* USER CODE BEGIN EV */
/* USER CODE END EV */
/******************************************************************************/
/* Cortex-M4 Processor Interruption and Exception Handlers */
/******************************************************************************/
/**
* @brief This function handles Non maskable interrupt.
*/
void NMI_Handler(void)
{
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
/* USER CODE END NonMaskableInt_IRQn 0 */
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
/* USER CODE END NonMaskableInt_IRQn 1 */
}
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
}
}
/**
* @brief This function handles Memory management fault.
*/
void MemManage_Handler(void)
{
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
/* USER CODE END MemoryManagement_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
/* USER CODE END W1_MemoryManagement_IRQn 0 */
}
}
/**
* @brief This function handles Pre-fetch fault, memory access fault.
*/
void BusFault_Handler(void)
{
/* USER CODE BEGIN BusFault_IRQn 0 */
/* USER CODE END BusFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
/* USER CODE END W1_BusFault_IRQn 0 */
}
}
/**
* @brief This function handles Undefined instruction or illegal state.
*/
void UsageFault_Handler(void)
{
/* USER CODE BEGIN UsageFault_IRQn 0 */
/* USER CODE END UsageFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
/* USER CODE END W1_UsageFault_IRQn 0 */
}
}
/**
* @brief This function handles System service call via SWI instruction.
*/
void SVC_Handler(void)
{
/* USER CODE BEGIN SVCall_IRQn 0 */
/* USER CODE END SVCall_IRQn 0 */
/* USER CODE BEGIN SVCall_IRQn 1 */
/* USER CODE END SVCall_IRQn 1 */
}
/**
* @brief This function handles Debug monitor.
*/
void DebugMon_Handler(void)
{
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
/* USER CODE END DebugMonitor_IRQn 0 */
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
/* USER CODE END DebugMonitor_IRQn 1 */
}
/**
* @brief This function handles Pendable request for system service.
*/
void PendSV_Handler(void)
{
/* USER CODE BEGIN PendSV_IRQn 0 */
/* USER CODE END PendSV_IRQn 0 */
/* USER CODE BEGIN PendSV_IRQn 1 */
/* USER CODE END PendSV_IRQn 1 */
}
// /**
// * @brief This function handles System tick timer.
// */
// void SysTick_Handler(void)
// {
// /* USER CODE BEGIN SysTick_IRQn 0 */
// /* USER CODE END SysTick_IRQn 0 */
// HAL_IncTick();
// /* USER CODE BEGIN SysTick_IRQn 1 */
// /* USER CODE END SysTick_IRQn 1 */
// }
/******************************************************************************/
/* STM32F4xx Peripheral Interrupt Handlers */
/* Add here the Interrupt Handlers for the used peripherals. */
/* For the available peripheral interrupt handler names, */
/* please refer to the startup file (startup_stm32f4xx.s). */
/******************************************************************************/
/**
* @brief This function handles USB On The Go FS global interrupt.
*/
// void OTG_FS_IRQHandler(void)
// {
// /* USER CODE BEGIN OTG_FS_IRQn 0 */
// /* USER CODE END OTG_FS_IRQn 0 */
// // HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS);
// /* USER CODE BEGIN OTG_FS_IRQn 1 */
// /* USER CODE END OTG_FS_IRQn 1 */
// }
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

@ -1,70 +0,0 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f4xx_it.h
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_IT_H
#define __STM32F4xx_IT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
/* USER CODE END EM */
/* Exported functions prototypes ---------------------------------------------*/
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
//void SysTick_Handler(void);
//void OTG_FS_IRQHandler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
#ifdef __cplusplus
}
#endif
#endif /* __STM32F4xx_IT_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

@ -1,6 +1,6 @@
USB_VID = 0x239A
USB_PID = 0x802A
USB_PRODUCT = "A glorious potato"
USB_PRODUCT = "STM32F411RE Discovery Board - CPy"
USB_MANUFACTURER = "Adafruit Industries LLC"
MCU_SERIES = m4

@ -62,7 +62,7 @@
/* #define HAL_MMC_MODULE_ENABLED */
#define HAL_SPI_MODULE_ENABLED
/* #define HAL_TIM_MODULE_ENABLED */
/* #define HAL_UART_MODULE_ENABLED */
#define HAL_UART_MODULE_ENABLED
/* #define HAL_USART_MODULE_ENABLED */
/* #define HAL_IRDA_MODULE_ENABLED */
/* #define HAL_SMARTCARD_MODULE_ENABLED */

@ -0,0 +1,13 @@
USB_VID = 0x483
USB_PID = 0x572B
USB_PRODUCT = "STM32F412ZG Discovery Board - CPy"
USB_MANUFACTURER = "STMicroelectronics"
MCU_SERIES = m4
MCU_VARIANT = stm32f4
MCU_SUB_VARIANT = stm32f412zx
CMSIS_MCU = STM32F412xG
LD_FILE = boards/STM32F412ZGTx_FLASH.ld
TEXT0_ADDR = 0x08000000
TEXT1_ADDR = 0x08020000

@ -1,112 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "common-hal/analogio/AnalogIn.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
#include "nrfx_saadc.h"
#include "nrf_gpio.h"
#define CHANNEL_NO 0
void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const mcu_pin_obj_t *pin) {
if (pin->adc_channel == 0)
mp_raise_ValueError(translate("Pin does not have ADC capabilities"));
nrf_gpio_cfg_default(pin->number);
claim_pin(pin);
self->pin = pin;
}
bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self) {
return self->pin == mp_const_none;
}
void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) {
if (common_hal_analogio_analogin_deinited(self))
return;
nrf_gpio_cfg_default(self->pin->number);
reset_pin_number(self->pin->number);
self->pin = mp_const_none;
}
uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
// Something else might have used the ADC in a different way,
// so we completely re-initialize it.
nrf_saadc_value_t value;
const nrf_saadc_channel_config_t config = {
.resistor_p = NRF_SAADC_RESISTOR_DISABLED,
.resistor_n = NRF_SAADC_RESISTOR_DISABLED,
.gain = NRF_SAADC_GAIN1_6,
.reference = NRF_SAADC_REFERENCE_INTERNAL,
.acq_time = NRF_SAADC_ACQTIME_3US,
.mode = NRF_SAADC_MODE_SINGLE_ENDED,
.burst = NRF_SAADC_BURST_DISABLED,
.pin_p = self->pin->adc_channel,
.pin_n = self->pin->adc_channel,
};
nrf_saadc_resolution_set(NRF_SAADC_RESOLUTION_14BIT);
nrf_saadc_oversample_set(NRF_SAADC_OVERSAMPLE_DISABLED);
nrf_saadc_enable();
for (uint32_t i = 0; i < NRF_SAADC_CHANNEL_COUNT; i++)
nrf_saadc_channel_input_set(i, NRF_SAADC_INPUT_DISABLED, NRF_SAADC_INPUT_DISABLED);
nrf_saadc_channel_init(CHANNEL_NO, &config);
nrf_saadc_buffer_init(&value, 1);
nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
while (nrf_saadc_event_check(NRF_SAADC_EVENT_STARTED) == 0);
nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE);
while (nrf_saadc_event_check(NRF_SAADC_EVENT_END) == 0);
nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP);
while (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED) == 0);
nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
nrf_saadc_disable();
if (value < 0)
value = 0;
// Map value to from 14 to 16 bits
return (value << 2);
}
float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) {
return 3.3f;
}

@ -1,39 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Scott Shawcroft
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_ANALOGIO_ANALOGIN_H
#define MICROPY_INCLUDED_NRF_COMMON_HAL_ANALOGIO_ANALOGIN_H
#include "common-hal/microcontroller/Pin.h"
#include "py/obj.h"
typedef struct {
mp_obj_base_t base;
const mcu_pin_obj_t * pin;
} analogio_analogin_obj_t;
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_ANALOGIO_ANALOGIN_H

@ -1,48 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Dan Halbert for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "shared-bindings/analogio/AnalogOut.h"
#include <stdint.h>
#include <string.h>
#include "py/mperrno.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self, const mcu_pin_obj_t *pin) {
mp_raise_RuntimeError(translate("AnalogOut functionality not supported"));
}
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
return true;
}
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
}
void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self, uint16_t value) {
}

@ -1 +0,0 @@
// No analogio module functions.

@ -1,152 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Glenn Ruben Bakke
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include "ble.h"
#include "ble_drv.h"
#include "nrfx_power.h"
#include "nrf_nvic.h"
#include "nrf_sdm.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Adapter.h"
#include "supervisor/usb.h"
STATIC void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) {
mp_raise_msg_varg(&mp_type_AssertionError,
translate("Soft device assert, id: 0x%08lX, pc: 0x%08lX"), id, pc);
}
STATIC uint32_t ble_stack_enable(void) {
nrf_clock_lf_cfg_t clock_config = {
.source = NRF_CLOCK_LF_SRC_XTAL,
.accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM
};
uint32_t err_code = sd_softdevice_enable(&clock_config, softdevice_assert_handler);
if (err_code != NRF_SUCCESS)
return err_code;
err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn);
if (err_code != NRF_SUCCESS)
return err_code;
// Start with no event handlers, etc.
ble_drv_reset();
uint32_t app_ram_start;
app_ram_start = 0x20004000;
ble_cfg_t ble_conf;
ble_conf.conn_cfg.conn_cfg_tag = BLE_CONN_CFG_TAG_CUSTOM;
ble_conf.conn_cfg.params.gap_conn_cfg.conn_count = BLE_GAP_CONN_COUNT_DEFAULT;
ble_conf.conn_cfg.params.gap_conn_cfg.event_length = BLE_GAP_EVENT_LENGTH_DEFAULT;
err_code = sd_ble_cfg_set(BLE_CONN_CFG_GAP, &ble_conf, app_ram_start);
if (err_code != NRF_SUCCESS)
return err_code;
memset(&ble_conf, 0, sizeof(ble_conf));
ble_conf.gap_cfg.role_count_cfg.periph_role_count = 1;
ble_conf.gap_cfg.role_count_cfg.central_role_count = 1;
err_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_conf, app_ram_start);
if (err_code != NRF_SUCCESS)
return err_code;
memset(&ble_conf, 0, sizeof(ble_conf));
ble_conf.conn_cfg.conn_cfg_tag = BLE_CONN_CFG_TAG_CUSTOM;
ble_conf.conn_cfg.params.gatts_conn_cfg.hvn_tx_queue_size = MAX_TX_IN_PROGRESS;
err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATTS, &ble_conf, app_ram_start);
if (err_code != NRF_SUCCESS)
return err_code;
err_code = sd_ble_enable(&app_ram_start);
return err_code;
}
void common_hal_bleio_adapter_set_enabled(bool enabled) {
const bool is_enabled = common_hal_bleio_adapter_get_enabled();
// Don't enable or disable twice
if ((is_enabled && enabled) || (!is_enabled && !enabled)) {
return;
}
uint32_t err_code;
if (enabled) {
// The SD takes over the POWER module and will fail if the module is already in use.
// Occurs when USB is initialized previously
nrfx_power_uninit();
err_code = ble_stack_enable();
// Re-init USB hardware
init_usb_hardware();
} else {
err_code = sd_softdevice_disable();
// Re-init USB hardware
init_usb_hardware();
}
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg(translate("Failed to change softdevice state"));
}
}
bool common_hal_bleio_adapter_get_enabled(void) {
uint8_t is_enabled;
const uint32_t err_code = sd_softdevice_is_enabled(&is_enabled);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg(translate("Failed to get softdevice state"));
}
return is_enabled;
}
void common_hal_bleio_adapter_get_address(bleio_address_obj_t *address) {
ble_gap_addr_t local_address;
uint32_t err_code;
common_hal_bleio_adapter_set_enabled(true);
#if (BLE_API_VERSION == 2)
err_code = sd_ble_gap_address_get(&local_address);
#else
err_code = sd_ble_gap_addr_get(&local_address);
#endif
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg(translate("Failed to get local address"));
}
address->type = local_address.addr_type;
memcpy(address->value, local_address.addr, BLEIO_ADDRESS_BYTES);
}

@ -1,37 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2016 Glenn Ruben Bakke
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_ADAPTER_H
#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_ADAPTER_H
#include "py/obj.h"
typedef struct {
mp_obj_base_t base;
} super_adapter_obj_t;
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_ADAPTER_H

@ -1,98 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Dan Halbert for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <string.h>
#include "ble.h"
#include "ble_drv.h"
#include "ble_hci.h"
#include "nrf_soc.h"
#include "py/runtime.h"
#include "common-hal/bleio/Broadcaster.h"
#include "shared-bindings/bleio/Adapter.h"
#include "shared-bindings/bleio/Broadcaster.h"
static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
void common_hal_bleio_broadcaster_construct(bleio_broadcaster_obj_t *self, mp_float_t interval) {
common_hal_bleio_adapter_set_enabled(true); // TODO -- Do this somewhere else maybe bleio __init__
const mp_float_t min = BLE_GAP_ADV_INTERVAL_MIN * ADV_INTERVAL_UNIT_FLOAT_SECS;
const mp_float_t max = BLE_GAP_ADV_INTERVAL_MAX * ADV_INTERVAL_UNIT_FLOAT_SECS;
if (interval < min || interval > max) {
// Would like to print range using the constants above, but vargs would convert to double.
mp_raise_ValueError(translate("interval not in range 0.0020 to 10.24"));
}
self->interval = interval;
}
void common_hal_bleio_broadcaster_start_advertising(bleio_broadcaster_obj_t *self, mp_buffer_info_t *data) {
uint32_t err_code;
if (data->len >= BLE_GAP_ADV_SET_DATA_SIZE_MAX) {
mp_raise_ValueError(translate("Data too large for advertisement packet"));
}
memcpy(self->adv_data, data->buf, data->len);
ble_gap_adv_params_t m_adv_params = {
.interval = (uint32_t) (self->interval / ADV_INTERVAL_UNIT_FLOAT_SECS),
.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED,
.duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED,
.filter_policy = BLE_GAP_ADV_FP_ANY,
.primary_phy = BLE_GAP_PHY_1MBPS,
};
common_hal_bleio_broadcaster_stop_advertising(self);
const ble_gap_adv_data_t ble_gap_adv_data = {
.adv_data.p_data = self->adv_data,
.adv_data.len = data->len,
};
err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &ble_gap_adv_data, &m_adv_params);
if (err_code == NRF_SUCCESS) {
err_code = sd_ble_gap_adv_start(m_adv_handle, BLE_CONN_CFG_TAG_CUSTOM);
}
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Failed to start advertising, err 0x%04x"), err_code);
}
}
void common_hal_bleio_broadcaster_stop_advertising(bleio_broadcaster_obj_t *self) {
if (m_adv_handle == BLE_GAP_ADV_SET_HANDLE_NOT_SET) {
return;
}
const uint32_t err_code = sd_ble_gap_adv_stop(m_adv_handle);
if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE)) {
mp_raise_OSError_msg_varg(translate("Failed to stop advertising, err 0x%04x"), err_code);
}
}

@ -1,47 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Artur Pacholec
* Copyright (c) 2018 Dan Halbert for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H
#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H
#include "ble.h"
#include "shared-module/bleio/__init__.h"
#include "shared-module/bleio/Address.h"
typedef struct {
mp_obj_base_t base;
// In seconds.
mp_float_t interval;
// The advertising data buffer is held by us, not by the SD, so we must
// maintain it and not change it. If we need to change its contents during advertising,
// there are tricks to get the SD to notice (see DevZone - TBS).
uint8_t adv_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX];
} bleio_broadcaster_obj_t;
#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H

@ -1,287 +0,0 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <string.h>
#include <stdio.h>