mirror of https://github.com/ARMmbed/mbed-os.git
Merge branch 'master' of https://github.com/mbedmicro/mbed
commit
66a93be3a0
|
|
@ -6,3 +6,4 @@ install:
|
|||
- "sudo $TRAVIS_BUILD_DIR/travis/install_dependencies.sh > /dev/null"
|
||||
- sudo pip install colorama
|
||||
- sudo pip install prettytable
|
||||
- sudo pip install jinja2
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ You can for example read more in our ```docs``` section in [mbedmicro/mbed/doc](
|
|||
# How to contribute
|
||||
We really appreciate your contributions! We are Open Source project and we need your help. We want to keep it as easy as possible to contribute changes that get things working in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
|
||||
|
||||
Before a pull request will be merged, the [mbed Contributor Agreement](http://developer.mbed.org/contributor_agreement/) must be signed.
|
||||
|
||||
You can pick up existing [mbed GitHub Issue](https://github.com/mbedmicro/mbed/issues) and solve it or implement new feature you find important, attractive or just necessary. We will review your proposal via pull request mechanism, give you comments and merge your changes if we decide your contribution satisfy criteria such as quality.
|
||||
|
||||
# Enhancements vs Bugs
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@
|
|||
/** A MIDI message container */
|
||||
class MIDIMessage {
|
||||
public:
|
||||
MIDIMessage() {}
|
||||
MIDIMessage() : length(4) {}
|
||||
|
||||
MIDIMessage(uint8_t *buf) {
|
||||
MIDIMessage(uint8_t *buf) : length(4) {
|
||||
for (int i = 0; i < 4; i++)
|
||||
data[i] = buf[i];
|
||||
}
|
||||
|
|
@ -270,7 +270,7 @@ public:
|
|||
}
|
||||
|
||||
uint8_t data[MAX_MIDI_MESSAGE_SIZE+1];
|
||||
uint8_t length=4;
|
||||
uint8_t length;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@
|
|||
#include "USBMIDI.h"
|
||||
|
||||
|
||||
USBMIDI::USBMIDI(uint16_t vendor_id, uint16_t product_id, uint16_t product_release): USBDevice(vendor_id, product_id, product_release) {
|
||||
USBMIDI::USBMIDI(uint16_t vendor_id, uint16_t product_id, uint16_t product_release)
|
||||
: USBDevice(vendor_id, product_id, product_release), cur_data(0), data_end(true)
|
||||
{
|
||||
midi_evt = NULL;
|
||||
USBDevice::connect();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,8 +103,8 @@ protected:
|
|||
|
||||
private:
|
||||
uint8_t data[MAX_MIDI_MESSAGE_SIZE+1];
|
||||
uint8_t cur_data=0;
|
||||
bool data_end = true;
|
||||
uint8_t cur_data;
|
||||
bool data_end;
|
||||
|
||||
void (*midi_evt)(MIDIMessage);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -135,10 +135,10 @@ bool USBMSD::connect(bool blocking) {
|
|||
}
|
||||
|
||||
void USBMSD::disconnect() {
|
||||
USBDevice::disconnect();
|
||||
//De-allocate MSD page size:
|
||||
free(page);
|
||||
page = NULL;
|
||||
USBDevice::disconnect();
|
||||
}
|
||||
|
||||
void USBMSD::reset() {
|
||||
|
|
|
|||
|
|
@ -19,20 +19,10 @@
|
|||
#ifndef CIRCBUFFER_H
|
||||
#define CIRCBUFFER_H
|
||||
|
||||
template <class T>
|
||||
template <class T, int Size>
|
||||
class CircBuffer {
|
||||
public:
|
||||
CircBuffer(int length) {
|
||||
write = 0;
|
||||
read = 0;
|
||||
size = length + 1;
|
||||
buf = (T *)malloc(size * sizeof(T));
|
||||
};
|
||||
|
||||
~CircBuffer() {
|
||||
free(buf);
|
||||
}
|
||||
|
||||
CircBuffer():write(0), read(0){}
|
||||
bool isFull() {
|
||||
return ((write + 1) % size == read);
|
||||
};
|
||||
|
|
@ -66,8 +56,8 @@ public:
|
|||
private:
|
||||
volatile uint16_t write;
|
||||
volatile uint16_t read;
|
||||
uint16_t size;
|
||||
T * buf;
|
||||
static const int size = Size+1; //a modern optimizer should be able to remove this so it uses no ram.
|
||||
T buf[Size];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public:
|
|||
* @param connect_blocking define if the connection must be blocked if USB not plugged in
|
||||
*
|
||||
*/
|
||||
USBSerial(uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001, bool connect_blocking = true): USBCDC(vendor_id, product_id, product_release, connect_blocking), buf(128){
|
||||
USBSerial(uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001, bool connect_blocking = true): USBCDC(vendor_id, product_id, product_release, connect_blocking){
|
||||
settingsChangedCallback = 0;
|
||||
};
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ protected:
|
|||
|
||||
private:
|
||||
FunctionPointer rx;
|
||||
CircBuffer<uint8_t> buf;
|
||||
CircBuffer<uint8_t,128> buf;
|
||||
void (*settingsChangedCallback)(int baud, int bits, int parity, int stop);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -42,10 +42,11 @@ SECTIONS
|
|||
{
|
||||
.isr_vector :
|
||||
{
|
||||
__vector_table = .;
|
||||
KEEP(*(.vector_table))
|
||||
. = 0;
|
||||
__isr_vector = .;
|
||||
KEEP(*(.isr_vector))
|
||||
*(.text.Reset_Handler)
|
||||
*(.text.System_Init)
|
||||
*(.text.SystemInit)
|
||||
. = ALIGN(4);
|
||||
} > VECTORS
|
||||
|
||||
|
|
|
|||
|
|
@ -192,6 +192,13 @@ __isr_vector:
|
|||
.globl Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
/*
|
||||
* Call SystemInit before loading the .data section to prevent the watchdog
|
||||
* from resetting the board.
|
||||
*/
|
||||
ldr r0, =SystemInit
|
||||
blx r0
|
||||
|
||||
/* Loop to copy data from read only memory to RAM. The ranges
|
||||
* of copy from/to are specified by following symbols evaluated in
|
||||
* linker script.
|
||||
|
|
@ -212,8 +219,6 @@ Reset_Handler:
|
|||
|
||||
.Lflash_to_ram_loop_end:
|
||||
|
||||
ldr r0, =SystemInit
|
||||
blx r0
|
||||
ldr r0, =_start
|
||||
bx r0
|
||||
.pool
|
||||
|
|
|
|||
|
|
@ -100,6 +100,8 @@ uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK;
|
|||
-- SystemInit()
|
||||
---------------------------------------------------------------------------- */
|
||||
void SystemInit (void) {
|
||||
/* SystemInit MUST NOT use any variables from the .data section, as this section is not loaded yet! */
|
||||
|
||||
#if (DISABLE_WDOG)
|
||||
/* Disable the WDOG module */
|
||||
/* WDOG_UNLOCK: WDOGUNLOCK=0xC520 */
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
;
|
||||
;WITH SOFTDEVICE:
|
||||
|
||||
LR_IROM1 0x16000 0x002A000 {
|
||||
ER_IROM1 0x16000 0x002A000 {
|
||||
LR_IROM1 0x18000 0x0028000 {
|
||||
ER_IROM1 0x18000 0x0028000 {
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
|
|
@ -22,6 +22,3 @@ LR_IROM1 0x16000 0x002A000 {
|
|||
.ANY (+RW +ZI)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
;
|
||||
;WITH SOFTDEVICE:
|
||||
|
||||
LR_IROM1 0x16000 0x002A000 {
|
||||
ER_IROM1 0x16000 0x002A000 {
|
||||
LR_IROM1 0x18000 0x0028000 {
|
||||
ER_IROM1 0x18000 0x0028000 {
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
|
|
@ -22,6 +22,3 @@ LR_IROM1 0x16000 0x002A000 {
|
|||
.ANY (+RW +ZI)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x00016000, LENGTH = 0x2A000
|
||||
FLASH (rx) : ORIGIN = 0x00018000, LENGTH = 0x28000
|
||||
RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x2000
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x00016000, LENGTH = 0x2A000
|
||||
FLASH (rx) : ORIGIN = 0x00018000, LENGTH = 0x28000
|
||||
RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x6000
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -209,6 +209,7 @@ void SystemInit(void)
|
|||
RCC->CIR = 0x00000000;
|
||||
|
||||
/* Configure the Cube driver */
|
||||
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
|
||||
HAL_Init();
|
||||
|
||||
/* Configure the System clock source, PLL Multiplier and Divider factors,
|
||||
|
|
|
|||
|
|
@ -226,6 +226,7 @@ void SystemInit(void)
|
|||
RCC->CIR = 0x00000000;
|
||||
|
||||
/* Configure the Cube driver */
|
||||
SystemCoreClock = 8000000; // At this stage the HSI is used as system clock
|
||||
HAL_Init();
|
||||
|
||||
/* Configure the System clock source, PLL Multiplier and Divider factors,
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@
|
|||
uint32_t SystemCoreClock = 72000000; /*!< System Clock Frequency (Core Clock) */
|
||||
#endif
|
||||
|
||||
__IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@
|
|||
uint32_t SystemCoreClock = 72000000; /*!< System Clock Frequency (Core Clock) */
|
||||
#endif
|
||||
|
||||
__IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -141,8 +141,8 @@
|
|||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
static __I uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
static __I uint16_t ADCPrescTable[16] = {1, 2, 4, 6, 8, 10, 12, 16, 32, 64, 128, 256, 0, 0, 0, 0 };
|
||||
const uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint16_t ADCPrescTable[16] = {1, 2, 4, 6, 8, 10, 12, 16, 32, 64, 128, 256, 0, 0, 0, 0 };
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@
|
|||
|
||||
uint32_t SystemCoreClock = 64000000; /* Default with HSI. Will be updated if HSE is used */
|
||||
|
||||
__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@
|
|||
variable is updated automatically.
|
||||
*/
|
||||
uint32_t SystemCoreClock = 168000000;
|
||||
__IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@
|
|||
variable is updated automatically.
|
||||
*/
|
||||
uint32_t SystemCoreClock = 16000000;
|
||||
__IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@
|
|||
variable is updated automatically.
|
||||
*/
|
||||
uint32_t SystemCoreClock = 16000000;
|
||||
__IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
|||
|
|
@ -27,15 +27,15 @@
|
|||
* | 2- PLL_HSE_XTAL |
|
||||
* | (external 8 MHz xtal) |
|
||||
*-----------------------------------------------------------------------------
|
||||
* SYSCLK(MHz) | 100 | 100
|
||||
* SYSCLK(MHz) | 96 | 96
|
||||
*-----------------------------------------------------------------------------
|
||||
* AHBCLK (MHz) | 100 | 100
|
||||
* AHBCLK (MHz) | 96 | 96
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB1CLK (MHz) | 50 | 50
|
||||
* APB1CLK (MHz) | 48 | 48
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB2CLK (MHz) | 100 | 100
|
||||
* APB2CLK (MHz) | 96 | 96
|
||||
*-----------------------------------------------------------------------------
|
||||
* USB capable (48 MHz precise clock) | NO | NO
|
||||
* USB capable (48 MHz precise clock) | YES | YES
|
||||
*-----------------------------------------------------------------------------
|
||||
******************************************************************************
|
||||
* @attention
|
||||
|
|
@ -157,7 +157,7 @@
|
|||
variable is updated automatically.
|
||||
*/
|
||||
uint32_t SystemCoreClock = 16000000;
|
||||
__IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
@ -611,11 +611,11 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
|
|||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
//RCC_OscInitStruct.PLL.PLLM = 8; // VCO input clock = 1 MHz (8 MHz / 8)
|
||||
//RCC_OscInitStruct.PLL.PLLN = 400; // VCO output clock = 400 MHz (1 MHz * 400)
|
||||
//RCC_OscInitStruct.PLL.PLLN = 384; // VCO output clock = 384 MHz (1 MHz * 384)
|
||||
RCC_OscInitStruct.PLL.PLLM = 4; // VCO input clock = 2 MHz (8 MHz / 4)
|
||||
RCC_OscInitStruct.PLL.PLLN = 200; // VCO output clock = 400 MHz (2 MHz * 200)
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; // PLLCLK = 100 MHz (400 MHz / 4)
|
||||
RCC_OscInitStruct.PLL.PLLQ = 9; // USB clock = 44.44 MHz (400 MHz / 9) --> Not good for USB
|
||||
RCC_OscInitStruct.PLL.PLLN = 192; // VCO output clock = 384 MHz (2 MHz * 192)
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; // PLLCLK = 96 MHz (384 MHz / 4)
|
||||
RCC_OscInitStruct.PLL.PLLQ = 8; // USB clock = 48 MHz (384 MHz / 8) --> Good for USB
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
return 0; // FAIL
|
||||
|
|
@ -623,10 +623,10 @@ uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
|
|||
|
||||
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
|
||||
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 100 MHz
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 100 MHz
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 50 MHz
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 100 MHz
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 96 MHz
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 96 MHz
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 48 MHz
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 96 MHz
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
|
||||
{
|
||||
return 0; // FAIL
|
||||
|
|
@ -665,11 +665,11 @@ uint8_t SetSysClock_PLL_HSI(void)
|
|||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||
//RCC_OscInitStruct.PLL.PLLM = 16; // VCO input clock = 1 MHz (16 MHz / 16)
|
||||
//RCC_OscInitStruct.PLL.PLLN = 400; // VCO output clock = 400 MHz (1 MHz * 400)
|
||||
//RCC_OscInitStruct.PLL.PLLN = 384; // VCO output clock = 384 MHz (1 MHz * 384)
|
||||
RCC_OscInitStruct.PLL.PLLM = 8; // VCO input clock = 2 MHz (16 MHz / 8)
|
||||
RCC_OscInitStruct.PLL.PLLN = 200; // VCO output clock = 400 MHz (2 MHz * 200)
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; // PLLCLK = 100 MHz (400 MHz / 4)
|
||||
RCC_OscInitStruct.PLL.PLLQ = 9; // USB clock = 44.44 MHz (400 MHz / 9) --> Not good for USB
|
||||
RCC_OscInitStruct.PLL.PLLN = 192; // VCO output clock = 384 MHz (2 MHz * 192)
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; // PLLCLK = 96 MHz (384 MHz / 4)
|
||||
RCC_OscInitStruct.PLL.PLLQ = 8; // USB clock = 48 MHz (384 MHz / 8) --> Good for USB
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
return 0; // FAIL
|
||||
|
|
@ -677,10 +677,10 @@ uint8_t SetSysClock_PLL_HSI(void)
|
|||
|
||||
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
|
||||
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 100 MHz
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 100 MHz
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 50 MHz
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 100 MHz
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 96 MHz
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 96 MHz
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 48 MHz
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 96 MHz
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
|
||||
{
|
||||
return 0; // FAIL
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@
|
|||
variable is updated automatically.
|
||||
*/
|
||||
uint32_t SystemCoreClock = 16000000;
|
||||
__IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ typedef struct
|
|||
|
||||
|
||||
#define DBP_TIMEOUT_VALUE ((uint32_t)100)
|
||||
#define LSE_TIMEOUT_VALUE ((uint32_t)600)
|
||||
#define LSE_TIMEOUT_VALUE ((uint32_t)5000)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@
|
|||
|
||||
uint32_t SystemCoreClock = 168000000;
|
||||
|
||||
__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
|||
|
|
@ -145,9 +145,9 @@
|
|||
is no need to call the 2 first functions listed above, since SystemCoreClock
|
||||
variable is updated automatically.
|
||||
*/
|
||||
uint32_t SystemCoreClock = 32000000;
|
||||
__IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
__IO const uint8_t PLLMulTable[9] = {3, 4, 6, 8, 12, 16, 24, 32, 48};
|
||||
uint32_t SystemCoreClock = 32000000;
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t PLLMulTable[9] = {3, 4, 6, 8, 12, 16, 24, 32, 48};
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
|||
|
|
@ -145,9 +145,9 @@
|
|||
is no need to call the 2 first functions listed above, since SystemCoreClock
|
||||
variable is updated automatically.
|
||||
*/
|
||||
uint32_t SystemCoreClock = 32000000;
|
||||
__IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
__IO const uint8_t PLLMulTable[9] = {3, 4, 6, 8, 12, 16, 24, 32, 48};
|
||||
uint32_t SystemCoreClock = 32000000;
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t PLLMulTable[9] = {3, 4, 6, 8, 12, 16, 24, 32, 48};
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
|||
|
|
@ -145,9 +145,9 @@
|
|||
is no need to call the 2 first functions listed above, since SystemCoreClock
|
||||
variable is updated automatically.
|
||||
*/
|
||||
uint32_t SystemCoreClock = 32000000;
|
||||
__IO const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
__IO const uint8_t PLLMulTable[9] = {3, 4, 6, 8, 12, 16, 24, 32, 48};
|
||||
uint32_t SystemCoreClock = 32000000;
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t PLLMulTable[9] = {3, 4, 6, 8, 12, 16, 24, 32, 48};
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@
|
|||
|
||||
|
||||
#if !defined (LSE_STARTUP_TIMEOUT)
|
||||
#define LSE_STARTUP_TIMEOUT ((uint32_t)500) /*!< Time out for LSE start up, in ms */
|
||||
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
|
||||
#endif /* HSE_STARTUP_TIMEOUT */
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -118,8 +118,8 @@
|
|||
/** @defgroup RCC_Private_Vatiables RCC Private Data
|
||||
* @{
|
||||
*/
|
||||
static __IO const uint8_t PLLMulTable[9] = {3, 4, 6, 8, 12, 16, 24, 32, 48};
|
||||
static __IO const uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
const uint8_t PLLMulTable[9] = {3, 4, 6, 8, 12, 16, 24, 32, 48};
|
||||
const uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,325 @@
|
|||
; STM32L152RC Ultra Low Power High-density Devices vector table for MDK ARM_MICRO toolchain
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Copyright (c) 2014, STMicroelectronics
|
||||
; All rights reserved.
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
;
|
||||
; 1. Redistributions of source code must retain the above copyright notice,
|
||||
; this list of conditions and the following disclaimer.
|
||||
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
; this list of conditions and the following disclaimer in the documentation
|
||||
; and/or other materials provided with the distribution.
|
||||
; 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
; may be used to endorse or promote products derived from this software
|
||||
; without specific prior written permission.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; Amount of memory (in bytes) allocated for Stack
|
||||
; Tailor this value to your application needs
|
||||
; <h> Stack Configuration
|
||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Stack_Size EQU 0x00000400
|
||||
|
||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
||||
EXPORT __initial_sp
|
||||
|
||||
Stack_Mem SPACE Stack_Size
|
||||
__initial_sp EQU 0x20008000 ; Top of RAM (32 KB)
|
||||
|
||||
|
||||
; <h> Heap Configuration
|
||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
||||
; </h>
|
||||
|
||||
Heap_Size EQU 0x00000400
|
||||
|
||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
||||
EXPORT __heap_base
|
||||
EXPORT __heap_limit
|
||||
|
||||
__heap_base
|
||||
Heap_Mem SPACE Heap_Size
|
||||
__heap_limit EQU (__initial_sp - Stack_Size)
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD WWDG_IRQHandler ; Window Watchdog
|
||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
||||
DCD TAMPER_STAMP_IRQHandler ; Tamper and Time Stamp
|
||||
DCD RTC_WKUP_IRQHandler ; RTC Wakeup
|
||||
DCD FLASH_IRQHandler ; FLASH
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
||||
DCD ADC1_IRQHandler ; ADC1
|
||||
DCD USB_HP_IRQHandler ; USB High Priority
|
||||
DCD USB_LP_IRQHandler ; USB Low Priority
|
||||
DCD DAC_IRQHandler ; DAC
|
||||
DCD COMP_IRQHandler ; COMP through EXTI Line
|
||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
||||
DCD LCD_IRQHandler ; LCD
|
||||
DCD TIM9_IRQHandler ; TIM9
|
||||
DCD TIM10_IRQHandler ; TIM10
|
||||
DCD TIM11_IRQHandler ; TIM11
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD TIM3_IRQHandler ; TIM3
|
||||
DCD TIM4_IRQHandler ; TIM4
|
||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
||||
DCD SPI1_IRQHandler ; SPI1
|
||||
DCD SPI2_IRQHandler ; SPI2
|
||||
DCD USART1_IRQHandler ; USART1
|
||||
DCD USART2_IRQHandler ; USART2
|
||||
DCD USART3_IRQHandler ; USART3
|
||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
||||
DCD USB_FS_WKUP_IRQHandler ; USB FS Wakeup from suspend
|
||||
DCD TIM6_IRQHandler ; TIM6
|
||||
DCD TIM7_IRQHandler ; TIM7
|
||||
DCD 0 ; Reserved
|
||||
DCD TIM5_IRQHandler ; TIM5
|
||||
DCD SPI3_IRQHandler ; SPI3
|
||||
DCD UART4_IRQHandler ; UART4
|
||||
DCD UART5_IRQHandler ; UART5
|
||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel 1
|
||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel 2
|
||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel 3
|
||||
DCD DMA2_Channel4_IRQHandler ; DMA2 Channel 4
|
||||
DCD DMA2_Channel5_IRQHandler ; DMA2 Channel 5
|
||||
DCD 0 ; Reserved
|
||||
DCD COMP_ACQ_IRQHandler ; Comparator Channel Acquisition
|
||||
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset handler
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT __main
|
||||
IMPORT SystemInit
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemManage_Handler\
|
||||
PROC
|
||||
EXPORT MemManage_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMon_Handler\
|
||||
PROC
|
||||
EXPORT DebugMon_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
PendSV_Handler PROC
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SysTick_Handler PROC
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
|
||||
EXPORT WWDG_IRQHandler [WEAK]
|
||||
EXPORT PVD_IRQHandler [WEAK]
|
||||
EXPORT TAMPER_STAMP_IRQHandler [WEAK]
|
||||
EXPORT RTC_WKUP_IRQHandler [WEAK]
|
||||
EXPORT FLASH_IRQHandler [WEAK]
|
||||
EXPORT RCC_IRQHandler [WEAK]
|
||||
EXPORT EXTI0_IRQHandler [WEAK]
|
||||
EXPORT EXTI1_IRQHandler [WEAK]
|
||||
EXPORT EXTI2_IRQHandler [WEAK]
|
||||
EXPORT EXTI3_IRQHandler [WEAK]
|
||||
EXPORT EXTI4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
||||
EXPORT ADC1_IRQHandler [WEAK]
|
||||
EXPORT USB_HP_IRQHandler [WEAK]
|
||||
EXPORT USB_LP_IRQHandler [WEAK]
|
||||
EXPORT DAC_IRQHandler [WEAK]
|
||||
EXPORT COMP_IRQHandler [WEAK]
|
||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
||||
EXPORT LCD_IRQHandler [WEAK]
|
||||
EXPORT TIM9_IRQHandler [WEAK]
|
||||
EXPORT TIM10_IRQHandler [WEAK]
|
||||
EXPORT TIM11_IRQHandler [WEAK]
|
||||
EXPORT TIM2_IRQHandler [WEAK]
|
||||
EXPORT TIM3_IRQHandler [WEAK]
|
||||
EXPORT TIM4_IRQHandler [WEAK]
|
||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
||||
EXPORT SPI1_IRQHandler [WEAK]
|
||||
EXPORT SPI2_IRQHandler [WEAK]
|
||||
EXPORT USART1_IRQHandler [WEAK]
|
||||
EXPORT USART2_IRQHandler [WEAK]
|
||||
EXPORT USART3_IRQHandler [WEAK]
|
||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
||||
EXPORT USB_FS_WKUP_IRQHandler [WEAK]
|
||||
EXPORT TIM6_IRQHandler [WEAK]
|
||||
EXPORT TIM7_IRQHandler [WEAK]
|
||||
EXPORT TIM5_IRQHandler [WEAK]
|
||||
EXPORT SPI3_IRQHandler [WEAK]
|
||||
EXPORT UART4_IRQHandler [WEAK]
|
||||
EXPORT UART5_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel1_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel2_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel3_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel4_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel5_IRQHandler [WEAK]
|
||||
EXPORT COMP_ACQ_IRQHandler [WEAK]
|
||||
|
||||
WWDG_IRQHandler
|
||||
PVD_IRQHandler
|
||||
TAMPER_STAMP_IRQHandler
|
||||
RTC_WKUP_IRQHandler
|
||||
FLASH_IRQHandler
|
||||
RCC_IRQHandler
|
||||
EXTI0_IRQHandler
|
||||
EXTI1_IRQHandler
|
||||
EXTI2_IRQHandler
|
||||
EXTI3_IRQHandler
|
||||
EXTI4_IRQHandler
|
||||
DMA1_Channel1_IRQHandler
|
||||
DMA1_Channel2_IRQHandler
|
||||
DMA1_Channel3_IRQHandler
|
||||
DMA1_Channel4_IRQHandler
|
||||
DMA1_Channel5_IRQHandler
|
||||
DMA1_Channel6_IRQHandler
|
||||
DMA1_Channel7_IRQHandler
|
||||
ADC1_IRQHandler
|
||||
USB_HP_IRQHandler
|
||||
USB_LP_IRQHandler
|
||||
DAC_IRQHandler
|
||||
COMP_IRQHandler
|
||||
EXTI9_5_IRQHandler
|
||||
LCD_IRQHandler
|
||||
TIM9_IRQHandler
|
||||
TIM10_IRQHandler
|
||||
TIM11_IRQHandler
|
||||
TIM2_IRQHandler
|
||||
TIM3_IRQHandler
|
||||
TIM4_IRQHandler
|
||||
I2C1_EV_IRQHandler
|
||||
I2C1_ER_IRQHandler
|
||||
I2C2_EV_IRQHandler
|
||||
I2C2_ER_IRQHandler
|
||||
SPI1_IRQHandler
|
||||
SPI2_IRQHandler
|
||||
USART1_IRQHandler
|
||||
USART2_IRQHandler
|
||||
USART3_IRQHandler
|
||||
EXTI15_10_IRQHandler
|
||||
RTC_Alarm_IRQHandler
|
||||
USB_FS_WKUP_IRQHandler
|
||||
TIM6_IRQHandler
|
||||
TIM7_IRQHandler
|
||||
TIM5_IRQHandler
|
||||
SPI3_IRQHandler
|
||||
UART4_IRQHandler
|
||||
UART5_IRQHandler
|
||||
DMA2_Channel1_IRQHandler
|
||||
DMA2_Channel2_IRQHandler
|
||||
DMA2_Channel3_IRQHandler
|
||||
DMA2_Channel4_IRQHandler
|
||||
DMA2_Channel5_IRQHandler
|
||||
COMP_ACQ_IRQHandler
|
||||
|
||||
B .
|
||||
|
||||
ENDP
|
||||
|
||||
ALIGN
|
||||
END
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
; Scatter-Loading Description File
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Copyright (c) 2014, STMicroelectronics
|
||||
; All rights reserved.
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
;
|
||||
; 1. Redistributions of source code must retain the above copyright notice,
|
||||
; this list of conditions and the following disclaimer.
|
||||
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
; this list of conditions and the following disclaimer in the documentation
|
||||
; and/or other materials provided with the distribution.
|
||||
; 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
; may be used to endorse or promote products derived from this software
|
||||
; without specific prior written permission.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; STM32L152RC: 256KB FLASH + 32KB SRAM
|
||||
LR_IROM1 0x08000000 0x40000 { ; load region size_region
|
||||
|
||||
ER_IROM1 0x08000000 0x40000 { ; load address = execution address
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
}
|
||||
|
||||
; 73 vectors = 292 bytes (0x124) to be reserved in RAM
|
||||
RW_IRAM1 (0x20000000+0x124) (0x8000-0x124) { ; RW data
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/* mbed Microcontroller Library - stackheap
|
||||
* Setup a fixed single stack/heap memory model,
|
||||
* between the top of the RW/ZI region and the stackpointer
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rt_misc.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern char Image$$RW_IRAM1$$ZI$$Limit[];
|
||||
|
||||
extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) {
|
||||
uint32_t zi_limit = (uint32_t)Image$$RW_IRAM1$$ZI$$Limit;
|
||||
uint32_t sp_limit = __current_sp();
|
||||
|
||||
zi_limit = (zi_limit + 7) & ~0x7; // ensure zi_limit is 8-byte aligned
|
||||
|
||||
struct __initial_stackheap r;
|
||||
r.heap_base = zi_limit;
|
||||
r.heap_limit = sp_limit;
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,298 @@
|
|||
; STM32L152RC Ultra Low Power High-density Devices vector table for MDK ARM_STD toolchain
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Copyright (c) 2014, STMicroelectronics
|
||||
; All rights reserved.
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
;
|
||||
; 1. Redistributions of source code must retain the above copyright notice,
|
||||
; this list of conditions and the following disclaimer.
|
||||
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
; this list of conditions and the following disclaimer in the documentation
|
||||
; and/or other materials provided with the distribution.
|
||||
; 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
; may be used to endorse or promote products derived from this software
|
||||
; without specific prior written permission.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
__initial_sp EQU 0x20008000 ; Top of RAM (32 KB)
|
||||
|
||||
PRESERVE8
|
||||
THUMB
|
||||
|
||||
|
||||
; Vector Table Mapped to Address 0 at Reset
|
||||
AREA RESET, DATA, READONLY
|
||||
EXPORT __Vectors
|
||||
EXPORT __Vectors_End
|
||||
EXPORT __Vectors_Size
|
||||
|
||||
__Vectors DCD __initial_sp ; Top of Stack
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD WWDG_IRQHandler ; Window Watchdog
|
||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
||||
DCD TAMPER_STAMP_IRQHandler ; Tamper and Time Stamp
|
||||
DCD RTC_WKUP_IRQHandler ; RTC Wakeup
|
||||
DCD FLASH_IRQHandler ; FLASH
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
||||
DCD ADC1_IRQHandler ; ADC1
|
||||
DCD USB_HP_IRQHandler ; USB High Priority
|
||||
DCD USB_LP_IRQHandler ; USB Low Priority
|
||||
DCD DAC_IRQHandler ; DAC
|
||||
DCD COMP_IRQHandler ; COMP through EXTI Line
|
||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
||||
DCD LCD_IRQHandler ; LCD
|
||||
DCD TIM9_IRQHandler ; TIM9
|
||||
DCD TIM10_IRQHandler ; TIM10
|
||||
DCD TIM11_IRQHandler ; TIM11
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD TIM3_IRQHandler ; TIM3
|
||||
DCD TIM4_IRQHandler ; TIM4
|
||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
||||
DCD SPI1_IRQHandler ; SPI1
|
||||
DCD SPI2_IRQHandler ; SPI2
|
||||
DCD USART1_IRQHandler ; USART1
|
||||
DCD USART2_IRQHandler ; USART2
|
||||
DCD USART3_IRQHandler ; USART3
|
||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
||||
DCD USB_FS_WKUP_IRQHandler ; USB FS Wakeup from suspend
|
||||
DCD TIM6_IRQHandler ; TIM6
|
||||
DCD TIM7_IRQHandler ; TIM7
|
||||
DCD 0 ; Reserved
|
||||
DCD TIM5_IRQHandler ; TIM5
|
||||
DCD SPI3_IRQHandler ; SPI3
|
||||
DCD UART4_IRQHandler ; UART4
|
||||
DCD UART5_IRQHandler ; UART5
|
||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel 1
|
||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel 2
|
||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel 3
|
||||
DCD DMA2_Channel4_IRQHandler ; DMA2 Channel 4
|
||||
DCD DMA2_Channel5_IRQHandler ; DMA2 Channel 5
|
||||
DCD 0 ; Reserved
|
||||
DCD COMP_ACQ_IRQHandler ; Comparator Channel Acquisition
|
||||
|
||||
__Vectors_End
|
||||
|
||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
||||
|
||||
AREA |.text|, CODE, READONLY
|
||||
|
||||
; Reset handler
|
||||
Reset_Handler PROC
|
||||
EXPORT Reset_Handler [WEAK]
|
||||
IMPORT __main
|
||||
IMPORT SystemInit
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__main
|
||||
BX R0
|
||||
ENDP
|
||||
|
||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
||||
|
||||
NMI_Handler PROC
|
||||
EXPORT NMI_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
HardFault_Handler\
|
||||
PROC
|
||||
EXPORT HardFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
MemManage_Handler\
|
||||
PROC
|
||||
EXPORT MemManage_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
BusFault_Handler\
|
||||
PROC
|
||||
EXPORT BusFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
UsageFault_Handler\
|
||||
PROC
|
||||
EXPORT UsageFault_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SVC_Handler PROC
|
||||
EXPORT SVC_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
DebugMon_Handler\
|
||||
PROC
|
||||
EXPORT DebugMon_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
PendSV_Handler PROC
|
||||
EXPORT PendSV_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
SysTick_Handler PROC
|
||||
EXPORT SysTick_Handler [WEAK]
|
||||
B .
|
||||
ENDP
|
||||
|
||||
Default_Handler PROC
|
||||
|
||||
EXPORT WWDG_IRQHandler [WEAK]
|
||||
EXPORT PVD_IRQHandler [WEAK]
|
||||
EXPORT TAMPER_STAMP_IRQHandler [WEAK]
|
||||
EXPORT RTC_WKUP_IRQHandler [WEAK]
|
||||
EXPORT FLASH_IRQHandler [WEAK]
|
||||
EXPORT RCC_IRQHandler [WEAK]
|
||||
EXPORT EXTI0_IRQHandler [WEAK]
|
||||
EXPORT EXTI1_IRQHandler [WEAK]
|
||||
EXPORT EXTI2_IRQHandler [WEAK]
|
||||
EXPORT EXTI3_IRQHandler [WEAK]
|
||||
EXPORT EXTI4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
||||
EXPORT ADC1_IRQHandler [WEAK]
|
||||
EXPORT USB_HP_IRQHandler [WEAK]
|
||||
EXPORT USB_LP_IRQHandler [WEAK]
|
||||
EXPORT DAC_IRQHandler [WEAK]
|
||||
EXPORT COMP_IRQHandler [WEAK]
|
||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
||||
EXPORT LCD_IRQHandler [WEAK]
|
||||
EXPORT TIM9_IRQHandler [WEAK]
|
||||
EXPORT TIM10_IRQHandler [WEAK]
|
||||
EXPORT TIM11_IRQHandler [WEAK]
|
||||
EXPORT TIM2_IRQHandler [WEAK]
|
||||
EXPORT TIM3_IRQHandler [WEAK]
|
||||
EXPORT TIM4_IRQHandler [WEAK]
|
||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
||||
EXPORT SPI1_IRQHandler [WEAK]
|
||||
EXPORT SPI2_IRQHandler [WEAK]
|
||||
EXPORT USART1_IRQHandler [WEAK]
|
||||
EXPORT USART2_IRQHandler [WEAK]
|
||||
EXPORT USART3_IRQHandler [WEAK]
|
||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
||||
EXPORT USB_FS_WKUP_IRQHandler [WEAK]
|
||||
EXPORT TIM6_IRQHandler [WEAK]
|
||||
EXPORT TIM7_IRQHandler [WEAK]
|
||||
EXPORT TIM5_IRQHandler [WEAK]
|
||||
EXPORT SPI3_IRQHandler [WEAK]
|
||||
EXPORT UART4_IRQHandler [WEAK]
|
||||
EXPORT UART5_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel1_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel2_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel3_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel4_IRQHandler [WEAK]
|
||||
EXPORT DMA2_Channel5_IRQHandler [WEAK]
|
||||
EXPORT COMP_ACQ_IRQHandler [WEAK]
|
||||
|
||||
WWDG_IRQHandler
|
||||
PVD_IRQHandler
|
||||
TAMPER_STAMP_IRQHandler
|
||||
RTC_WKUP_IRQHandler
|
||||
FLASH_IRQHandler
|
||||
RCC_IRQHandler
|
||||
EXTI0_IRQHandler
|
||||
EXTI1_IRQHandler
|
||||
EXTI2_IRQHandler
|
||||
EXTI3_IRQHandler
|
||||
EXTI4_IRQHandler
|
||||
DMA1_Channel1_IRQHandler
|
||||
DMA1_Channel2_IRQHandler
|
||||
DMA1_Channel3_IRQHandler
|
||||
DMA1_Channel4_IRQHandler
|
||||
DMA1_Channel5_IRQHandler
|
||||
DMA1_Channel6_IRQHandler
|
||||
DMA1_Channel7_IRQHandler
|
||||
ADC1_IRQHandler
|
||||
USB_HP_IRQHandler
|
||||
USB_LP_IRQHandler
|
||||
DAC_IRQHandler
|
||||
COMP_IRQHandler
|
||||
EXTI9_5_IRQHandler
|
||||
LCD_IRQHandler
|
||||
TIM9_IRQHandler
|
||||
TIM10_IRQHandler
|
||||
TIM11_IRQHandler
|
||||
TIM2_IRQHandler
|
||||
TIM3_IRQHandler
|
||||
TIM4_IRQHandler
|
||||
I2C1_EV_IRQHandler
|
||||
I2C1_ER_IRQHandler
|
||||
I2C2_EV_IRQHandler
|
||||
I2C2_ER_IRQHandler
|
||||
SPI1_IRQHandler
|
||||
SPI2_IRQHandler
|
||||
USART1_IRQHandler
|
||||
USART2_IRQHandler
|
||||
USART3_IRQHandler
|
||||
EXTI15_10_IRQHandler
|
||||
RTC_Alarm_IRQHandler
|
||||
USB_FS_WKUP_IRQHandler
|
||||
TIM6_IRQHandler
|
||||
TIM7_IRQHandler
|
||||
TIM5_IRQHandler
|
||||
SPI3_IRQHandler
|
||||
UART4_IRQHandler
|
||||
UART5_IRQHandler
|
||||
DMA2_Channel1_IRQHandler
|
||||
DMA2_Channel2_IRQHandler
|
||||
DMA2_Channel3_IRQHandler
|
||||
DMA2_Channel4_IRQHandler
|
||||
DMA2_Channel5_IRQHandler
|
||||
COMP_ACQ_IRQHandler
|
||||
|
||||
B .
|
||||
|
||||
ENDP
|
||||
|
||||
ALIGN
|
||||
END
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
; Scatter-Loading Description File
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; Copyright (c) 2014, STMicroelectronics
|
||||
; All rights reserved.
|
||||
;
|
||||
; Redistribution and use in source and binary forms, with or without
|
||||
; modification, are permitted provided that the following conditions are met:
|
||||
;
|
||||
; 1. Redistributions of source code must retain the above copyright notice,
|
||||
; this list of conditions and the following disclaimer.
|
||||
; 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
; this list of conditions and the following disclaimer in the documentation
|
||||
; and/or other materials provided with the distribution.
|
||||
; 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
; may be used to endorse or promote products derived from this software
|
||||
; without specific prior written permission.
|
||||
;
|
||||
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
; STM32L152RC: 256KB FLASH + 32KB SRAM
|
||||
LR_IROM1 0x08000000 0x40000 { ; load region size_region
|
||||
|
||||
ER_IROM1 0x08000000 0x40000 { ; load address = execution address
|
||||
*.o (RESET, +First)
|
||||
*(InRoot$$Sections)
|
||||
.ANY (+RO)
|
||||
}
|
||||
|
||||
; 73 vectors = 292 bytes (0x124) to be reserved in RAM
|
||||
RW_IRAM1 (0x20000000+0x124) (0x8000-0x124) { ; RW data
|
||||
.ANY (+RW +ZI)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/* mbed Microcontroller Library - stackheap
|
||||
* Setup a fixed single stack/heap memory model,
|
||||
* between the top of the RW/ZI region and the stackpointer
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rt_misc.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern char Image$$RW_IRAM1$$ZI$$Limit[];
|
||||
|
||||
extern __value_in_regs struct __initial_stackheap __user_setup_stackheap(uint32_t R0, uint32_t R1, uint32_t R2, uint32_t R3) {
|
||||
uint32_t zi_limit = (uint32_t)Image$$RW_IRAM1$$ZI$$Limit;
|
||||
uint32_t sp_limit = __current_sp();
|
||||
|
||||
zi_limit = (zi_limit + 7) & ~0x7; // ensure zi_limit is 8-byte aligned
|
||||
|
||||
struct __initial_stackheap r;
|
||||
r.heap_base = zi_limit;
|
||||
r.heap_limit = sp_limit;
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
/* Linker script to configure memory regions. */
|
||||
MEMORY
|
||||
{
|
||||
/* 256KB FLASH, 32KB RAM, Reserve up till 0x13C. There are 0x73 vectors = 292
|
||||
* bytes (0x124) in RAM. But all GCC scripts seem to require BootRAM @0x138
|
||||
*/
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256k
|
||||
RAM (rwx) : ORIGIN = 0x2000013C, LENGTH = 0x8000-0x13C
|
||||
}
|
||||
|
||||
/* Linker script to place sections and symbol values. Should be used together
|
||||
* with other linker script that defines memory regions FLASH and RAM.
|
||||
* It references following symbols, which must be defined in code:
|
||||
* Reset_Handler : Entry of reset handler
|
||||
*
|
||||
* It defines following symbols, which code can use without definition:
|
||||
* __exidx_start
|
||||
* __exidx_end
|
||||
* __etext
|
||||
* __data_start__
|
||||
* __preinit_array_start
|
||||
* __preinit_array_end
|
||||
* __init_array_start
|
||||
* __init_array_end
|
||||
* __fini_array_start
|
||||
* __fini_array_end
|
||||
* __data_end__
|
||||
* __bss_start__
|
||||
* __bss_end__
|
||||
* __end__
|
||||
* end
|
||||
* __HeapLimit
|
||||
* __StackLimit
|
||||
* __StackTop
|
||||
* __stack
|
||||
* _estack
|
||||
*/
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
KEEP(*(.isr_vector))
|
||||
*(.text*)
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
*(.rodata*)
|
||||
|
||||
KEEP(*(.eh_frame*))
|
||||
} > FLASH
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > FLASH
|
||||
|
||||
__exidx_start = .;
|
||||
.ARM.exidx :
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} > FLASH
|
||||
__exidx_end = .;
|
||||
|
||||
__etext = .;
|
||||
_sidata = .;
|
||||
|
||||
.data : AT (__etext)
|
||||
{
|
||||
__data_start__ = .;
|
||||
_sdata = .;
|
||||
*(vtable)
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
KEEP(*(.jcr*))
|
||||
. = ALIGN(4);
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
_edata = .;
|
||||
|
||||
} > RAM
|
||||
|
||||
.bss :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__bss_start__ = .;
|
||||
_sbss = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
__bss_end__ = .;
|
||||
_ebss = .;
|
||||
} > RAM
|
||||
|
||||
.heap (COPY):
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
*(.heap*)
|
||||
__HeapLimit = .;
|
||||
} > RAM
|
||||
|
||||
/* .stack_dummy section doesn't contains any symbols. It is only
|
||||
* used for linker to calculate size of stack sections, and assign
|
||||
* values to stack symbols later */
|
||||
.stack_dummy (COPY):
|
||||
{
|
||||
*(.stack*)
|
||||
} > RAM
|
||||
|
||||
/* Set stack top to end of RAM, and stack limit move down by
|
||||
* size of stack_dummy section */
|
||||
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
|
||||
_estack = __StackTop;
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
/* Check if data + heap + stack exceeds RAM limit */
|
||||
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
|
||||
}
|
||||
|
|
@ -0,0 +1,421 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file startup_stm32l152xc.s
|
||||
* @author MCD Application Team
|
||||
* @version V2.0.0
|
||||
* @date 5-September-2014
|
||||
* @brief STM32L152XC Devices vector table for
|
||||
* Atollic toolchain.
|
||||
* This module performs:
|
||||
* - Set the initial SP
|
||||
* - Set the initial PC == Reset_Handler,
|
||||
* - Set the vector table entries with the exceptions ISR address
|
||||
* - Configure the clock system
|
||||
* - Branches to main in the C library (which eventually
|
||||
* calls main()).
|
||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
||||
* priority is Privileged, and the Stack is set to Main.
|
||||
******************************************************************************
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
.syntax unified
|
||||
.cpu cortex-m3
|
||||
.fpu softvfp
|
||||
.thumb
|
||||
|
||||
.global g_pfnVectors
|
||||
.global Default_Handler
|
||||
|
||||
/* start address for the initialization values of the .data section.
|
||||
defined in linker script */
|
||||
.word _sidata
|
||||
/* start address for the .data section. defined in linker script */
|
||||
.word _sdata
|
||||
/* end address for the .data section. defined in linker script */
|
||||
.word _edata
|
||||
/* start address for the .bss section. defined in linker script */
|
||||
.word _sbss
|
||||
/* end address for the .bss section. defined in linker script */
|
||||
.word _ebss
|
||||
|
||||
.equ BootRAM, 0xF108F85F
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor first
|
||||
* starts execution following a reset event. Only the absolutely
|
||||
* necessary set is performed, after which the application
|
||||
* supplied main() routine is called.
|
||||
* @param None
|
||||
* @retval : None
|
||||
*/
|
||||
|
||||
.section .text.Reset_Handler
|
||||
.weak Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
|
||||
/* Copy the data segment initializers from flash to SRAM */
|
||||
movs r1, #0
|
||||
b LoopCopyDataInit
|
||||
|
||||
CopyDataInit:
|
||||
ldr r3, =_sidata
|
||||
ldr r3, [r3, r1]
|
||||
str r3, [r0, r1]
|
||||
adds r1, r1, #4
|
||||
|
||||
LoopCopyDataInit:
|
||||
ldr r0, =_sdata
|
||||
ldr r3, =_edata
|
||||
adds r2, r0, r1
|
||||
cmp r2, r3
|
||||
bcc CopyDataInit
|
||||
ldr r2, =_sbss
|
||||
b LoopFillZerobss
|
||||
/* Zero fill the bss segment. */
|
||||
FillZerobss:
|
||||
movs r3, #0
|
||||
str r3, [r2], #4
|
||||
|
||||
LoopFillZerobss:
|
||||
ldr r3, = _ebss
|
||||
cmp r2, r3
|
||||
bcc FillZerobss
|
||||
|
||||
/* Call the clock system intitialization function.*/
|
||||
bl SystemInit
|
||||
/* Call static constructors */
|
||||
bl __libc_init_array
|
||||
/* Call the application's entry point.*/
|
||||
bl main
|
||||
bx lr
|
||||
.size Reset_Handler, .-Reset_Handler
|
||||
|
||||
/**
|
||||
* @brief This is the code that gets called when the processor receives an
|
||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
||||
* the system state for examination by a debugger.
|
||||
*
|
||||
* @param None
|
||||
* @retval : None
|
||||
*/
|
||||
.section .text.Default_Handler,"ax",%progbits
|
||||
Default_Handler:
|
||||
Infinite_Loop:
|
||||
b Infinite_Loop
|
||||
.size Default_Handler, .-Default_Handler
|
||||
/******************************************************************************
|
||||
*
|
||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
||||
* must be placed on this to ensure that it ends up at physical address
|
||||
* 0x0000.0000.
|
||||
*
|
||||
******************************************************************************/
|
||||
.section .isr_vector,"a",%progbits
|
||||
.type g_pfnVectors, %object
|
||||
.size g_pfnVectors, .-g_pfnVectors
|
||||
|
||||
|
||||
g_pfnVectors:
|
||||
.word _estack
|
||||
.word Reset_Handler
|
||||
.word NMI_Handler
|
||||
.word HardFault_Handler
|
||||
.word MemManage_Handler
|
||||
.word BusFault_Handler
|
||||
.word UsageFault_Handler
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word SVC_Handler
|
||||
.word DebugMon_Handler
|
||||
.word 0
|
||||
.word PendSV_Handler
|
||||
.word SysTick_Handler
|
||||
.word WWDG_IRQHandler
|
||||
.word PVD_IRQHandler
|
||||
.word TAMPER_STAMP_IRQHandler
|
||||
.word RTC_WKUP_IRQHandler
|
||||
.word FLASH_IRQHandler
|
||||
.word RCC_IRQHandler
|
||||
.word EXTI0_IRQHandler
|
||||
.word EXTI1_IRQHandler
|
||||
.word EXTI2_IRQHandler
|
||||
.word EXTI3_IRQHandler
|
||||
.word EXTI4_IRQHandler
|
||||
.word DMA1_Channel1_IRQHandler
|
||||
.word DMA1_Channel2_IRQHandler
|
||||
.word DMA1_Channel3_IRQHandler
|
||||
.word DMA1_Channel4_IRQHandler
|
||||
.word DMA1_Channel5_IRQHandler
|
||||
.word DMA1_Channel6_IRQHandler
|
||||
.word DMA1_Channel7_IRQHandler
|
||||
.word ADC1_IRQHandler
|
||||
.word USB_HP_IRQHandler
|
||||
.word USB_LP_IRQHandler
|
||||
.word DAC_IRQHandler
|
||||
.word COMP_IRQHandler
|
||||
.word EXTI9_5_IRQHandler
|
||||
.word LCD_IRQHandler
|
||||
.word TIM9_IRQHandler
|
||||
.word TIM10_IRQHandler
|
||||
.word TIM11_IRQHandler
|
||||
.word TIM2_IRQHandler
|
||||
.word TIM3_IRQHandler
|
||||
.word TIM4_IRQHandler
|
||||
.word I2C1_EV_IRQHandler
|
||||
.word I2C1_ER_IRQHandler
|
||||
.word I2C2_EV_IRQHandler
|
||||
.word I2C2_ER_IRQHandler
|
||||
.word SPI1_IRQHandler
|
||||
.word SPI2_IRQHandler
|
||||
.word USART1_IRQHandler
|
||||
.word USART2_IRQHandler
|
||||
.word USART3_IRQHandler
|
||||
.word EXTI15_10_IRQHandler
|
||||
.word RTC_Alarm_IRQHandler
|
||||
.word USB_FS_WKUP_IRQHandler
|
||||
.word TIM6_IRQHandler
|
||||
.word TIM7_IRQHandler
|
||||
.word 0
|
||||
.word TIM5_IRQHandler
|
||||
.word SPI3_IRQHandler
|
||||
.word 0
|
||||
.word 0
|
||||
.word DMA2_Channel1_IRQHandler
|
||||
.word DMA2_Channel2_IRQHandler
|
||||
.word DMA2_Channel3_IRQHandler
|
||||
.word DMA2_Channel4_IRQHandler
|
||||
.word DMA2_Channel5_IRQHandler
|
||||
.word 0
|
||||
.word COMP_ACQ_IRQHandler
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word BootRAM /* @0x108. This is for boot in RAM mode for
|
||||
STM32L152XE devices. */
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
||||
* As they are weak aliases, any function with the same name will override
|
||||
* this definition.
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
.weak NMI_Handler
|
||||
.thumb_set NMI_Handler,Default_Handler
|
||||
|
||||
.weak HardFault_Handler
|
||||
.thumb_set HardFault_Handler,Default_Handler
|
||||
|
||||
.weak MemManage_Handler
|
||||
.thumb_set MemManage_Handler,Default_Handler
|
||||
|
||||
.weak BusFault_Handler
|
||||
.thumb_set BusFault_Handler,Default_Handler
|
||||
|
||||
.weak UsageFault_Handler
|
||||
.thumb_set UsageFault_Handler,Default_Handler
|
||||
|
||||
.weak SVC_Handler
|
||||
.thumb_set SVC_Handler,Default_Handler
|
||||
|
||||
.weak DebugMon_Handler
|
||||
.thumb_set DebugMon_Handler,Default_Handler
|
||||
|
||||
.weak PendSV_Handler
|
||||
.thumb_set PendSV_Handler,Default_Handler
|
||||
|
||||
.weak SysTick_Handler
|
||||
.thumb_set SysTick_Handler,Default_Handler
|
||||
|
||||
.weak WWDG_IRQHandler
|
||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
||||
|
||||
.weak PVD_IRQHandler
|
||||
.thumb_set PVD_IRQHandler,Default_Handler
|
||||
|
||||
.weak TAMPER_STAMP_IRQHandler
|
||||
.thumb_set TAMPER_STAMP_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_WKUP_IRQHandler
|
||||
.thumb_set RTC_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak FLASH_IRQHandler
|
||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
||||
|
||||
.weak RCC_IRQHandler
|
||||
.thumb_set RCC_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI0_IRQHandler
|
||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI1_IRQHandler
|
||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI2_IRQHandler
|
||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI3_IRQHandler
|
||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI4_IRQHandler
|
||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel1_IRQHandler
|
||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel2_IRQHandler
|
||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel3_IRQHandler
|
||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel4_IRQHandler
|
||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel5_IRQHandler
|
||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel6_IRQHandler
|
||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA1_Channel7_IRQHandler
|
||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
||||
|
||||
.weak ADC1_IRQHandler
|
||||
.thumb_set ADC1_IRQHandler,Default_Handler
|
||||
|
||||
.weak USB_HP_IRQHandler
|
||||
.thumb_set USB_HP_IRQHandler,Default_Handler
|
||||
|
||||
.weak USB_LP_IRQHandler
|
||||
.thumb_set USB_LP_IRQHandler,Default_Handler
|
||||
|
||||
.weak DAC_IRQHandler
|
||||
.thumb_set DAC_IRQHandler,Default_Handler
|
||||
|
||||
.weak COMP_IRQHandler
|
||||
.thumb_set COMP_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI9_5_IRQHandler
|
||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
||||
|
||||
.weak LCD_IRQHandler
|
||||
.thumb_set LCD_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM9_IRQHandler
|
||||
.thumb_set TIM9_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM10_IRQHandler
|
||||
.thumb_set TIM10_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM11_IRQHandler
|
||||
.thumb_set TIM11_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM2_IRQHandler
|
||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM3_IRQHandler
|
||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM4_IRQHandler
|
||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C1_EV_IRQHandler
|
||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C1_ER_IRQHandler
|
||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C2_EV_IRQHandler
|
||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
||||
|
||||
.weak I2C2_ER_IRQHandler
|
||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI1_IRQHandler
|
||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI2_IRQHandler
|
||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART1_IRQHandler
|
||||
.thumb_set USART1_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART2_IRQHandler
|
||||
.thumb_set USART2_IRQHandler,Default_Handler
|
||||
|
||||
.weak USART3_IRQHandler
|
||||
.thumb_set USART3_IRQHandler,Default_Handler
|
||||
|
||||
.weak EXTI15_10_IRQHandler
|
||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
||||
|
||||
.weak RTC_Alarm_IRQHandler
|
||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
||||
|
||||
.weak USB_FS_WKUP_IRQHandler
|
||||
.thumb_set USB_FS_WKUP_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM6_IRQHandler
|
||||
.thumb_set TIM6_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM7_IRQHandler
|
||||
.thumb_set TIM7_IRQHandler,Default_Handler
|
||||
|
||||
.weak TIM5_IRQHandler
|
||||
.thumb_set TIM5_IRQHandler,Default_Handler
|
||||
|
||||
.weak SPI3_IRQHandler
|
||||
.thumb_set SPI3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel1_IRQHandler
|
||||
.thumb_set DMA2_Channel1_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel2_IRQHandler
|
||||
.thumb_set DMA2_Channel2_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel3_IRQHandler
|
||||
.thumb_set DMA2_Channel3_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel4_IRQHandler
|
||||
.thumb_set DMA2_Channel4_IRQHandler,Default_Handler
|
||||
|
||||
.weak DMA2_Channel5_IRQHandler
|
||||
.thumb_set DMA2_Channel5_IRQHandler,Default_Handler
|
||||
|
||||
.weak COMP_ACQ_IRQHandler
|
||||
.thumb_set COMP_ACQ_IRQHandler,Default_Handler
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
||||
|
|
@ -0,0 +1,536 @@
|
|||
;/******************** (C) COPYRIGHT 2014 STMicroelectronics ********************
|
||||
;* File Name : startup_stm32l152xc.s
|
||||
;* Author : MCD Application Team
|
||||
;* Version : V1.0.0
|
||||
;* Date : 5-September-2014
|
||||
;* Description : STM32L152XC Devices vector for EWARM toolchain.
|
||||
;* This module performs:
|
||||
;* - Set the initial SP
|
||||
;* - Set the initial PC == __iar_program_start,
|
||||
;* - Set the vector table entries with the exceptions ISR
|
||||
;* address.
|
||||
;* - Configure the system clock
|
||||
;* - Branches to main in the C library (which eventually
|
||||
;* calls main()).
|
||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
||||
;* priority is Privileged, and the Stack is set to Main.
|
||||
;********************************************************************************
|
||||
;*
|
||||
;* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||
;*
|
||||
;* Redistribution and use in source and binary forms, with or without modification,
|
||||
;* are permitted provided that the following conditions are met:
|
||||
;* 1. Redistributions of source code must retain the above copyright notice,
|
||||
;* this list of conditions and the following disclaimer.
|
||||
;* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
;* this list of conditions and the following disclaimer in the documentation
|
||||
;* and/or other materials provided with the distribution.
|
||||
;* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
;* may be used to endorse or promote products derived from this software
|
||||
;* without specific prior written permission.
|
||||
;*
|
||||
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
;* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
;* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
;* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
;* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
;* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
;* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
;* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;*
|
||||
;*******************************************************************************
|
||||
;
|
||||
;
|
||||
; The modules in this file are included in the libraries, and may be replaced
|
||||
; by any user-defined modules that define the PUBLIC symbol _program_start or
|
||||
; a user defined start symbol.
|
||||
; To override the cstartup defined in the library, simply add your modified
|
||||
; version to the workbench project.
|
||||
;
|
||||
; The vector table is normally located at address 0.
|
||||
; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
|
||||
; The name "__vector_table" has special meaning for C-SPY:
|
||||
; it is where the SP start value is found, and the NVIC vector
|
||||
; table register (VTOR) is initialized to this address if != 0.
|
||||
;
|
||||
; Cortex-M version
|
||||
;
|
||||
|
||||
MODULE ?cstartup
|
||||
|
||||
;; Forward declaration of sections.
|
||||
SECTION CSTACK:DATA:NOROOT(3)
|
||||
|
||||
SECTION .intvec:CODE:NOROOT(2)
|
||||
|
||||
EXTERN __iar_program_start
|
||||
EXTERN SystemInit
|
||||
PUBLIC __vector_table
|
||||
|
||||
DATA
|
||||
__vector_table
|
||||
DCD sfe(CSTACK)
|
||||
DCD Reset_Handler ; Reset Handler
|
||||
|
||||
DCD NMI_Handler ; NMI Handler
|
||||
DCD HardFault_Handler ; Hard Fault Handler
|
||||
DCD MemManage_Handler ; MPU Fault Handler
|
||||
DCD BusFault_Handler ; Bus Fault Handler
|
||||
DCD UsageFault_Handler ; Usage Fault Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD SVC_Handler ; SVCall Handler
|
||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
||||
DCD 0 ; Reserved
|
||||
DCD PendSV_Handler ; PendSV Handler
|
||||
DCD SysTick_Handler ; SysTick Handler
|
||||
|
||||
; External Interrupts
|
||||
DCD WWDG_IRQHandler ; Window Watchdog
|
||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
||||
DCD TAMPER_STAMP_IRQHandler ; Tamper and Time Stamp
|
||||
DCD RTC_WKUP_IRQHandler ; RTC Wakeup
|
||||
DCD FLASH_IRQHandler ; FLASH
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
||||
DCD ADC1_IRQHandler ; ADC1
|
||||
DCD USB_HP_IRQHandler ; USB High Priority
|
||||
DCD USB_LP_IRQHandler ; USB Low Priority
|
||||
DCD DAC_IRQHandler ; DAC
|
||||
DCD COMP_IRQHandler ; COMP through EXTI Line
|
||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
||||
DCD LCD_IRQHandler ; LCD
|
||||
DCD TIM9_IRQHandler ; TIM9
|
||||
DCD TIM10_IRQHandler ; TIM10
|
||||
DCD TIM11_IRQHandler ; TIM11
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD TIM3_IRQHandler ; TIM3
|
||||
DCD TIM4_IRQHandler ; TIM4
|
||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
||||
DCD SPI1_IRQHandler ; SPI1
|
||||
DCD SPI2_IRQHandler ; SPI2
|
||||
DCD USART1_IRQHandler ; USART1
|
||||
DCD USART2_IRQHandler ; USART2
|
||||
DCD USART3_IRQHandler ; USART3
|
||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
||||
DCD USB_FS_WKUP_IRQHandler ; USB FS Wakeup from suspend
|
||||
DCD TIM6_IRQHandler ; TIM6
|
||||
DCD TIM7_IRQHandler ; TIM7
|
||||
DCD 0 ; Reserved
|
||||
DCD TIM5_IRQHandler ; TIM5
|
||||
DCD SPI3_IRQHandler ; SPI3
|
||||
DCD 0 ; Reserved
|
||||
DCD 0 ; Reserved
|
||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel 1
|
||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel 2
|
||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel 3
|
||||
DCD DMA2_Channel4_IRQHandler ; DMA2 Channel 4
|
||||
DCD DMA2_Channel5_IRQHandler ; DMA2 Channel 5
|
||||
DCD 0 ; Reserved
|
||||
DCD COMP_ACQ_IRQHandler ; Comparator Channel Acquisition
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; Default interrupt handlers.
|
||||
;;
|
||||
THUMB
|
||||
|
||||
PUBWEAK Reset_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(2)
|
||||
Reset_Handler
|
||||
LDR R0, =SystemInit
|
||||
BLX R0
|
||||
LDR R0, =__iar_program_start
|
||||
BX R0
|
||||
|
||||
PUBWEAK NMI_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
NMI_Handler
|
||||
B NMI_Handler
|
||||
|
||||
|
||||
PUBWEAK HardFault_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
HardFault_Handler
|
||||
B HardFault_Handler
|
||||
|
||||
|
||||
PUBWEAK MemManage_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
MemManage_Handler
|
||||
B MemManage_Handler
|
||||
|
||||
|
||||
PUBWEAK BusFault_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
BusFault_Handler
|
||||
B BusFault_Handler
|
||||
|
||||
|
||||
PUBWEAK UsageFault_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
UsageFault_Handler
|
||||
B UsageFault_Handler
|
||||
|
||||
|
||||
PUBWEAK SVC_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SVC_Handler
|
||||
B SVC_Handler
|
||||
|
||||
|
||||
PUBWEAK DebugMon_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DebugMon_Handler
|
||||
B DebugMon_Handler
|
||||
|
||||
|
||||
PUBWEAK PendSV_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
PendSV_Handler
|
||||
B PendSV_Handler
|
||||
|
||||
|
||||
PUBWEAK SysTick_Handler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SysTick_Handler
|
||||
B SysTick_Handler
|
||||
|
||||
|
||||
PUBWEAK WWDG_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
WWDG_IRQHandler
|
||||
B WWDG_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK PVD_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
PVD_IRQHandler
|
||||
B PVD_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK TAMPER_STAMP_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TAMPER_STAMP_IRQHandler
|
||||
B TAMPER_STAMP_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK RTC_WKUP_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
RTC_WKUP_IRQHandler
|
||||
B RTC_WKUP_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK FLASH_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
FLASH_IRQHandler
|
||||
B FLASH_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK RCC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
RCC_IRQHandler
|
||||
B RCC_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK EXTI0_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
EXTI0_IRQHandler
|
||||
B EXTI0_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK EXTI1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
EXTI1_IRQHandler
|
||||
B EXTI1_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK EXTI2_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
EXTI2_IRQHandler
|
||||
B EXTI2_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK EXTI3_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
EXTI3_IRQHandler
|
||||
B EXTI3_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK EXTI4_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
EXTI4_IRQHandler
|
||||
B EXTI4_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DMA1_Channel1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DMA1_Channel1_IRQHandler
|
||||
B DMA1_Channel1_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DMA1_Channel2_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DMA1_Channel2_IRQHandler
|
||||
B DMA1_Channel2_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DMA1_Channel3_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DMA1_Channel3_IRQHandler
|
||||
B DMA1_Channel3_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DMA1_Channel4_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DMA1_Channel4_IRQHandler
|
||||
B DMA1_Channel4_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DMA1_Channel5_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DMA1_Channel5_IRQHandler
|
||||
B DMA1_Channel5_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DMA1_Channel6_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DMA1_Channel6_IRQHandler
|
||||
B DMA1_Channel6_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DMA1_Channel7_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DMA1_Channel7_IRQHandler
|
||||
B DMA1_Channel7_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK ADC1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
ADC1_IRQHandler
|
||||
B ADC1_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK USB_HP_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
USB_HP_IRQHandler
|
||||
B USB_HP_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK USB_LP_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
USB_LP_IRQHandler
|
||||
B USB_LP_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DAC_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DAC_IRQHandler
|
||||
B DAC_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK COMP_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
COMP_IRQHandler
|
||||
B COMP_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK EXTI9_5_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
EXTI9_5_IRQHandler
|
||||
B EXTI9_5_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK LCD_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
LCD_IRQHandler
|
||||
B LCD_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK TIM9_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIM9_IRQHandler
|
||||
B TIM9_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK TIM10_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIM10_IRQHandler
|
||||
B TIM10_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK TIM11_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIM11_IRQHandler
|
||||
B TIM11_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK TIM2_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIM2_IRQHandler
|
||||
B TIM2_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK TIM3_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIM3_IRQHandler
|
||||
B TIM3_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK TIM4_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIM4_IRQHandler
|
||||
B TIM4_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK I2C1_EV_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
I2C1_EV_IRQHandler
|
||||
B I2C1_EV_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK I2C1_ER_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
I2C1_ER_IRQHandler
|
||||
B I2C1_ER_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK I2C2_EV_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
I2C2_EV_IRQHandler
|
||||
B I2C2_EV_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK I2C2_ER_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
I2C2_ER_IRQHandler
|
||||
B I2C2_ER_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK SPI1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SPI1_IRQHandler
|
||||
B SPI1_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK SPI2_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SPI2_IRQHandler
|
||||
B SPI2_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK USART1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
USART1_IRQHandler
|
||||
B USART1_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK USART2_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
USART2_IRQHandler
|
||||
B USART2_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK USART3_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
USART3_IRQHandler
|
||||
B USART3_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK EXTI15_10_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
EXTI15_10_IRQHandler
|
||||
B EXTI15_10_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK RTC_Alarm_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
RTC_Alarm_IRQHandler
|
||||
B RTC_Alarm_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK USB_FS_WKUP_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
USB_FS_WKUP_IRQHandler
|
||||
B USB_FS_WKUP_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK TIM6_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIM6_IRQHandler
|
||||
B TIM6_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK TIM7_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIM7_IRQHandler
|
||||
B TIM7_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK TIM5_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
TIM5_IRQHandler
|
||||
B TIM5_IRQHandler
|
||||
|
||||
PUBWEAK SPI3_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
SPI3_IRQHandler
|
||||
B SPI3_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DMA2_Channel1_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DMA2_Channel1_IRQHandler
|
||||
B DMA2_Channel1_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DMA2_Channel2_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DMA2_Channel2_IRQHandler
|
||||
B DMA2_Channel2_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DMA2_Channel3_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DMA2_Channel3_IRQHandler
|
||||
B DMA2_Channel3_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DMA2_Channel4_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DMA2_Channel4_IRQHandler
|
||||
B DMA2_Channel4_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK DMA2_Channel5_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
DMA2_Channel5_IRQHandler
|
||||
B DMA2_Channel5_IRQHandler
|
||||
|
||||
|
||||
PUBWEAK COMP_ACQ_IRQHandler
|
||||
SECTION .text:CODE:REORDER:NOROOT(1)
|
||||
COMP_ACQ_IRQHandler
|
||||
B COMP_ACQ_IRQHandler
|
||||
|
||||
END
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/* [ROM = 256kb = 0x40000] */
|
||||
define symbol __intvec_start__ = 0x08000000;
|
||||
define symbol __region_ROM_start__ = 0x08000000;
|
||||
define symbol __region_ROM_end__ = 0x0803FFFF;
|
||||
|
||||
/* [RAM = 32kb = 0x8000] Vector table dynamic copy: 73 vectors = 292 bytes (0x124) to be reserved in RAM */
|
||||
define symbol __NVIC_start__ = 0x20000000;
|
||||
define symbol __NVIC_end__ = 0x20000127; /* Add 4 more bytes to be aligned on 8 bytes */
|
||||
define symbol __region_RAM_start__ = 0x20000128;
|
||||
define symbol __region_RAM_end__ = 0x20007FFF;
|
||||
|
||||
/* Memory regions */
|
||||
define memory mem with size = 4G;
|
||||
define region ROM_region = mem:[from __region_ROM_start__ to __region_ROM_end__];
|
||||
define region RAM_region = mem:[from __region_RAM_start__ to __region_RAM_end__];
|
||||
|
||||
/* Stack and Heap */
|
||||
define symbol __size_cstack__ = 0x800;
|
||||
define symbol __size_heap__ = 0x800;
|
||||
define block CSTACK with alignment = 8, size = __size_cstack__ { };
|
||||
define block HEAP with alignment = 8, size = __size_heap__ { };
|
||||
define block STACKHEAP with fixed order { block HEAP, block CSTACK };
|
||||
|
||||
initialize by copy with packing = zeros { readwrite };
|
||||
do not initialize { section .noinit };
|
||||
|
||||
place at address mem:__intvec_start__ { readonly section .intvec };
|
||||
|
||||
place in ROM_region { readonly };
|
||||
place in RAM_region { readwrite, block STACKHEAP };
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/* mbed Microcontroller Library
|
||||
* A generic CMSIS include header
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef MBED_CMSIS_H
|
||||
#define MBED_CMSIS_H
|
||||
|
||||
#include "stm32l1xx.h"
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/* mbed Microcontroller Library
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
#define NVIC_RAM_VECTOR_ADDRESS (0x20000000) // Vectors positioned at start of RAM
|
||||
#define NVIC_FLASH_VECTOR_ADDRESS (0x08000000) // Initial vector position in flash
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
|
||||
uint32_t *vectors = (uint32_t *)SCB->VTOR;
|
||||
uint32_t i;
|
||||
|
||||
// Copy and switch to dynamic vectors if the first time called
|
||||
if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
|
||||
uint32_t *old_vectors = vectors;
|
||||
vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
|
||||
for (i=0; i<NVIC_NUM_VECTORS; i++) {
|
||||
vectors[i] = old_vectors[i];
|
||||
}
|
||||
SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
|
||||
}
|
||||
vectors[IRQn + NVIC_USER_IRQ_OFFSET] = vector;
|
||||
}
|
||||
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn) {
|
||||
uint32_t *vectors = (uint32_t*)SCB->VTOR;
|
||||
return vectors[IRQn + NVIC_USER_IRQ_OFFSET];
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/* mbed Microcontroller Library
|
||||
* CMSIS-style functionality to support dynamic vectors
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef MBED_CMSIS_NVIC_H
|
||||
#define MBED_CMSIS_NVIC_H
|
||||
|
||||
// STM32L152RC
|
||||
// CORE: 16 vectors = 64 bytes from 0x00 to 0x3F
|
||||
// MCU Peripherals: 57 vectors = 228 bytes from 0x40 to 0x123
|
||||
// Total: 73 vectors = 292 bytes (0x124) to be reserved in RAM
|
||||
#define NVIC_NUM_VECTORS 73
|
||||
#define NVIC_USER_IRQ_OFFSET 16
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
|
||||
uint32_t NVIC_GetVector(IRQn_Type IRQn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file hal_tick.c
|
||||
* @author MCD Application Team
|
||||
* @brief Initialization of HAL tick
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "hal_tick.h"
|
||||
|
||||
TIM_HandleTypeDef TimMasterHandle;
|
||||
uint32_t PreviousVal = 0;
|
||||
|
||||
void us_ticker_irq_handler(void);
|
||||
|
||||
void timer_irq_handler(void) {
|
||||
// Channel 1 for mbed timeout
|
||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||
us_ticker_irq_handler();
|
||||
}
|
||||
|
||||
// Channel 2 for HAL tick
|
||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
uint32_t val = __HAL_TIM_GetCounter(&TimMasterHandle);
|
||||
if ((val - PreviousVal) >= HAL_TICK_DELAY) {
|
||||
// Increment HAL variable
|
||||
HAL_IncTick();
|
||||
// Prepare next interrupt
|
||||
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_2, val + HAL_TICK_DELAY);
|
||||
PreviousVal = val;
|
||||
#if 0 // For DEBUG only
|
||||
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_6);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||
// Enable timer clock
|
||||
TIM_MST_RCC;
|
||||
|
||||
// Reset timer
|
||||
TIM_MST_RESET_ON;
|
||||
TIM_MST_RESET_OFF;
|
||||
|
||||
// Update the SystemCoreClock variable
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
// Configure time base
|
||||
TimMasterHandle.Instance = TIM_MST;
|
||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||
TimMasterHandle.Init.ClockDivision = 0;
|
||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
HAL_TIM_OC_Init(&TimMasterHandle);
|
||||
|
||||
NVIC_SetVector(TIM_MST_IRQ, (uint32_t)timer_irq_handler);
|
||||
NVIC_EnableIRQ(TIM_MST_IRQ);
|
||||
|
||||
// Channel 1 for mbed timeout
|
||||
HAL_TIM_OC_Start(&TimMasterHandle, TIM_CHANNEL_1);
|
||||
|
||||
// Channel 2 for HAL tick
|
||||
HAL_TIM_OC_Start(&TimMasterHandle, TIM_CHANNEL_2);
|
||||
PreviousVal = __HAL_TIM_GetCounter(&TimMasterHandle);
|
||||
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_2, PreviousVal + HAL_TICK_DELAY);
|
||||
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
|
||||
#if 0 // For DEBUG only
|
||||
__GPIOB_CLK_ENABLE();
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_6;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
#endif
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file hal_tick.h
|
||||
* @author MCD Application Team
|
||||
* @brief Initialization of HAL tick
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef __HAL_TICK_H
|
||||
#define __HAL_TICK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "stm32l1xx.h"
|
||||
#include "cmsis_nvic.h"
|
||||
|
||||
#define TIM_MST TIM5
|
||||
#define TIM_MST_IRQ TIM5_IRQn
|
||||
#define TIM_MST_RCC __TIM5_CLK_ENABLE()
|
||||
|
||||
#define TIM_MST_RESET_ON __TIM5_FORCE_RESET()
|
||||
#define TIM_MST_RESET_OFF __TIM5_RELEASE_RESET()
|
||||
|
||||
#define HAL_TICK_DELAY (1000) // 1 ms
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __HAL_TICK_H
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,247 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l1xx.h
|
||||
* @author MCD Application Team
|
||||
* @version V2.0.0
|
||||
* @date 5-September-2014
|
||||
* @brief CMSIS STM32L1xx Device Peripheral Access Layer Header File.
|
||||
*
|
||||
* The file is the unique include file that the application programmer
|
||||
* is using in the C source code, usually in main.c. This file contains:
|
||||
* - Configuration section that allows to select:
|
||||
* - The STM32L1xx device used in the target application
|
||||
* - To use or not the peripheral’s drivers in application code(i.e.
|
||||
* code will be based on direct access to peripheral’s registers
|
||||
* rather than drivers API), this option is controlled by
|
||||
* "#define USE_HAL_DRIVER"
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup CMSIS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup stm32l1xx
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __STM32L1XX_H
|
||||
#define __STM32L1XX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/** @addtogroup Library_configuration_section
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Uncomment the line below according to the target STM32L device used in your
|
||||
application
|
||||
*/
|
||||
|
||||
#if !defined (STM32L100xB) && !defined (STM32L100xBA) && !defined (STM32L100xC) && \
|
||||
!defined (STM32L151xB) && !defined (STM32L151xBA) && !defined (STM32L151xC) && !defined (STM32L151xCA) && !defined (STM32L151xD) && !defined (STM32L151xE) && \
|
||||
!defined (STM32L152xB) && !defined (STM32L152xBA) && !defined (STM32L152xC) && !defined (STM32L152xCA) && !defined (STM32L152xD) && !defined (STM32L152xE) && \
|
||||
!defined (STM32L162xC) && !defined (STM32L162xCA) && !defined (STM32L162xD) && !defined (STM32L162xE)
|
||||
/* #define STM32L100xB */ /*!< STM32L100C6, STM32L100R and STM32L100RB Devices */
|
||||
/* #define STM32L100xBA */ /*!< STM32L100C6-A, STM32L100R8-A and STM32L100RB-A Devices */
|
||||
/* #define STM32L100xC */ /*!< STM32L100RC Devices */
|
||||
/* #define STM32L151xB */ /*!< STM32L151C6, STM32L151R6, STM32L151C8, STM32L151R8, STM32L151V8, STM32L151CB, STM32L151RB and STM32L151VB */
|
||||
/* #define STM32L151xBA */ /*!< STM32L151C6-A, STM32L151R6-A, STM32L151C8-A, STM32L151R8-A, STM32L151V8-A, STM32L151CB-A, STM32L151RB-A and STM32L151VB-A */
|
||||
/* #define STM32L151xC */ /*!< STM32L151CC, STM32L151UC, STM32L151RC and STM32L151VC */
|
||||
/* #define STM32L151xCA */ /*!< STM32L151RC-A, STM32L151VC-A, STM32L151QC and STM32L151ZC */
|
||||
/* #define STM32L151xD */ /*!< STM32L151QD, STM32L151RD, STM32L151VD & STM32L151ZD */
|
||||
/* #define STM32L151xE */ /*!< STM32L151QE, STM32L151RE, STM32L151VE and STM32L151ZE */
|
||||
/* #define STM32L152xB */ /*!< STM32L152C6, STM32L152R6, STM32L152C8, STM32L152R8, STM32L152V8, STM32L152CB, STM32L152RB and STM32L152VB */
|
||||
/* #define STM32L152xBA */ /*!< STM32L152C6-A, STM32L152R6-A, STM32L152C8-A, STM32L152R8-A, STM32L152V8-A, STM32L152CB-A, STM32L152RB-A and STM32L152VB-A */
|
||||
#define STM32L152xC /*!< STM32L152CC, STM32L152UC, STM32L152RC and STM32L152VC */
|
||||
/* #define STM32L152xCA */ /*!< STM32L152RC-A, STM32L152VC-A, STM32L152QC and STM32L152ZC */
|
||||
/* #define STM32L152xD */ /*!< STM32L152QD, STM32L152RD, STM32L152VD and STM32L152ZD */
|
||||
/* #define STM32L152xE */ /*!< STM32L152QE, STM32L152RE, STM32L152VE and STM32L152ZE */
|
||||
/* #define STM32L162xC */ /*!< STM32L162RC and STM32L162VC */
|
||||
/* #define STM32L162xCA */ /*!< STM32L162RC-A, STM32L162VC-A, STM32L162QC and STM32L162ZC */
|
||||
/* #define STM32L162xD */ /*!< STM32L162QD, STM32L162RD, STM32L162VD and STM32L162ZD */
|
||||
/* #define STM32L162xE */ /*!< STM32L162RE, STM32L162VE and STM32L162ZE */
|
||||
#endif
|
||||
|
||||
/* Tip: To avoid modifying this file each time you need to switch between these
|
||||
devices, you can define the device in your toolchain compiler preprocessor.
|
||||
*/
|
||||
|
||||
#if !defined (USE_HAL_DRIVER)
|
||||
/**
|
||||
* @brief Comment the line below if you will not use the peripherals drivers.
|
||||
In this case, these drivers will not be included and the application code will
|
||||
be based on direct access to peripherals registers
|
||||
*/
|
||||
#define USE_HAL_DRIVER
|
||||
#endif /* USE_HAL_DRIVER */
|
||||
|
||||
/**
|
||||
* @brief CMSIS Device version number V2.0.0
|
||||
*/
|
||||
#define __STM32L1xx_CMSIS_DEVICE_VERSION_MAIN (0x02) /*!< [31:24] main version */
|
||||
#define __STM32L1xx_CMSIS_DEVICE_VERSION_SUB1 (0x00) /*!< [23:16] sub1 version */
|
||||
#define __STM32L1xx_CMSIS_DEVICE_VERSION_SUB2 (0x00) /*!< [15:8] sub2 version */
|
||||
#define __STM32L1xx_CMSIS_DEVICE_VERSION_RC (0x00) /*!< [7:0] release candidate */
|
||||
#define __STM32L1xx_CMSIS_DEVICE_VERSION ((__CMSIS_DEVICE_VERSION_MAIN << 24)\
|
||||
|(__CMSIS_DEVICE_HAL_VERSION_SUB1 << 16)\
|
||||
|(__CMSIS_DEVICE_HAL_VERSION_SUB2 << 8 )\
|
||||
|(__CMSIS_DEVICE_HAL_VERSION_RC))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup Device_Included
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(STM32L100xB)
|
||||
#include "stm32l100xb.h"
|
||||
#elif defined(STM32L100xBA)
|
||||
#include "stm32l100xba.h"
|
||||
#elif defined(STM32L100xC)
|
||||
#include "stm32l100xc.h"
|
||||
#elif defined(STM32L151xB)
|
||||
#include "stm32l151xb.h"
|
||||
#elif defined(STM32L151xBA)
|
||||
#include "stm32l151xba.h"
|
||||
#elif defined(STM32L151xC)
|
||||
#include "stm32l151xc.h"
|
||||
#elif defined(STM32L151xCA)
|
||||
#include "stm32l151xca.h"
|
||||
#elif defined(STM32L151xD)
|
||||
#include "stm32l151xd.h"
|
||||
#elif defined(STM32L151xE)
|
||||
#include "stm32l151xe.h"
|
||||
#elif defined(STM32L152xB)
|
||||
#include "stm32l152xb.h"
|
||||
#elif defined(STM32L152xBA)
|
||||
#include "stm32l152xba.h"
|
||||
#elif defined(STM32L152xC)
|
||||
#include "stm32l152xc.h"
|
||||
#elif defined(STM32L152xCA)
|
||||
#include "stm32l152xca.h"
|
||||
#elif defined(STM32L152xD)
|
||||
#include "stm32l152xd.h"
|
||||
#elif defined(STM32L152xE)
|
||||
#include "stm32l152xe.h"
|
||||
#elif defined(STM32L162xC)
|
||||
#include "stm32l162xc.h"
|
||||
#elif defined(STM32L162xCA)
|
||||
#include "stm32l162xca.h"
|
||||
#elif defined(STM32L162xD)
|
||||
#include "stm32l162xd.h"
|
||||
#elif defined(STM32L162xE)
|
||||
#include "stm32l162xe.h"
|
||||
#else
|
||||
#error "Please select first the target STM32L1xx device used in your application (in stm32l1xx.h file)"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup Exported_types
|
||||
* @{
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
RESET = 0,
|
||||
SET = !RESET
|
||||
} FlagStatus, ITStatus;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DISABLE = 0,
|
||||
ENABLE = !DISABLE
|
||||
} FunctionalState;
|
||||
#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ERROR = 0,
|
||||
SUCCESS = !ERROR
|
||||
} ErrorStatus;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup Exported_macros
|
||||
* @{
|
||||
*/
|
||||
#define SET_BIT(REG, BIT) ((REG) |= (BIT))
|
||||
|
||||
#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
|
||||
|
||||
#define READ_BIT(REG, BIT) ((REG) & (BIT))
|
||||
|
||||
#define CLEAR_REG(REG) ((REG) = (0x0))
|
||||
|
||||
#define WRITE_REG(REG, VAL) ((REG) = (VAL))
|
||||
|
||||
#define READ_REG(REG) ((REG))
|
||||
|
||||
#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
|
||||
|
||||
#define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#if defined (USE_HAL_DRIVER)
|
||||
#include "stm32l1xx_hal.h"
|
||||
#endif /* USE_HAL_DRIVER */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __STM32L1xx_H */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
@ -0,0 +1,607 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file system_stm32l1xx.c
|
||||
* @author MCD Application Team
|
||||
* @version V2.0.0
|
||||
* @date 5-September-2014
|
||||
* @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File.
|
||||
*
|
||||
* This file provides two functions and one global variable to be called from
|
||||
* user application:
|
||||
* - SystemInit(): This function is called at startup just after reset and
|
||||
* before branch to main program. This call is made inside
|
||||
* the "startup_stm32l1xx.s" file.
|
||||
*
|
||||
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
|
||||
* by the user application to setup the SysTick
|
||||
* timer or configure other parameters.
|
||||
*
|
||||
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
|
||||
* be called whenever the core clock is changed
|
||||
* during program execution.
|
||||
*
|
||||
* This file configures the system clock as follows:
|
||||
*-----------------------------------------------------------------------------
|
||||
* System clock source | 1- PLL_HSE_EXTC | 3- PLL_HSI
|
||||
* | (external 8 MHz clock) | (internal 16 MHz)
|
||||
* | 2- PLL_HSE_XTAL |
|
||||
* | (external 8 MHz xtal) |
|
||||
*-----------------------------------------------------------------------------
|
||||
* SYSCLK(MHz) | 24 | 32
|
||||
*-----------------------------------------------------------------------------
|
||||
* AHBCLK (MHz) | 24 | 32
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB1CLK (MHz) | 24 | 32
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB2CLK (MHz) | 24 | 32
|
||||
*-----------------------------------------------------------------------------
|
||||
* USB capable (48 MHz precise clock) | YES | NO
|
||||
*-----------------------------------------------------------------------------
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup CMSIS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup stm32l1xx_system
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L1xx_System_Private_Includes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "stm32l1xx.h"
|
||||
#include "hal_tick.h"
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L1xx_System_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L1xx_System_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
#if !defined (HSE_VALUE)
|
||||
#define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz.
|
||||
This value can be provided and adapted by the user application. */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
#if !defined (HSI_VALUE)
|
||||
#define HSI_VALUE ((uint32_t)16000000) /*!< Default value of the Internal oscillator in Hz.
|
||||
This value can be provided and adapted by the user application. */
|
||||
#endif /* HSI_VALUE */
|
||||
|
||||
/*!< Uncomment the following line if you need to use external SRAM mounted
|
||||
on STM32L152D_EVAL board as data memory */
|
||||
/* #define DATA_IN_ExtSRAM */
|
||||
|
||||
/*!< Uncomment the following line if you need to relocate your vector Table in
|
||||
Internal SRAM. */
|
||||
/* #define VECT_TAB_SRAM */
|
||||
#define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field.
|
||||
This value must be a multiple of 0x200. */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L1xx_System_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Select the clock sources (other than HSI) to start with (0=OFF, 1=ON) */
|
||||
#define USE_PLL_HSE_EXTC (0) /* Use external clock */
|
||||
#define USE_PLL_HSE_XTAL (1) /* Use external xtal */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L1xx_System_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
/* This variable is updated in three ways:
|
||||
1) by calling CMSIS function SystemCoreClockUpdate()
|
||||
2) by calling HAL API function HAL_RCC_GetHCLKFreq()
|
||||
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
|
||||
Note: If you use this function to configure the system clock; then there
|
||||
is no need to call the 2 first functions listed above, since SystemCoreClock
|
||||
variable is updated automatically.
|
||||
*/
|
||||
uint32_t SystemCoreClock = 32000000; /* Default with HSI. Will be updated if HSE is used */
|
||||
const uint8_t PLLMulTable[9] = {3, 4, 6, 8, 12, 16, 24, 32, 48};
|
||||
const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L1xx_System_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined (STM32L151xD) || defined (STM32L152xD) || defined (STM32L162xD)
|
||||
#ifdef DATA_IN_ExtSRAM
|
||||
static void SystemInit_ExtMemCtl(void);
|
||||
#endif /* DATA_IN_ExtSRAM */
|
||||
#endif /* STM32L151xD || STM32L152xD || STM32L162xD */
|
||||
|
||||
#if (USE_PLL_HSE_XTAL != 0) || (USE_PLL_HSE_EXTC != 0)
|
||||
uint8_t SetSysClock_PLL_HSE(uint8_t bypass);
|
||||
#endif
|
||||
|
||||
uint8_t SetSysClock_PLL_HSI(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L1xx_System_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Setup the microcontroller system.
|
||||
* Initialize the Embedded Flash Interface, the PLL and update the
|
||||
* SystemCoreClock variable.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SystemInit (void)
|
||||
{
|
||||
/*!< Set MSION bit */
|
||||
RCC->CR |= (uint32_t)0x00000100;
|
||||
|
||||
/*!< Reset SW[1:0], HPRE[3:0], PPRE1[2:0], PPRE2[2:0], MCOSEL[2:0] and MCOPRE[2:0] bits */
|
||||
RCC->CFGR &= (uint32_t)0x88FFC00C;
|
||||
|
||||
/*!< Reset HSION, HSEON, CSSON and PLLON bits */
|
||||
RCC->CR &= (uint32_t)0xEEFEFFFE;
|
||||
|
||||
/*!< Reset HSEBYP bit */
|
||||
RCC->CR &= (uint32_t)0xFFFBFFFF;
|
||||
|
||||
/*!< Reset PLLSRC, PLLMUL[3:0] and PLLDIV[1:0] bits */
|
||||
RCC->CFGR &= (uint32_t)0xFF02FFFF;
|
||||
|
||||
/*!< Disable all interrupts */
|
||||
RCC->CIR = 0x00000000;
|
||||
|
||||
#ifdef DATA_IN_ExtSRAM
|
||||
SystemInit_ExtMemCtl();
|
||||
#endif /* DATA_IN_ExtSRAM */
|
||||
|
||||
#ifdef VECT_TAB_SRAM
|
||||
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
|
||||
#else
|
||||
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
|
||||
#endif
|
||||
|
||||
/* Configure the Cube driver */
|
||||
SystemCoreClock = 16000000; // At this stage the HSI is used as system clock
|
||||
HAL_Init();
|
||||
|
||||
/* Configure the System clock source, PLL Multiplier and Divider factors,
|
||||
AHB/APBx prescalers and Flash settings */
|
||||
SetSysClock();
|
||||
|
||||
/* Reset the timer to avoid issues after the RAM initialization */
|
||||
TIM_MST_RESET_ON;
|
||||
TIM_MST_RESET_OFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update SystemCoreClock according to Clock Register Values
|
||||
* The SystemCoreClock variable contains the core clock (HCLK), it can
|
||||
* be used by the user application to setup the SysTick timer or configure
|
||||
* other parameters.
|
||||
*
|
||||
* @note Each time the core clock (HCLK) changes, this function must be called
|
||||
* to update SystemCoreClock variable value. Otherwise, any configuration
|
||||
* based on this variable will be incorrect.
|
||||
*
|
||||
* @note - The system frequency computed by this function is not the real
|
||||
* frequency in the chip. It is calculated based on the predefined
|
||||
* constant and the selected clock source:
|
||||
*
|
||||
* - If SYSCLK source is MSI, SystemCoreClock will contain the MSI
|
||||
* value as defined by the MSI range.
|
||||
*
|
||||
* - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
|
||||
*
|
||||
* - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
|
||||
*
|
||||
* - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
|
||||
* or HSI_VALUE(*) multiplied/divided by the PLL factors.
|
||||
*
|
||||
* (*) HSI_VALUE is a constant defined in stm32l1xx.h file (default value
|
||||
* 16 MHz) but the real value may vary depending on the variations
|
||||
* in voltage and temperature.
|
||||
*
|
||||
* (**) HSE_VALUE is a constant defined in stm32l1xx.h file (default value
|
||||
* 8 MHz), user has to ensure that HSE_VALUE is same as the real
|
||||
* frequency of the crystal used. Otherwise, this function may
|
||||
* have wrong result.
|
||||
*
|
||||
* - The result of this function could be not correct when using fractional
|
||||
* value for HSE crystal.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SystemCoreClockUpdate (void)
|
||||
{
|
||||
uint32_t tmp = 0, pllmul = 0, plldiv = 0, pllsource = 0, msirange = 0;
|
||||
|
||||
/* Get SYSCLK source -------------------------------------------------------*/
|
||||
tmp = RCC->CFGR & RCC_CFGR_SWS;
|
||||
|
||||
switch (tmp)
|
||||
{
|
||||
case 0x00: /* MSI used as system clock */
|
||||
msirange = (RCC->ICSCR & RCC_ICSCR_MSIRANGE) >> 13;
|
||||
SystemCoreClock = (32768 * (1 << (msirange + 1)));
|
||||
break;
|
||||
case 0x04: /* HSI used as system clock */
|
||||
SystemCoreClock = HSI_VALUE;
|
||||
break;
|
||||
case 0x08: /* HSE used as system clock */
|
||||
SystemCoreClock = HSE_VALUE;
|
||||
break;
|
||||
case 0x0C: /* PLL used as system clock */
|
||||
/* Get PLL clock source and multiplication factor ----------------------*/
|
||||
pllmul = RCC->CFGR & RCC_CFGR_PLLMUL;
|
||||
plldiv = RCC->CFGR & RCC_CFGR_PLLDIV;
|
||||
pllmul = PLLMulTable[(pllmul >> 18)];
|
||||
plldiv = (plldiv >> 22) + 1;
|
||||
|
||||
pllsource = RCC->CFGR & RCC_CFGR_PLLSRC;
|
||||
|
||||
if (pllsource == 0x00)
|
||||
{
|
||||
/* HSI oscillator clock selected as PLL clock entry */
|
||||
SystemCoreClock = (((HSI_VALUE) * pllmul) / plldiv);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* HSE selected as PLL clock entry */
|
||||
SystemCoreClock = (((HSE_VALUE) * pllmul) / plldiv);
|
||||
}
|
||||
break;
|
||||
default: /* MSI used as system clock */
|
||||
msirange = (RCC->ICSCR & RCC_ICSCR_MSIRANGE) >> 13;
|
||||
SystemCoreClock = (32768 * (1 << (msirange + 1)));
|
||||
break;
|
||||
}
|
||||
/* Compute HCLK clock frequency --------------------------------------------*/
|
||||
/* Get HCLK prescaler */
|
||||
tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
|
||||
/* HCLK clock frequency */
|
||||
SystemCoreClock >>= tmp;
|
||||
}
|
||||
|
||||
#if defined (STM32L151xD) || defined (STM32L152xD) || defined (STM32L162xD)
|
||||
#ifdef DATA_IN_ExtSRAM
|
||||
/**
|
||||
* @brief Setup the external memory controller.
|
||||
* Called in SystemInit() function before jump to main.
|
||||
* This function configures the external SRAM mounted on STM32L152D_EVAL board
|
||||
* This SRAM will be used as program data memory (including heap and stack).
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SystemInit_ExtMemCtl(void)
|
||||
{
|
||||
/*-- GPIOs Configuration -----------------------------------------------------*/
|
||||
/*
|
||||
+-------------------+--------------------+------------------+------------------+
|
||||
+ SRAM pins assignment +
|
||||
+-------------------+--------------------+------------------+------------------+
|
||||
| PD0 <-> FSMC_D2 | PE0 <-> FSMC_NBL0 | PF0 <-> FSMC_A0 | PG0 <-> FSMC_A10 |
|
||||
| PD1 <-> FSMC_D3 | PE1 <-> FSMC_NBL1 | PF1 <-> FSMC_A1 | PG1 <-> FSMC_A11 |
|
||||
| PD4 <-> FSMC_NOE | PE7 <-> FSMC_D4 | PF2 <-> FSMC_A2 | PG2 <-> FSMC_A12 |
|
||||
| PD5 <-> FSMC_NWE | PE8 <-> FSMC_D5 | PF3 <-> FSMC_A3 | PG3 <-> FSMC_A13 |
|
||||
| PD8 <-> FSMC_D13 | PE9 <-> FSMC_D6 | PF4 <-> FSMC_A4 | PG4 <-> FSMC_A14 |
|
||||
| PD9 <-> FSMC_D14 | PE10 <-> FSMC_D7 | PF5 <-> FSMC_A5 | PG5 <-> FSMC_A15 |
|
||||
| PD10 <-> FSMC_D15 | PE11 <-> FSMC_D8 | PF12 <-> FSMC_A6 | PG10<-> FSMC_NE2 |
|
||||
| PD11 <-> FSMC_A16 | PE12 <-> FSMC_D9 | PF13 <-> FSMC_A7 |------------------+
|
||||
| PD12 <-> FSMC_A17 | PE13 <-> FSMC_D10 | PF14 <-> FSMC_A8 |
|
||||
| PD13 <-> FSMC_A18 | PE14 <-> FSMC_D11 | PF15 <-> FSMC_A9 |
|
||||
| PD14 <-> FSMC_D0 | PE15 <-> FSMC_D12 |------------------+
|
||||
| PD15 <-> FSMC_D1 |--------------------+
|
||||
+-------------------+
|
||||
*/
|
||||
|
||||
/* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
|
||||
RCC->AHBENR = 0x000080D8;
|
||||
|
||||
/* Connect PDx pins to FSMC Alternate function */
|
||||
GPIOD->AFR[0] = 0x00CC00CC;
|
||||
GPIOD->AFR[1] = 0xCCCCCCCC;
|
||||
/* Configure PDx pins in Alternate function mode */
|
||||
GPIOD->MODER = 0xAAAA0A0A;
|
||||
/* Configure PDx pins speed to 40 MHz */
|
||||
GPIOD->OSPEEDR = 0xFFFF0F0F;
|
||||
/* Configure PDx pins Output type to push-pull */
|
||||
GPIOD->OTYPER = 0x00000000;
|
||||
/* No pull-up, pull-down for PDx pins */
|
||||
GPIOD->PUPDR = 0x00000000;
|
||||
|
||||
/* Connect PEx pins to FSMC Alternate function */
|
||||
GPIOE->AFR[0] = 0xC00000CC;
|
||||
GPIOE->AFR[1] = 0xCCCCCCCC;
|
||||
/* Configure PEx pins in Alternate function mode */
|
||||
GPIOE->MODER = 0xAAAA800A;
|
||||
/* Configure PEx pins speed to 40 MHz */
|
||||
GPIOE->OSPEEDR = 0xFFFFC00F;
|
||||
/* Configure PEx pins Output type to push-pull */
|
||||
GPIOE->OTYPER = 0x00000000;
|
||||
/* No pull-up, pull-down for PEx pins */
|
||||
GPIOE->PUPDR = 0x00000000;
|
||||
|
||||
/* Connect PFx pins to FSMC Alternate function */
|
||||
GPIOF->AFR[0] = 0x00CCCCCC;
|
||||
GPIOF->AFR[1] = 0xCCCC0000;
|
||||
/* Configure PFx pins in Alternate function mode */
|
||||
GPIOF->MODER = 0xAA000AAA;
|
||||
/* Configure PFx pins speed to 40 MHz */
|
||||
GPIOF->OSPEEDR = 0xFF000FFF;
|
||||
/* Configure PFx pins Output type to push-pull */
|
||||
GPIOF->OTYPER = 0x00000000;
|
||||
/* No pull-up, pull-down for PFx pins */
|
||||
GPIOF->PUPDR = 0x00000000;
|
||||
|
||||
/* Connect PGx pins to FSMC Alternate function */
|
||||
GPIOG->AFR[0] = 0x00CCCCCC;
|
||||
GPIOG->AFR[1] = 0x00000C00;
|
||||
/* Configure PGx pins in Alternate function mode */
|
||||
GPIOG->MODER = 0x00200AAA;
|
||||
/* Configure PGx pins speed to 40 MHz */
|
||||
GPIOG->OSPEEDR = 0x00300FFF;
|
||||
/* Configure PGx pins Output type to push-pull */
|
||||
GPIOG->OTYPER = 0x00000000;
|
||||
/* No pull-up, pull-down for PGx pins */
|
||||
GPIOG->PUPDR = 0x00000000;
|
||||
|
||||
/*-- FSMC Configuration ------------------------------------------------------*/
|
||||
/* Enable the FSMC interface clock */
|
||||
RCC->AHBENR = 0x400080D8;
|
||||
|
||||
/* Configure and enable Bank1_SRAM3 */
|
||||
FSMC_Bank1->BTCR[4] = 0x00001011;
|
||||
FSMC_Bank1->BTCR[5] = 0x00000300;
|
||||
FSMC_Bank1E->BWTR[4] = 0x0FFFFFFF;
|
||||
/*
|
||||
Bank1_SRAM3 is configured as follow:
|
||||
|
||||
p.FSMC_AddressSetupTime = 0;
|
||||
p.FSMC_AddressHoldTime = 0;
|
||||
p.FSMC_DataSetupTime = 3;
|
||||
p.FSMC_BusTurnAroundDuration = 0;
|
||||
p.FSMC_CLKDivision = 0;
|
||||
p.FSMC_DataLatency = 0;
|
||||
p.FSMC_AccessMode = FSMC_AccessMode_A;
|
||||
|
||||
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM3;
|
||||
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
|
||||
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
|
||||
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
|
||||
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
|
||||
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;
|
||||
|
||||
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
|
||||
|
||||
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM3, ENABLE);
|
||||
*/
|
||||
|
||||
}
|
||||
#endif /* DATA_IN_ExtSRAM */
|
||||
#endif /* STM32L151xD || STM32L152xD || STM32L162xD */
|
||||
|
||||
/**
|
||||
* @brief Configures the System clock source, PLL Multiplier and Divider factors,
|
||||
* AHB/APBx prescalers and Flash settings
|
||||
* @note This function should be called only once the RCC clock configuration
|
||||
* is reset to the default reset state (done in SystemInit() function).
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SetSysClock(void)
|
||||
{
|
||||
/* 1- Try to start with HSE and external clock */
|
||||
#if USE_PLL_HSE_EXTC != 0
|
||||
if (SetSysClock_PLL_HSE(1) == 0)
|
||||
#endif
|
||||
{
|
||||
/* 2- If fail try to start with HSE and external xtal */
|
||||
#if USE_PLL_HSE_XTAL != 0
|
||||
if (SetSysClock_PLL_HSE(0) == 0)
|
||||
#endif
|
||||
{
|
||||
/* 3- If fail start with HSI clock */
|
||||
if (SetSysClock_PLL_HSI() == 0)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
// [TODO] Put something here to tell the user that a problem occured...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Output clock on MCO1 pin(PA8) for debugging purpose */
|
||||
//HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_SYSCLK, RCC_MCODIV_1);
|
||||
}
|
||||
|
||||
#if (USE_PLL_HSE_XTAL != 0) || (USE_PLL_HSE_EXTC != 0)
|
||||
/******************************************************************************/
|
||||
/* PLL (clocked by HSE) used as System clock source */
|
||||
/******************************************************************************/
|
||||
uint8_t SetSysClock_PLL_HSE(uint8_t bypass)
|
||||
{
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
|
||||
if (__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_CFGR_SWS_PLL)
|
||||
return 1; // already on HSE PLL, could occur from deepsleep waking
|
||||
|
||||
/* Used to gain time after DeepSleep in case HSI is used */
|
||||
if (__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != RESET)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
||||
clocked below the maximum system frequency, to update the voltage scaling value
|
||||
regarding system frequency refer to product datasheet. */
|
||||
__PWR_CLK_ENABLE();
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
||||
|
||||
/* Enable HSE and HSI48 oscillators and activate PLL with HSE as source */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI;
|
||||
if (bypass == 0)
|
||||
{
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON; /* External 8 MHz xtal on OSC_IN/OSC_OUT */
|
||||
}
|
||||
else
|
||||
{
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; /* External 8 MHz clock on OSC_IN */
|
||||
}
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
|
||||
// SYSCLK = 24 MHz ((8 MHz * 6) / 2)
|
||||
// USBCLK = 48 MHz (8 MHz * 6) --> USB OK
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6;
|
||||
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV2;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
return 0; // FAIL
|
||||
}
|
||||
|
||||
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
|
||||
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 24 MHz
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 24 MHz
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; // 24 MHz
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 24 MHz
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
|
||||
{
|
||||
return 0; // FAIL
|
||||
}
|
||||
|
||||
/* Output clock on MCO1 pin(PA8) for debugging purpose */
|
||||
//if (bypass == 0)
|
||||
//HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_2); // 4 MHz
|
||||
//else
|
||||
//HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz
|
||||
|
||||
return 1; // OK
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
/* PLL (clocked by HSI) used as System clock source */
|
||||
/******************************************************************************/
|
||||
uint8_t SetSysClock_PLL_HSI(void)
|
||||
{
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
|
||||
/* The voltage scaling allows optimizing the power consumption when the device is
|
||||
clocked below the maximum system frequency, to update the voltage scaling value
|
||||
regarding system frequency refer to product datasheet. */
|
||||
__PWR_CLK_ENABLE();
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
||||
|
||||
/* Enable HSI oscillator and activate PLL with HSI as source */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
// SYSCLK = 32 MHz ((16 MHz * 4) / 2)
|
||||
// USBCLK = 64 MHz (16 MHz * 4) --> USB not possible
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
||||
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL4;
|
||||
RCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV2;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
return 0; // FAIL
|
||||
}
|
||||
|
||||
/* Poll VOSF bit of in PWR_CSR. Wait until it is reset to 0 */
|
||||
while (__HAL_PWR_GET_FLAG(PWR_FLAG_VOS) != RESET) {};
|
||||
|
||||
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
|
||||
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 32 MHz
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 32 MHz
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; // 32 MHz
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 32 MHz
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
|
||||
{
|
||||
return 0; // FAIL
|
||||
}
|
||||
|
||||
/* Output clock on MCO1 pin(PA8) for debugging purpose */
|
||||
//HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz
|
||||
|
||||
return 1; // OK
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file system_stm32l1xx.h
|
||||
* @author MCD Application Team
|
||||
* @version V2.0.0
|
||||
* @date 5-September-2014
|
||||
* @brief CMSIS Cortex-M3 Device System Source File for STM32L1xx devices.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup CMSIS
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup stm32l1xx_system
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Define to prevent recursive inclusion
|
||||
*/
|
||||
#ifndef __SYSTEM_STM32L1XX_H
|
||||
#define __SYSTEM_STM32L1XX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup STM32L1xx_System_Includes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup STM32L1xx_System_Exported_types
|
||||
* @{
|
||||
*/
|
||||
/* This variable is updated in three ways:
|
||||
1) by calling CMSIS function SystemCoreClockUpdate()
|
||||
2) by calling HAL API function HAL_RCC_GetSysClockFreq()
|
||||
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
|
||||
Note: If you use this function to configure the system clock; then there
|
||||
is no need to call the 2 first functions listed above, since SystemCoreClock
|
||||
variable is updated automatically.
|
||||
*/
|
||||
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L1xx_System_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L1xx_System_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup STM32L1xx_System_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern void SystemInit(void);
|
||||
extern void SystemCoreClockUpdate(void);
|
||||
extern void SetSysClock(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__SYSTEM_STM32L1XX_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
@ -122,7 +122,7 @@
|
|||
|
||||
|
||||
#if !defined (LSE_STARTUP_TIMEOUT)
|
||||
#define LSE_STARTUP_TIMEOUT ((uint32_t)500) /*!< Time out for LSE start up, in ms */
|
||||
#define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
|
||||
#endif /* HSE_STARTUP_TIMEOUT */
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ uint16_t crc16_compute(const uint8_t * p_data, uint32_t size, const uint16_t * p
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // CRC16_H__
|
||||
|
||||
/** @} */
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@
|
|||
#include <stdbool.h>
|
||||
#include "nrf_error.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**@brief Function for error handling, which is called when an error has occurred.
|
||||
*
|
||||
* @param[in] error_code Error code supplied to the handler.
|
||||
|
|
@ -34,6 +38,10 @@
|
|||
*/
|
||||
void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/**@brief Macro for calling error handler function.
|
||||
*
|
||||
* @param[in] ERR_CODE Error code supplied to the error handler.
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ enum
|
|||
|
||||
#if defined(__GNUC__)
|
||||
#define STATIC_ASSERT(EXPR) typedef char __attribute__((unused)) static_assert_failed[(EXPR) ? 1 : -1]
|
||||
#elif defined(__ICCARM__)
|
||||
#define STATIC_ASSERT(EXPR) extern char static_assert_failed[(EXPR) ? 1 : -1]
|
||||
#else
|
||||
#define STATIC_ASSERT(EXPR) typedef char static_assert_failed[(EXPR) ? 1 : -1]
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,419 +0,0 @@
|
|||
/* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@addtogroup BLE_COMMON BLE SoftDevice Common
|
||||
@{
|
||||
@defgroup ble_api Events, type definitions and API calls
|
||||
@{
|
||||
|
||||
@brief Module independent events, type definitions and API calls for the S110 SoftDevice.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef BLE_H__
|
||||
#define BLE_H__
|
||||
|
||||
#include "ble_ranges.h"
|
||||
#include "ble_types.h"
|
||||
#include "ble_gap.h"
|
||||
#include "ble_l2cap.h"
|
||||
#include "ble_gatt.h"
|
||||
#include "ble_gattc.h"
|
||||
#include "ble_gatts.h"
|
||||
|
||||
/** @addtogroup BLE_COMMON_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @brief Common API SVC numbers.
|
||||
*/
|
||||
enum BLE_COMMON_SVCS
|
||||
{
|
||||
SD_BLE_ENABLE = BLE_SVC_BASE, /**< Enable and initialize the BLE stack */
|
||||
SD_BLE_EVT_GET, /**< Get an event from the pending events queue. */
|
||||
SD_BLE_TX_BUFFER_COUNT_GET, /**< Get the total number of available application transmission buffers from the stack. */
|
||||
SD_BLE_UUID_VS_ADD, /**< Add a Vendor Specific UUID. */
|
||||
SD_BLE_UUID_DECODE, /**< Decode UUID bytes. */
|
||||
SD_BLE_UUID_ENCODE, /**< Encode UUID bytes. */
|
||||
SD_BLE_VERSION_GET, /**< Get the local version information (company id, Link Layer Version, Link Layer Subversion). */
|
||||
SD_BLE_USER_MEM_REPLY, /**< User Memory Reply. */
|
||||
SD_BLE_OPT_SET, /**< Set a BLE option. */
|
||||
SD_BLE_OPT_GET, /**< Get a BLE option. */
|
||||
};
|
||||
|
||||
/**@brief Common Option IDs.
|
||||
* IDs that uniquely identify a common option.
|
||||
*/
|
||||
enum BLE_COMMON_OPTS
|
||||
{
|
||||
BLE_COMMON_OPT_RADIO_CPU_MUTEX = BLE_OPT_BASE /**< Radio CPU mutex option. @ref ble_common_opt_radio_cpu_mutex_t */
|
||||
};
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_COMMON_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @brief Required pointer alignment for BLE Events.
|
||||
*/
|
||||
#define BLE_EVTS_PTR_ALIGNMENT 4
|
||||
|
||||
/** @defgroup BLE_USER_MEM_TYPES User Memory Types
|
||||
* @{ */
|
||||
#define BLE_USER_MEM_TYPE_INVALID 0x00 /**< Invalid User Memory Types. */
|
||||
#define BLE_USER_MEM_TYPE_GATTS_QUEUED_WRITES 0x01 /**< User Memory for GATTS queued writes. */
|
||||
/** @} */
|
||||
|
||||
/** @brief Maximum number of Vendor Specific UUIDs.
|
||||
*/
|
||||
#define BLE_UUID_VS_MAX_COUNT 10
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_COMMON_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @brief BLE Module Independent Event IDs.
|
||||
*/
|
||||
enum BLE_COMMON_EVTS
|
||||
{
|
||||
BLE_EVT_TX_COMPLETE = BLE_EVT_BASE, /**< Transmission Complete. */
|
||||
BLE_EVT_USER_MEM_REQUEST, /**< User Memory request. */
|
||||
BLE_EVT_USER_MEM_RELEASE /**< User Memory release. */
|
||||
};
|
||||
|
||||
/**@brief User Memory Block. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t* p_mem; /**< Pointer to the start of the user memory block. */
|
||||
uint16_t len; /**< Length in bytes of the user memory block. */
|
||||
} ble_user_mem_block_t;
|
||||
|
||||
/**
|
||||
* @brief TX complete event.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t count; /**< Number of packets transmitted. */
|
||||
} ble_evt_tx_complete_t;
|
||||
|
||||
/**@brief Event structure for BLE_EVT_USER_MEM_REQUEST. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
|
||||
} ble_evt_user_mem_request_t;
|
||||
|
||||
/**@brief Event structure for BLE_EVT_USER_MEM_RELEASE. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< User memory type, see @ref BLE_USER_MEM_TYPES. */
|
||||
ble_user_mem_block_t mem_block; /**< User memory block */
|
||||
} ble_evt_user_mem_release_t;
|
||||
|
||||
|
||||
/**@brief Event structure for events not associated with a specific function module. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which this event occured. */
|
||||
union
|
||||
{
|
||||
ble_evt_tx_complete_t tx_complete; /**< Transmission Complete. */
|
||||
ble_evt_user_mem_request_t user_mem_request; /**< User Memory Request Event Parameters. */
|
||||
ble_evt_user_mem_release_t user_mem_release; /**< User Memory Release Event Parameters. */
|
||||
} params;
|
||||
} ble_common_evt_t;
|
||||
|
||||
/**@brief BLE Event header. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t evt_id; /**< Value from a BLE_<module>_EVT series. */
|
||||
uint16_t evt_len; /**< Length in octets excluding this header. */
|
||||
} ble_evt_hdr_t;
|
||||
|
||||
/**@brief Common BLE Event type, wrapping the module specific event reports. */
|
||||
typedef struct
|
||||
{
|
||||
ble_evt_hdr_t header; /**< Event header. */
|
||||
union
|
||||
{
|
||||
ble_common_evt_t common_evt; /**< Common Event, evt_id in BLE_EVT_* series. */
|
||||
ble_gap_evt_t gap_evt; /**< GAP originated event, evt_id in BLE_GAP_EVT_* series. */
|
||||
ble_l2cap_evt_t l2cap_evt; /**< L2CAP originated event, evt_id in BLE_L2CAP_EVT* series. */
|
||||
ble_gattc_evt_t gattc_evt; /**< GATT client originated event, evt_id in BLE_GATTC_EVT* series. */
|
||||
ble_gatts_evt_t gatts_evt; /**< GATT server originated event, evt_id in BLE_GATTS_EVT* series. */
|
||||
} evt;
|
||||
} ble_evt_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Version Information.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t version_number; /**< Link Layer Version number for BT 4.1 spec is 7 (https://www.bluetooth.org/en-us/specification/assigned-numbers/link-layer). */
|
||||
uint16_t company_id; /**< Company ID, Nordic Semiconductor's company ID is 89 (0x0059) (https://www.bluetooth.org/apps/content/Default.aspx?doc_id=49708). */
|
||||
uint16_t subversion_number; /**< Link Layer Sub Version number, corresponds to the SoftDevice Config ID or Firmware ID (FWID). */
|
||||
} ble_version_t;
|
||||
|
||||
/**@brief Mutual exclusion of radio activity and CPU execution.
|
||||
*
|
||||
* This option configures the application's access to the CPU when the radio is active. The
|
||||
* application can configure itself to have access to the CPU while the radio is active.
|
||||
* By default, the application will be not able to share CPU time with the SoftDevice
|
||||
* during radio activity. This parameter structure is used together with @ref sd_ble_opt_set
|
||||
* to configure the @ref BLE_COMMON_OPT_RADIO_CPU_MUTEX option.
|
||||
*
|
||||
* @note Note that the mutual exclusion of radio activity and CPU execution should remain enabled
|
||||
* when running the SoftDevice on hardware affected by PAN #44 "CCM may exceed real time
|
||||
* requirements"and PAN #45 "AAR may exceed real time requirements".
|
||||
*
|
||||
* @note @ref sd_ble_opt_get is not supported for this option.
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t enable : 1; /**< Enable mutual exclusion of radio activity and the CPU execution. */
|
||||
} ble_common_opt_radio_cpu_mutex_t;
|
||||
|
||||
/**@brief Option structure for common options. */
|
||||
typedef union
|
||||
{
|
||||
ble_common_opt_radio_cpu_mutex_t radio_cpu_mutex; /**< Parameters for the option for the mutual exclusion of radio activity and CPU execution. */
|
||||
} ble_common_opt_t;
|
||||
|
||||
/**@brief Common BLE Option type, wrapping the module specific options. */
|
||||
typedef union
|
||||
{
|
||||
ble_common_opt_t common_opt; /**< Common option, opt_id in BLE_COMMON_OPT_* series. */
|
||||
ble_gap_opt_t gap; /**< GAP option, opt_id in BLE_GAP_OPT_* series. */
|
||||
} ble_opt_t;
|
||||
|
||||
/**
|
||||
* @brief BLE GATTS init options
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ble_gatts_enable_params_t gatts_enable_params; /**< GATTS init options @ref ble_gatts_enable_params_t. */
|
||||
} ble_enable_params_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_COMMON_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Enable the bluetooth stack
|
||||
*
|
||||
* @param[in] p_ble_enable_params Pointer to ble_enable_params_t
|
||||
*
|
||||
* @details This call initializes the bluetooth stack, no other BLE related call can be called before this one has been executed.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS BLE stack has been initialized successfully
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
|
||||
*/
|
||||
SVCALL(SD_BLE_ENABLE, uint32_t, sd_ble_enable(ble_enable_params_t * p_ble_enable_params));
|
||||
|
||||
/**@brief Get an event from the pending events queue.
|
||||
*
|
||||
* @param[in] p_dest Pointer to buffer to be filled in with an event, or NULL to retrieve the event length. This buffer <b>must be 4-byte aligned in memory</b>.
|
||||
* @param[in, out] p_len Pointer the length of the buffer, on return it is filled with the event length.
|
||||
*
|
||||
* @details This call allows the application to pull a BLE event from the BLE stack. The application is signalled that an event is
|
||||
* available from the BLE Stack by the triggering of the SD_EVT_IRQn interrupt (mapped to IRQ 22).
|
||||
* The application is free to choose whether to call this function from thread mode (main context) or directly from the Interrupt Service Routine
|
||||
* that maps to SD_EVT_IRQn. In any case however, and because the BLE stack runs at a higher priority than the application, this function should be called
|
||||
* in a loop (until @ref NRF_ERROR_NOT_FOUND is returned) every time SD_EVT_IRQn is raised to ensure that all available events are pulled from the stack.
|
||||
* Failure to do so could potentially leave events in the internal queue without the application being aware of this fact.
|
||||
* Sizing the p_dest buffer is equally important, since the application needs to provide all the memory necessary for the event to be copied into
|
||||
* application memory. If the buffer provided is not large enough to fit the entire contents of the event, @ref NRF_ERROR_DATA_SIZE will be returned
|
||||
* and the application can then call again with a larger buffer size.
|
||||
* Please note that because of the variable length nature of some events, sizeof(ble_evt_t) will not always be large enough to fit certain events,
|
||||
* and so it is the application's responsability to provide an amount of memory large enough so that the relevant event is copied in full.
|
||||
* The application may "peek" the event length by providing p_dest as a NULL pointer and inspecting the value of *p_len upon return.
|
||||
*
|
||||
* @note The pointer supplied must be aligned to the extend defined by @ref BLE_EVTS_PTR_ALIGNMENT
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Event pulled and stored into the supplied buffer.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid or not sufficiently aligned pointer supplied.
|
||||
* @return @ref NRF_ERROR_NOT_FOUND No events ready to be pulled.
|
||||
* @return @ref NRF_ERROR_DATA_SIZE Event ready but could not fit into the supplied buffer.
|
||||
*/
|
||||
SVCALL(SD_BLE_EVT_GET, uint32_t, sd_ble_evt_get(uint8_t* p_dest, uint16_t *p_len));
|
||||
|
||||
|
||||
/**@brief Get the total number of available application transmission buffers in the BLE stack.
|
||||
*
|
||||
* @details This call allows the application to obtain the total number of
|
||||
* transmission buffers available for application data. Please note that
|
||||
* this does not give the number of free buffers, but rather the total amount of them.
|
||||
* The application has two options to handle its own application transmission buffers:
|
||||
* - Use a simple arithmetic calculation: at boot time the application should use this function
|
||||
* to find out the total amount of buffers available to it and store it in a variable.
|
||||
* Every time a packet that consumes an application buffer is sent using any of the
|
||||
* exposed functions in this BLE API, the application should decrement that variable.
|
||||
* Conversely, whenever a @ref BLE_EVT_TX_COMPLETE event is received by the application
|
||||
* it should retrieve the count field in such event and add that number to the same
|
||||
* variable storing the number of available packets.
|
||||
* This mechanism allows the application to be aware at any time of the number of
|
||||
* application packets available in the BLE stack's internal buffers, and therefore
|
||||
* it can know with certainty whether it is possible to send more data or it has to
|
||||
* wait for a @ref BLE_EVT_TX_COMPLETE event before it proceeds.
|
||||
* - Choose to simply not keep track of available buffers at all, and instead handle the
|
||||
* @ref BLE_ERROR_NO_TX_BUFFERS error by queueing the packet to be transmitted and
|
||||
* try again as soon as a @ref BLE_EVT_TX_COMPLETE event arrives.
|
||||
*
|
||||
* The API functions that <b>may</b> consume an application buffer depending on
|
||||
* the parameters supplied to them can be found below:
|
||||
*
|
||||
* - @ref sd_ble_gattc_write (write witout response only)
|
||||
* - @ref sd_ble_gatts_hvx (notifications only)
|
||||
* - @ref sd_ble_l2cap_tx (all packets)
|
||||
*
|
||||
* @param[out] p_count Pointer to a uint8_t which will contain the number of application transmission buffers upon
|
||||
* successful return.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Number of application transmission buffers retrieved successfully.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
*/
|
||||
SVCALL(SD_BLE_TX_BUFFER_COUNT_GET, uint32_t, sd_ble_tx_buffer_count_get(uint8_t* p_count));
|
||||
|
||||
|
||||
/**@brief Add a Vendor Specific UUID.
|
||||
*
|
||||
* @details This call enables the application to add a vendor specific UUID to the BLE stack's table,
|
||||
* for later use all other modules and APIs. This then allows the application to use the shorter,
|
||||
* 24-bit @ref ble_uuid_t format when dealing with both 16-bit and 128-bit UUIDs without having to
|
||||
* check for lengths and having split code paths. The way that this is accomplished is by extending the
|
||||
* grouping mechanism that the Bluetooth SIG standard base UUID uses for all other 128-bit UUIDs. The
|
||||
* type field in the @ref ble_uuid_t structure is an index (relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN)
|
||||
* to the table populated by multiple calls to this function, and the uuid field in the same structure
|
||||
* contains the 2 bytes at indices 12 and 13. The number of possible 128-bit UUIDs available to the
|
||||
* application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536,
|
||||
* although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array.
|
||||
*
|
||||
* @note Bytes 12 and 13 of the provided UUID will not be used internally, since those are always replaced by
|
||||
* the 16-bit uuid field in @ref ble_uuid_t.
|
||||
*
|
||||
*
|
||||
* @param[in] p_vs_uuid Pointer to a 16-octet (128-bit) little endian Vendor Specific UUID disregarding
|
||||
* bytes 12 and 13.
|
||||
* @param[out] p_uuid_type Pointer where the type field in @ref ble_uuid_t corresponding to this UUID will be stored.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully added the Vendor Specific UUID.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR If p_vs_uuid or p_uuid_type is NULL or invalid.
|
||||
* @return @ref NRF_ERROR_NO_MEM If there are no more free slots for VS UUIDs.
|
||||
* @return @ref NRF_ERROR_FORBIDDEN If p_vs_uuid has already been added to the VS UUID table.
|
||||
*/
|
||||
SVCALL(SD_BLE_UUID_VS_ADD, uint32_t, sd_ble_uuid_vs_add(ble_uuid128_t const * const p_vs_uuid, uint8_t * const p_uuid_type));
|
||||
|
||||
|
||||
/** @brief Decode little endian raw UUID bytes (16-bit or 128-bit) into a 24 bit @ref ble_uuid_t structure.
|
||||
*
|
||||
* @details The raw UUID bytes excluding bytes 12 and 13 (i.e. bytes 0-11 and 14-15) of p_uuid_le are compared
|
||||
* to the corresponding ones in each entry of the table of vendor specific UUIDs pouplated with @ref sd_ble_uuid_vs_add
|
||||
* to look for a match. If there is such a match, bytes 12 and 13 are returned as p_uuid->uuid and the index
|
||||
* relative to @ref BLE_UUID_TYPE_VENDOR_BEGIN as p_uuid->type.
|
||||
*
|
||||
* @note If the UUID length supplied is 2, then the type set by this call will always be @ref BLE_UUID_TYPE_BLE.
|
||||
*
|
||||
* @param[in] uuid_le_len Length in bytes of the buffer pointed to by p_uuid_le (must be 2 or 16 bytes).
|
||||
* @param[in] p_uuid_le Pointer pointing to little endian raw UUID bytes.
|
||||
* @param[in,out] p_uuid Pointer to a @ref ble_uuid_t structure to be filled in.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully decoded into the @ref ble_uuid_t structure.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_INVALID_LENGTH Invalid UUID length.
|
||||
* @return @ref NRF_ERROR_NOT_FOUND For a 128-bit UUID, no match in the populated table of UUIDs.
|
||||
*/
|
||||
SVCALL(SD_BLE_UUID_DECODE, uint32_t, sd_ble_uuid_decode(uint8_t uuid_le_len, uint8_t const * const p_uuid_le, ble_uuid_t * const p_uuid));
|
||||
|
||||
|
||||
/** @brief Encode a @ref ble_uuid_t structure into little endian raw UUID bytes (16-bit or 128-bit).
|
||||
*
|
||||
* @note The pointer to the destination buffer p_uuid_le may be NULL, in which case only the validitiy and size of p_uuid is computed.
|
||||
*
|
||||
* @param[in] p_uuid Pointer to a @ref ble_uuid_t structure that will be encoded into bytes.
|
||||
* @param[out] p_uuid_le_len Pointer to a uint8_t that will be filled with the encoded length (2 or 16 bytes).
|
||||
* @param[out] p_uuid_le Pointer to a buffer where the little endian raw UUID bytes (2 or 16) will be stored.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully encoded into the buffer.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid UUID type.
|
||||
*/
|
||||
SVCALL(SD_BLE_UUID_ENCODE, uint32_t, sd_ble_uuid_encode(ble_uuid_t const * const p_uuid, uint8_t * const p_uuid_le_len, uint8_t * const p_uuid_le));
|
||||
|
||||
|
||||
/**@brief Get Version Information.
|
||||
*
|
||||
* @details This call allows the application to get the BLE stack version information.
|
||||
*
|
||||
* @param[in] p_version Pointer to ble_version_t structure to be filled in.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Version information stored successfully.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_BUSY The stack is busy (typically doing a locally-initiated disconnection procedure).
|
||||
*/
|
||||
SVCALL(SD_BLE_VERSION_GET, uint32_t, sd_ble_version_get(ble_version_t * p_version));
|
||||
|
||||
|
||||
/**@brief Provide a user memory block.
|
||||
*
|
||||
* @note This call can only be used as a response to a @ref BLE_EVT_USER_MEM_REQUEST event issued to the application.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_block Pointer to a user memory block structure.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully queued a response to the peer.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_STATE No execute write request pending.
|
||||
*/
|
||||
SVCALL(SD_BLE_USER_MEM_REPLY, uint32_t, sd_ble_user_mem_reply(uint16_t conn_handle, ble_user_mem_block_t *p_block));
|
||||
|
||||
|
||||
/**@brief Set a BLE option.
|
||||
*
|
||||
* @details This call allows the application to set the value of an option.
|
||||
*
|
||||
* @param[in] opt_id Option ID.
|
||||
* @param[in] p_opt Pointer to a ble_opt_t structure containing the option value.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Option set successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Unable to set the parameter at this time.
|
||||
* @retval ::NRF_ERROR_BUSY The stack is busy or the previous procedure has not completed.
|
||||
*/
|
||||
SVCALL(SD_BLE_OPT_SET, uint32_t, sd_ble_opt_set(uint32_t opt_id, ble_opt_t const *p_opt));
|
||||
|
||||
|
||||
/**@brief Get a BLE option.
|
||||
*
|
||||
* @details This call allows the application to retrieve the value of an option.
|
||||
*
|
||||
* @param[in] opt_id Option ID.
|
||||
* @param[out] p_opt Pointer to a ble_opt_t structure to be filled in.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS Option retrieved successfully.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
|
||||
* @retval ::NRF_ERROR_INVALID_STATE Unable to retrieve the parameter at this time.
|
||||
* @retval ::NRF_ERROR_BUSY The stack is busy or the previous procedure has not completed.
|
||||
* @retval ::NRF_ERROR_NOT_SUPPORTED This option is not supported.
|
||||
*
|
||||
*/
|
||||
SVCALL(SD_BLE_OPT_GET, uint32_t, sd_ble_opt_get(uint32_t opt_id, ble_opt_t *p_opt));
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* BLE_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@addtogroup BLE_COMMON
|
||||
@{
|
||||
@addtogroup nrf_error
|
||||
@{
|
||||
@ingroup BLE_COMMON
|
||||
@}
|
||||
|
||||
@defgroup ble_err General error codes
|
||||
@{
|
||||
|
||||
@brief General error code definitions for the BLE API.
|
||||
|
||||
@ingroup BLE_COMMON
|
||||
*/
|
||||
#ifndef NRF_BLE_ERR_H__
|
||||
#define NRF_BLE_ERR_H__
|
||||
|
||||
#include "nrf_error.h"
|
||||
|
||||
/* @defgroup BLE_ERRORS Error Codes
|
||||
* @{ */
|
||||
#define BLE_ERROR_NOT_ENABLED (NRF_ERROR_STK_BASE_NUM+0x001) /**< @ref sd_ble_enable has not been called. */
|
||||
#define BLE_ERROR_INVALID_CONN_HANDLE (NRF_ERROR_STK_BASE_NUM+0x002) /**< Invalid connection handle. */
|
||||
#define BLE_ERROR_INVALID_ATTR_HANDLE (NRF_ERROR_STK_BASE_NUM+0x003) /**< Invalid attribute handle. */
|
||||
#define BLE_ERROR_NO_TX_BUFFERS (NRF_ERROR_STK_BASE_NUM+0x004) /**< Buffer capacity exceeded. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_ERROR_SUBRANGES Module specific error code subranges
|
||||
* @brief Assignment of subranges for module specific error codes.
|
||||
* @note For specific error codes, see ble_<module>.h or ble_error_<module>.h.
|
||||
* @{ */
|
||||
#define NRF_L2CAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x100) /**< L2CAP specific errors. */
|
||||
#define NRF_GAP_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x200) /**< GAP specific errors. */
|
||||
#define NRF_GATTC_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x300) /**< GATT client specific errors. */
|
||||
#define NRF_GATTS_ERR_BASE (NRF_ERROR_STK_BASE_NUM+0x400) /**< GATT server specific errors. */
|
||||
/** @} */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,171 +0,0 @@
|
|||
/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@addtogroup BLE_GATT Generic Attribute Profile (GATT) Common
|
||||
@{
|
||||
@brief Common definitions and prototypes for the GATT interfaces.
|
||||
*/
|
||||
|
||||
#ifndef BLE_GATT_H__
|
||||
#define BLE_GATT_H__
|
||||
|
||||
#include "ble_types.h"
|
||||
#include "ble_ranges.h"
|
||||
|
||||
|
||||
/** @addtogroup BLE_GATT_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @brief Default MTU size. */
|
||||
#define GATT_MTU_SIZE_DEFAULT 23
|
||||
|
||||
/** @brief Only the default MTU size of 23 is currently supported. */
|
||||
#define GATT_RX_MTU 23
|
||||
|
||||
|
||||
/**@brief Invalid Attribute Handle. */
|
||||
#define BLE_GATT_HANDLE_INVALID 0x0000
|
||||
|
||||
/** @defgroup BLE_GATT_TIMEOUT_SOURCES GATT Timeout sources
|
||||
* @{ */
|
||||
#define BLE_GATT_TIMEOUT_SRC_PROTOCOL 0x00 /**< ATT Protocol timeout. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_WRITE_OPS GATT Write operations
|
||||
* @{ */
|
||||
#define BLE_GATT_OP_INVALID 0x00 /**< Invalid Operation. */
|
||||
#define BLE_GATT_OP_WRITE_REQ 0x01 /**< Write Request. */
|
||||
#define BLE_GATT_OP_WRITE_CMD 0x02 /**< Write Command. */
|
||||
#define BLE_GATT_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */
|
||||
#define BLE_GATT_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */
|
||||
#define BLE_GATT_OP_EXEC_WRITE_REQ 0x05 /**< Execute Write Request. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_EXEC_WRITE_FLAGS GATT Execute Write flags
|
||||
* @{ */
|
||||
#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL 0x00
|
||||
#define BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE 0x01
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_HVX_TYPES GATT Handle Value operations
|
||||
* @{ */
|
||||
#define BLE_GATT_HVX_INVALID 0x00 /**< Invalid Operation. */
|
||||
#define BLE_GATT_HVX_NOTIFICATION 0x01 /**< Handle Value Notification. */
|
||||
#define BLE_GATT_HVX_INDICATION 0x02 /**< Handle Value Indication. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_STATUS_CODES GATT Status Codes
|
||||
* @{ */
|
||||
#define BLE_GATT_STATUS_SUCCESS 0x0000 /**< Success. */
|
||||
#define BLE_GATT_STATUS_UNKNOWN 0x0001 /**< Unknown or not applicable status. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID 0x0100 /**< ATT Error: Invalid Error Code. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_HANDLE 0x0101 /**< ATT Error: Invalid Attribute Handle. */
|
||||
#define BLE_GATT_STATUS_ATTERR_READ_NOT_PERMITTED 0x0102 /**< ATT Error: Read not permitted. */
|
||||
#define BLE_GATT_STATUS_ATTERR_WRITE_NOT_PERMITTED 0x0103 /**< ATT Error: Write not permitted. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_PDU 0x0104 /**< ATT Error: Used in ATT as Invalid PDU. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION 0x0105 /**< ATT Error: Authenticated link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_REQUEST_NOT_SUPPORTED 0x0106 /**< ATT Error: Used in ATT as Request Not Supported. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_OFFSET 0x0107 /**< ATT Error: Offset specified was past the end of the attribute. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_AUTHORIZATION 0x0108 /**< ATT Error: Used in ATT as Insufficient Authorisation. */
|
||||
#define BLE_GATT_STATUS_ATTERR_PREPARE_QUEUE_FULL 0x0109 /**< ATT Error: Used in ATT as Prepare Queue Full. */
|
||||
#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_FOUND 0x010A /**< ATT Error: Used in ATT as Attribute not found. */
|
||||
#define BLE_GATT_STATUS_ATTERR_ATTRIBUTE_NOT_LONG 0x010B /**< ATT Error: Attribute cannot be read or written using read/write blob requests. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_ENC_KEY_SIZE 0x010C /**< ATT Error: Encryption key size used is insufficient. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH 0x010D /**< ATT Error: Invalid value size. */
|
||||
#define BLE_GATT_STATUS_ATTERR_UNLIKELY_ERROR 0x010E /**< ATT Error: Very unlikely error. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION 0x010F /**< ATT Error: Encrypted link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_UNSUPPORTED_GROUP_TYPE 0x0110 /**< ATT Error: Attribute type is not a supported grouping attribute. */
|
||||
#define BLE_GATT_STATUS_ATTERR_INSUF_RESOURCES 0x0111 /**< ATT Error: Encrypted link required. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_BEGIN 0x0112 /**< ATT Error: Reserved for Future Use range #1 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE1_END 0x017F /**< ATT Error: Reserved for Future Use range #1 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_APP_BEGIN 0x0180 /**< ATT Error: Application range begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_APP_END 0x019F /**< ATT Error: Application range end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_BEGIN 0x01A0 /**< ATT Error: Reserved for Future Use range #2 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE2_END 0x01DF /**< ATT Error: Reserved for Future Use range #2 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_BEGIN 0x01E0 /**< ATT Error: Reserved for Future Use range #3 begin. */
|
||||
#define BLE_GATT_STATUS_ATTERR_RFU_RANGE3_END 0x01FC /**< ATT Error: Reserved for Future Use range #3 end. */
|
||||
#define BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR 0x01FD /**< ATT Common Profile and Service Error: Client Characteristic Configuration Descriptor improperly configured. */
|
||||
#define BLE_GATT_STATUS_ATTERR_CPS_PROC_ALR_IN_PROG 0x01FE /**< ATT Common Profile and Service Error: Procedure Already in Progress. */
|
||||
#define BLE_GATT_STATUS_ATTERR_CPS_OUT_OF_RANGE 0x01FF /**< ATT Common Profile and Service Error: Out Of Range. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_GATT_CPF_FORMATS Characteristic Presentation Formats
|
||||
* @note Found at http://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
|
||||
* @{ */
|
||||
#define BLE_GATT_CPF_FORMAT_RFU 0x00 /**< Reserved For Future Use. */
|
||||
#define BLE_GATT_CPF_FORMAT_BOOLEAN 0x01 /**< Boolean. */
|
||||
#define BLE_GATT_CPF_FORMAT_2BIT 0x02 /**< Unsigned 2-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_NIBBLE 0x03 /**< Unsigned 4-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT8 0x04 /**< Unsigned 8-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT12 0x05 /**< Unsigned 12-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT16 0x06 /**< Unsigned 16-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT24 0x07 /**< Unsigned 24-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT32 0x08 /**< Unsigned 32-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT48 0x09 /**< Unsigned 48-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT64 0x0A /**< Unsigned 64-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_UINT128 0x0B /**< Unsigned 128-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT8 0x0C /**< Signed 2-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT12 0x0D /**< Signed 12-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT16 0x0E /**< Signed 16-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT24 0x0F /**< Signed 24-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT32 0x10 /**< Signed 32-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT48 0x11 /**< Signed 48-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT64 0x12 /**< Signed 64-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_SINT128 0x13 /**< Signed 128-bit integer. */
|
||||
#define BLE_GATT_CPF_FORMAT_FLOAT32 0x14 /**< IEEE-754 32-bit floating point. */
|
||||
#define BLE_GATT_CPF_FORMAT_FLOAT64 0x15 /**< IEEE-754 64-bit floating point. */
|
||||
#define BLE_GATT_CPF_FORMAT_SFLOAT 0x16 /**< IEEE-11073 16-bit SFLOAT. */
|
||||
#define BLE_GATT_CPF_FORMAT_FLOAT 0x17 /**< IEEE-11073 32-bit FLOAT. */
|
||||
#define BLE_GATT_CPF_FORMAT_DUINT16 0x18 /**< IEEE-20601 format. */
|
||||
#define BLE_GATT_CPF_FORMAT_UTF8S 0x19 /**< UTF-8 string. */
|
||||
#define BLE_GATT_CPF_FORMAT_UTF16S 0x1A /**< UTF-16 string. */
|
||||
#define BLE_GATT_CPF_FORMAT_STRUCT 0x1B /**< Opaque Structure. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATT_CPF_NAMESPACES GATT Bluetooth Namespaces
|
||||
* @{
|
||||
*/
|
||||
#define BLE_GATT_CPF_NAMESPACE_BTSIG 0x01
|
||||
#define BLE_GATT_CPF_NAMESPACE_DESCRIPTION_UNKNOWN 0x0000
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATT_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief GATT Characteristic Properties. */
|
||||
typedef struct
|
||||
{
|
||||
/* Standard properties */
|
||||
uint8_t broadcast :1; /**< Broadcasting of value permitted. */
|
||||
uint8_t read :1; /**< Reading value permitted. */
|
||||
uint8_t write_wo_resp :1; /**< Writing value with Write Command permitted. */
|
||||
uint8_t write :1; /**< Writing value with Write Request permitted. */
|
||||
uint8_t notify :1; /**< Notications of value permitted. */
|
||||
uint8_t indicate :1; /**< Indications of value permitted. */
|
||||
uint8_t auth_signed_wr :1; /**< Writing value with Signed Write Command permitted. */
|
||||
} ble_gatt_char_props_t;
|
||||
|
||||
/**@brief GATT Characteristic Extended Properties. */
|
||||
typedef struct
|
||||
{
|
||||
/* Extended properties */
|
||||
uint8_t reliable_wr :1; /**< Writing value with Queued Write Request permitted. */
|
||||
uint8_t wr_aux :1; /**< Writing the Characteristic User Description permitted. */
|
||||
} ble_gatt_char_ext_props_t;
|
||||
|
||||
#endif // BLE_GATT_H__
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,406 +0,0 @@
|
|||
/* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@addtogroup BLE_GATTC Generic Attribute Profile (GATT) Client
|
||||
@{
|
||||
@brief Definitions and prototypes for the GATT Client interface.
|
||||
*/
|
||||
|
||||
#ifndef BLE_GATTC_H__
|
||||
#define BLE_GATTC_H__
|
||||
|
||||
#include "ble_gatt.h"
|
||||
#include "ble_types.h"
|
||||
#include "ble_ranges.h"
|
||||
#include "nrf_svc.h"
|
||||
|
||||
/** @addtogroup BLE_GATTC_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief GATTC API SVC numbers. */
|
||||
enum BLE_GATTC_SVCS
|
||||
{
|
||||
SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER = BLE_GATTC_SVC_BASE, /**< Primary Service Discovery. */
|
||||
SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, /**< Relationship Discovery. */
|
||||
SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, /**< Characteristic Discovery. */
|
||||
SD_BLE_GATTC_DESCRIPTORS_DISCOVER, /**< Characteristic Descriptor Discovery. */
|
||||
SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, /**< Read Characteristic Value by UUID. */
|
||||
SD_BLE_GATTC_READ, /**< Generic read. */
|
||||
SD_BLE_GATTC_CHAR_VALUES_READ, /**< Read multiple Characteristic Values. */
|
||||
SD_BLE_GATTC_WRITE, /**< Generic write. */
|
||||
SD_BLE_GATTC_HV_CONFIRM /**< Handle Value Confirmation. */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTC_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @defgroup BLE_ERRORS_GATTC SVC return values specific to GATTC
|
||||
* @{ */
|
||||
#define BLE_ERROR_GATTC_PROC_NOT_PERMITTED (NRF_GATTC_ERR_BASE + 0x000)
|
||||
/** @} */
|
||||
|
||||
/**@brief Last Attribute Handle. */
|
||||
#define BLE_GATTC_HANDLE_END 0xFFFF
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTC_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief Operation Handle Range. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t start_handle; /**< Start Handle. */
|
||||
uint16_t end_handle; /**< End Handle. */
|
||||
} ble_gattc_handle_range_t;
|
||||
|
||||
|
||||
/**@brief GATT service. */
|
||||
typedef struct
|
||||
{
|
||||
ble_uuid_t uuid; /**< Service UUID. */
|
||||
ble_gattc_handle_range_t handle_range; /**< Service Handle Range. */
|
||||
} ble_gattc_service_t;
|
||||
|
||||
|
||||
/**@brief GATT include. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Include Handle. */
|
||||
ble_gattc_service_t included_srvc; /**< Handle of the included service. */
|
||||
} ble_gattc_include_t;
|
||||
|
||||
|
||||
/**@brief GATT characteristic. */
|
||||
typedef struct
|
||||
{
|
||||
ble_uuid_t uuid; /**< Characteristic UUID. */
|
||||
ble_gatt_char_props_t char_props; /**< Characteristic Properties. */
|
||||
uint8_t char_ext_props : 1; /**< Extended properties present. */
|
||||
uint16_t handle_decl; /**< Handle of the Characteristic Declaration. */
|
||||
uint16_t handle_value; /**< Handle of the Characteristic Value. */
|
||||
} ble_gattc_char_t;
|
||||
|
||||
|
||||
/**@brief GATT descriptor. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Descriptor Handle. */
|
||||
ble_uuid_t uuid; /**< Descriptor UUID. */
|
||||
} ble_gattc_desc_t;
|
||||
|
||||
|
||||
/**@brief Write Parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t write_op; /**< Write Operation to be performed, see @ref BLE_GATT_WRITE_OPS. */
|
||||
uint16_t handle; /**< Handle to the attribute to be written. */
|
||||
uint16_t offset; /**< Offset in bytes. @note For WRITE_CMD and WRITE_REQ, offset must be 0. */
|
||||
uint16_t len; /**< Length of data in bytes. */
|
||||
uint8_t* p_value; /**< Pointer to the value data. */
|
||||
uint8_t flags; /**< Flags, see @ref BLE_GATT_EXEC_WRITE_FLAGS. */
|
||||
} ble_gattc_write_params_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief GATT Client Event IDs.
|
||||
*/
|
||||
enum BLE_GATTC_EVTS
|
||||
{
|
||||
BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP = BLE_GATTC_EVT_BASE, /**< Primary Service Discovery Response event. */
|
||||
BLE_GATTC_EVT_REL_DISC_RSP, /**< Relationship Discovery Response event. */
|
||||
BLE_GATTC_EVT_CHAR_DISC_RSP, /**< Characteristic Discovery Response event. */
|
||||
BLE_GATTC_EVT_DESC_DISC_RSP, /**< Descriptor Discovery Response event. */
|
||||
BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP, /**< Read By UUID Response event. */
|
||||
BLE_GATTC_EVT_READ_RSP, /**< Read Response event. */
|
||||
BLE_GATTC_EVT_CHAR_VALS_READ_RSP, /**< Read multiple Response event. */
|
||||
BLE_GATTC_EVT_WRITE_RSP, /**< Write Response event. */
|
||||
BLE_GATTC_EVT_HVX, /**< Handle Value Notification or Indication event. */
|
||||
BLE_GATTC_EVT_TIMEOUT /**< Timeout event. */
|
||||
};
|
||||
|
||||
/**@brief Event structure for BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Service count. */
|
||||
ble_gattc_service_t services[1]; /**< Service data, variable length. */
|
||||
} ble_gattc_evt_prim_srvc_disc_rsp_t;
|
||||
|
||||
/**@brief Event structure for BLE_GATTC_EVT_REL_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Include count. */
|
||||
ble_gattc_include_t includes[1]; /**< Include data, variable length. */
|
||||
} ble_gattc_evt_rel_disc_rsp_t;
|
||||
|
||||
/**@brief Event structure for BLE_GATTC_EVT_CHAR_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Characteristic count. */
|
||||
ble_gattc_char_t chars[1]; /**< Characteristic data, variable length. */
|
||||
} ble_gattc_evt_char_disc_rsp_t;
|
||||
|
||||
/**@brief Event structure for BLE_GATTC_EVT_DESC_DISC_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Descriptor count. */
|
||||
ble_gattc_desc_t descs[1]; /**< Descriptor data, variable length. */
|
||||
} ble_gattc_evt_desc_disc_rsp_t;
|
||||
|
||||
/**@brief GATT read by UUID handle value pair. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
uint8_t *p_value; /**< Pointer to value, variable length (length available as value_len in ble_gattc_evt_read_by_uuid_rsp_t).
|
||||
Please note that this pointer is absolute to the memory provided by the user when retrieving the event,
|
||||
so it will effectively point to a location inside the handle_value array. */
|
||||
} ble_gattc_handle_value_t;
|
||||
|
||||
/**@brief Event structure for BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t count; /**< Handle-Value Pair Count. */
|
||||
uint16_t value_len; /**< Length of the value in Handle-Value(s) list. */
|
||||
ble_gattc_handle_value_t handle_value[1]; /**< Handle-Value(s) list, variable length. */
|
||||
} ble_gattc_evt_char_val_by_uuid_read_rsp_t;
|
||||
|
||||
/**@brief Event structure for BLE_GATTC_EVT_READ_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
uint16_t offset; /**< Offset of the attribute data. */
|
||||
uint16_t len; /**< Attribute data length. */
|
||||
uint8_t data[1]; /**< Attribute data, variable length. */
|
||||
} ble_gattc_evt_read_rsp_t;
|
||||
|
||||
/**@brief Event structure for BLE_GATTC_EVT_CHAR_VALS_READ_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t len; /**< Concatenated Attribute values length. */
|
||||
uint8_t values[1]; /**< Attribute values, variable length. */
|
||||
} ble_gattc_evt_char_vals_read_rsp_t;
|
||||
|
||||
/**@brief Event structure for BLE_GATTC_EVT_WRITE_RSP. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
uint8_t write_op; /**< Type of write operation, see @ref BLE_GATT_WRITE_OPS. */
|
||||
uint16_t offset; /**< Data Offset. */
|
||||
uint16_t len; /**< Data length. */
|
||||
uint8_t data[1]; /**< Data, variable length. */
|
||||
} ble_gattc_evt_write_rsp_t;
|
||||
|
||||
/**@brief Event structure for BLE_GATTC_EVT_HVX. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Handle to which the HVx operation applies. */
|
||||
uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */
|
||||
uint16_t len; /**< Attribute data length. */
|
||||
uint8_t data[1]; /**< Attribute data, variable length. */
|
||||
} ble_gattc_evt_hvx_t;
|
||||
|
||||
/**@brief Event structure for BLE_GATTC_EVT_TIMEOUT. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */
|
||||
} ble_gattc_evt_timeout_t;
|
||||
|
||||
/**@brief GATTC event type. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which event occured. */
|
||||
uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
|
||||
uint16_t error_handle; /**< In case of error: The handle causing the error. In all other cases BLE_GATT_HANDLE_INVALID. */
|
||||
union
|
||||
{
|
||||
ble_gattc_evt_prim_srvc_disc_rsp_t prim_srvc_disc_rsp; /**< Primary Service Discovery Response Event Parameters. */
|
||||
ble_gattc_evt_rel_disc_rsp_t rel_disc_rsp; /**< Relationship Discovery Response Event Parameters. */
|
||||
ble_gattc_evt_char_disc_rsp_t char_disc_rsp; /**< Characteristic Discovery Response Event Parameters. */
|
||||
ble_gattc_evt_desc_disc_rsp_t desc_disc_rsp; /**< Descriptor Discovery Response Event Parameters. */
|
||||
ble_gattc_evt_char_val_by_uuid_read_rsp_t char_val_by_uuid_read_rsp; /**< Characteristic Value Read by UUID Response Event Parameters. */
|
||||
ble_gattc_evt_read_rsp_t read_rsp; /**< Read Response Event Parameters. */
|
||||
ble_gattc_evt_char_vals_read_rsp_t char_vals_read_rsp; /**< Characteristic Values Read Response Event Parameters. */
|
||||
ble_gattc_evt_write_rsp_t write_rsp; /**< Write Response Event Parameters. */
|
||||
ble_gattc_evt_hvx_t hvx; /**< Handle Value Notification/Indication Event Parameters. */
|
||||
ble_gattc_evt_timeout_t timeout; /**< Timeout Event Parameters. */
|
||||
} params; /**< Event Parameters. @note Only valid if @ref gatt_status == BLE_GATT_STATUS_SUCCESS. */
|
||||
} ble_gattc_evt_t;
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTC_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Initiate or continue a GATT Primary Service Discovery procedure.
|
||||
*
|
||||
* @details This function initiates a Primary Service discovery, starting from the supplied handle.
|
||||
* If the last service has not been reached, this must be called again with an updated start handle value to continue the search.
|
||||
*
|
||||
* @note If any of the discovered services have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with
|
||||
* type BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] start_handle Handle to start searching from.
|
||||
* @param[in] p_srvc_uuid Pointer to the service UUID to be found. If it is NULL, all primary services will be returned.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully started or resumed the Primary Service Discovery procedure.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @return @ref NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_PRIMARY_SERVICES_DISCOVER, uint32_t, sd_ble_gattc_primary_services_discover(uint16_t conn_handle, uint16_t start_handle, ble_uuid_t const * const p_srvc_uuid));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Relationship Discovery procedure.
|
||||
*
|
||||
* @details This function initiates the Find Included Services sub-procedure. If the last included service has not been reached,
|
||||
* this must be called again with an updated handle range to continue the search.
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully started or resumed the Relationship Discovery procedure.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @return @ref NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_RELATIONSHIPS_DISCOVER, uint32_t, sd_ble_gattc_relationships_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * const p_handle_range));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Characteristic Discovery procedure.
|
||||
*
|
||||
* @details This function initiates a Characteristic discovery procedure. If the last Characteristic has not been reached,
|
||||
* this must be called again with an updated handle range to continue the discovery.
|
||||
*
|
||||
* @note If any of the discovered characteristics have 128-bit UUIDs which are not present in the table provided to ble_vs_uuids_assign, a UUID structure with
|
||||
* type BLE_UUID_TYPE_UNKNOWN will be received in the corresponding event.
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handle_range A pointer to the range of handles of the Service to perform this procedure on.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully started or resumed the Characteristic Discovery procedure.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_CHARACTERISTICS_DISCOVER, uint32_t, sd_ble_gattc_characteristics_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * const p_handle_range));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Characteristic Descriptor Discovery procedure.
|
||||
*
|
||||
* @details This function initiates the Characteristic Descriptor discovery procedure. If the last Descriptor has not been reached,
|
||||
* this must be called again with an updated handle range to continue the discovery.
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handle_range A pointer to the range of handles of the Characteristic to perform this procedure on.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully started or resumed the Descriptor Discovery procedure.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_DESCRIPTORS_DISCOVER, uint32_t, sd_ble_gattc_descriptors_discover(uint16_t conn_handle, ble_gattc_handle_range_t const * const p_handle_range));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Read using Characteristic UUID procedure.
|
||||
*
|
||||
* @details This function initiates the Read using Characteristic UUID procedure. If the last Characteristic has not been reached,
|
||||
* this must be called again with an updated handle range to continue the discovery.
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_uuid Pointer to a Characteristic value UUID to read.
|
||||
* @param[in] p_handle_range A pointer to the range of handles to perform this procedure on.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully started or resumed the Read using Characteristic UUID procedure.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_CHAR_VALUE_BY_UUID_READ, uint32_t, sd_ble_gattc_char_value_by_uuid_read(uint16_t conn_handle, ble_uuid_t const * const p_uuid, ble_gattc_handle_range_t const * const p_handle_range));
|
||||
|
||||
|
||||
/**@brief Initiate or continue a GATT Read (Long) Characteristic or Descriptor procedure.
|
||||
*
|
||||
* @details This function initiates a GATT Read (Long) Characteristic or Descriptor procedure. If the Characteristic or Descriptor
|
||||
* to be read is longer than GATT_MTU - 1, this function must be called multiple times with appropriate offset to read the
|
||||
* complete value.
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] handle The handle of the attribute to be read.
|
||||
* @param[in] offset Offset into the attribute value to be read.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully started or resumed the Read (Long) procedure.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_READ, uint32_t, sd_ble_gattc_read(uint16_t conn_handle, uint16_t handle, uint16_t offset));
|
||||
|
||||
|
||||
/**@brief Initiate a GATT Read Multiple Characteristic Values procedure.
|
||||
*
|
||||
* @details This function initiates a GATT Read Multiple Characteristic Values procedure.
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_handles A pointer to the handle(s) of the attribute(s) to be read.
|
||||
* @param[in] handle_count The number of handles in p_handles.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully started the Read Multiple Characteristic Values procedure.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_BUSY Client procedure already in progress.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_CHAR_VALUES_READ, uint32_t, sd_ble_gattc_char_values_read(uint16_t conn_handle, uint16_t const * const p_handles, uint16_t handle_count));
|
||||
|
||||
|
||||
/**@brief Perform a Write (Characteristic Value or Descriptor, with or without response, signed or not, long or reliable) procedure.
|
||||
*
|
||||
* @details This function can perform all write procedures described in GATT.
|
||||
*
|
||||
* @note It is important to note that a write without response will <b>consume an application buffer</b>, and will therefore
|
||||
* generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. A write on the other hand will use the
|
||||
* standard client internal buffer and thus will only generate a @ref BLE_GATTC_EVT_WRITE_RSP event as soon as the write response
|
||||
* has been received from the peer. Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details.
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] p_write_params A pointer to a write parameters structure.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully started the Write procedure.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
|
||||
* @return @ref NRF_ERROR_BUSY Procedure already in progress.
|
||||
* @return @ref BLE_ERROR_NO_TX_BUFFERS There are no available buffers left.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_WRITE, uint32_t, sd_ble_gattc_write(uint16_t conn_handle, ble_gattc_write_params_t const * const p_write_params));
|
||||
|
||||
|
||||
/**@brief Send a Handle Value Confirmation to the GATT Server.
|
||||
*
|
||||
* @param[in] conn_handle The connection handle identifying the connection to perform this procedure on.
|
||||
* @param[in] handle The handle of the attribute in the indication.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully queued the Handle Value Confirmation for transmission.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_STATE No Indication pending to be confirmed.
|
||||
* @return @ref BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle.
|
||||
* @return @ref BLE_ERROR_NO_TX_BUFFERS There are no available buffers left.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTC_HV_CONFIRM, uint32_t, sd_ble_gattc_hv_confirm(uint16_t conn_handle, uint16_t handle));
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* BLE_GATTC_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,566 +0,0 @@
|
|||
/* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@addtogroup BLE_GATTS Generic Attribute Profile (GATT) Server
|
||||
@{
|
||||
@brief Definitions and prototypes for the GATTS interface.
|
||||
*/
|
||||
|
||||
#ifndef BLE_GATTS_H__
|
||||
#define BLE_GATTS_H__
|
||||
|
||||
#include "ble_types.h"
|
||||
#include "ble_ranges.h"
|
||||
#include "ble_l2cap.h"
|
||||
#include "ble_gap.h"
|
||||
#include "ble_gatt.h"
|
||||
#include "nrf_svc.h"
|
||||
|
||||
/** @addtogroup BLE_GATTS_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @brief GATTS API SVC numbers.
|
||||
*/
|
||||
enum BLE_GATTS_SVCS
|
||||
{
|
||||
SD_BLE_GATTS_SERVICE_ADD = BLE_GATTS_SVC_BASE, /**< Add a service. */
|
||||
SD_BLE_GATTS_INCLUDE_ADD, /**< Add an included service. */
|
||||
SD_BLE_GATTS_CHARACTERISTIC_ADD, /**< Add a characteristic. */
|
||||
SD_BLE_GATTS_DESCRIPTOR_ADD, /**< Add a generic attribute. */
|
||||
SD_BLE_GATTS_VALUE_SET, /**< Set an attribute value. */
|
||||
SD_BLE_GATTS_VALUE_GET, /**< Get an attribute value. */
|
||||
SD_BLE_GATTS_HVX, /**< Handle Value Notification or Indication. */
|
||||
SD_BLE_GATTS_SERVICE_CHANGED, /**< Perform a Service Changed Indication to one or more peers. */
|
||||
SD_BLE_GATTS_RW_AUTHORIZE_REPLY, /**< Reply to an authorization request for a read or write operation on one or more attributes. */
|
||||
SD_BLE_GATTS_SYS_ATTR_SET, /**< Set the persistent system attributes for a connection. */
|
||||
SD_BLE_GATTS_SYS_ATTR_GET, /**< Get updated persistent system attributes after terminating a connection. */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTS_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @brief Only the default MTU size of 23 is currently supported. */
|
||||
#define GATT_RX_MTU 23
|
||||
|
||||
/** @defgroup BLE_ERRORS_GATTS SVC return values specific to GATTS
|
||||
* @{ */
|
||||
#define BLE_ERROR_GATTS_INVALID_ATTR_TYPE (NRF_GATTS_ERR_BASE + 0x000) /**< Invalid attribute type. */
|
||||
#define BLE_ERROR_GATTS_SYS_ATTR_MISSING (NRF_GATTS_ERR_BASE + 0x001) /**< System Attributes missing. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_ATTR_LENS_MAX Maximum attribute lengths
|
||||
* @{ */
|
||||
#define BLE_GATTS_FIX_ATTR_LEN_MAX (510) /**< Maximum length for fixed length Attribute Values. */
|
||||
#define BLE_GATTS_VAR_ATTR_LEN_MAX (512) /**< Maximum length for variable length Attribute Values. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_SRVC_TYPES GATT Server Service Types
|
||||
* @{ */
|
||||
#define BLE_GATTS_SRVC_TYPE_INVALID 0x00 /**< Invalid Service Type. */
|
||||
#define BLE_GATTS_SRVC_TYPE_PRIMARY 0x01 /**< Primary Service. */
|
||||
#define BLE_GATTS_SRVC_TYPE_SECONDARY 0x02 /**< Secondary Type. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_GATTS_ATTR_TYPES GATT Server Attribute Types
|
||||
* @{ */
|
||||
#define BLE_GATTS_ATTR_TYPE_INVALID 0x00 /**< Invalid Attribute Type. */
|
||||
#define BLE_GATTS_ATTR_TYPE_PRIM_SRVC_DECL 0x01 /**< Primary Service Declaration. */
|
||||
#define BLE_GATTS_ATTR_TYPE_SEC_SRVC_DECL 0x02 /**< Secondary Service Declaration. */
|
||||
#define BLE_GATTS_ATTR_TYPE_INC_DECL 0x03 /**< Include Declaration. */
|
||||
#define BLE_GATTS_ATTR_TYPE_CHAR_DECL 0x04 /**< Characteristic Declaration. */
|
||||
#define BLE_GATTS_ATTR_TYPE_CHAR_VAL 0x05 /**< Characteristic Value. */
|
||||
#define BLE_GATTS_ATTR_TYPE_DESC 0x06 /**< Descriptor. */
|
||||
#define BLE_GATTS_ATTR_TYPE_OTHER 0x07 /**< Other, non-GATT specific type. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_GATTS_OPS GATT Server Operations
|
||||
* @{ */
|
||||
#define BLE_GATTS_OP_INVALID 0x00 /**< Invalid Operation. */
|
||||
#define BLE_GATTS_OP_WRITE_REQ 0x01 /**< Write Request. */
|
||||
#define BLE_GATTS_OP_WRITE_CMD 0x02 /**< Write Command. */
|
||||
#define BLE_GATTS_OP_SIGN_WRITE_CMD 0x03 /**< Signed Write Command. */
|
||||
#define BLE_GATTS_OP_PREP_WRITE_REQ 0x04 /**< Prepare Write Request. */
|
||||
#define BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL 0x05 /**< Execute Write Request: Cancel all prepared writes. */
|
||||
#define BLE_GATTS_OP_EXEC_WRITE_REQ_NOW 0x06 /**< Execute Write Request: Immediately execute all prepared writes. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_VLOCS GATT Value Locations
|
||||
* @{ */
|
||||
#define BLE_GATTS_VLOC_INVALID 0x00 /**< Invalid Location. */
|
||||
#define BLE_GATTS_VLOC_STACK 0x01 /**< Attribute Value is located in stack memory, no user memory is required. */
|
||||
#define BLE_GATTS_VLOC_USER 0x02 /**< Attribute Value is located in user memory. This requires the user to maintain a valid buffer through the lifetime of the attribute, since the stack
|
||||
will read and write directly to the memory using the pointer provided in the APIs. There are no alignment requirements for the buffer. */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup BLE_GATTS_AUTHORIZE_TYPES GATT Server Authorization Types
|
||||
* @{ */
|
||||
#define BLE_GATTS_AUTHORIZE_TYPE_INVALID 0x00 /**< Invalid Type. */
|
||||
#define BLE_GATTS_AUTHORIZE_TYPE_READ 0x01 /**< Authorize a Read Operation. */
|
||||
#define BLE_GATTS_AUTHORIZE_TYPE_WRITE 0x02 /**< Authorize a Write Request Operation. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTS_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @brief BLE GATTS init options
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t service_changed:1; /**< Include the Service Changed characteristic in the local attributes. */
|
||||
} ble_gatts_enable_params_t;
|
||||
|
||||
/**@brief Attribute metadata. */
|
||||
typedef struct
|
||||
{
|
||||
ble_gap_conn_sec_mode_t read_perm; /**< Read permissions. */
|
||||
ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */
|
||||
uint8_t vlen :1; /**< Variable length attribute. */
|
||||
uint8_t vloc :2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/
|
||||
uint8_t rd_auth :1; /**< Read Authorization and value will be requested from the application on every read operation. */
|
||||
uint8_t wr_auth :1; /**< Write Authorization will be requested from the application on every Write Request operation (but not Write Command). */
|
||||
} ble_gatts_attr_md_t;
|
||||
|
||||
|
||||
/**@brief GATT Attribute. */
|
||||
typedef struct
|
||||
{
|
||||
ble_uuid_t* p_uuid; /**< Pointer to the attribute UUID. */
|
||||
ble_gatts_attr_md_t* p_attr_md; /**< Pointer to the attribute metadata structure. */
|
||||
uint16_t init_len; /**< Initial attribute value length in bytes. */
|
||||
uint16_t init_offs; /**< Initial attribute value offset in bytes. If different from zero, the first init_offs bytes of the attribute value will be left uninitialized. */
|
||||
uint16_t max_len; /**< Maximum attribute value length in bytes, see @ref BLE_GATTS_ATTR_LENS_MAX for maximum values. */
|
||||
uint8_t* p_value; /**< Pointer to the attribute data. Please note that if the @ref BLE_GATTS_VLOC_USER value location is selected in the attribute metadata, this will have to point to a buffer
|
||||
that remains valid through the lifetime of the attribute. This excludes usage of automatic variables that may go out of scope or any other temporary location.
|
||||
The stack may access that memory directly without the application's knowledge. */
|
||||
} ble_gatts_attr_t;
|
||||
|
||||
|
||||
/**@brief GATT Attribute Context. */
|
||||
typedef struct
|
||||
{
|
||||
ble_uuid_t srvc_uuid; /**< Service UUID. */
|
||||
ble_uuid_t char_uuid; /**< Characteristic UUID if applicable (BLE_UUID_TYPE_UNKNOWN if N/A). */
|
||||
ble_uuid_t desc_uuid; /**< Descriptor UUID if applicable (BLE_UUID_TYPE_UNKNOWN if N/A). */
|
||||
uint16_t srvc_handle; /**< Service Handle. */
|
||||
uint16_t value_handle; /**< Characteristic Handle if applicable (BLE_GATT_HANDLE_INVALID if N/A). */
|
||||
uint8_t type; /**< Attribute Type, see @ref BLE_GATTS_ATTR_TYPES. */
|
||||
} ble_gatts_attr_context_t;
|
||||
|
||||
|
||||
/**@brief GATT Characteristic Presentation Format. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t format; /**< Format of the value, see @ref BLE_GATT_CPF_FORMATS. */
|
||||
int8_t exponent; /**< Exponent for integer data types. */
|
||||
uint16_t unit; /**< UUID from Bluetooth Assigned Numbers. */
|
||||
uint8_t name_space; /**< Namespace from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */
|
||||
uint16_t desc; /**< Namespace description from Bluetooth Assigned Numbers, see @ref BLE_GATT_CPF_NAMESPACES. */
|
||||
} ble_gatts_char_pf_t;
|
||||
|
||||
|
||||
/**@brief GATT Characteristic metadata. */
|
||||
typedef struct
|
||||
{
|
||||
ble_gatt_char_props_t char_props; /**< Characteristic Properties. */
|
||||
ble_gatt_char_ext_props_t char_ext_props; /**< Characteristic Extended Properties. */
|
||||
uint8_t* p_char_user_desc; /**< Pointer to a UTF-8, NULL if the descriptor is not required. */
|
||||
uint16_t char_user_desc_max_size; /**< The maximum size in bytes of the user description descriptor. */
|
||||
uint16_t char_user_desc_size; /**< The size of the user description, must be smaller or equal to char_user_desc_max_size. */
|
||||
ble_gatts_char_pf_t* p_char_pf; /**< Pointer to a presentation format structure or NULL if the descriptor is not required. */
|
||||
ble_gatts_attr_md_t* p_user_desc_md; /**< Attribute metadata for the User Description descriptor, or NULL for default values. */
|
||||
ble_gatts_attr_md_t* p_cccd_md; /**< Attribute metadata for the Client Characteristic Configuration Descriptor, or NULL for default values. */
|
||||
ble_gatts_attr_md_t* p_sccd_md; /**< Attribute metadata for the Server Characteristic Configuration Descriptor, or NULL for default values. */
|
||||
} ble_gatts_char_md_t;
|
||||
|
||||
|
||||
/**@brief GATT Characteristic Definition Handles. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t value_handle; /**< Handle to the characteristic value. */
|
||||
uint16_t user_desc_handle; /**< Handle to the User Description descriptor, or BLE_GATT_HANDLE_INVALID if not present. */
|
||||
uint16_t cccd_handle; /**< Handle to the Client Characteristic Configuration Descriptor, or BLE_GATT_HANDLE_INVALID if not present. */
|
||||
uint16_t sccd_handle; /**< Handle to the Server Characteristic Configuration Descriptor, or BLE_GATT_HANDLE_INVALID if not present. */
|
||||
} ble_gatts_char_handles_t;
|
||||
|
||||
|
||||
/**@brief GATT HVx parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Characteristic Value Handle. */
|
||||
uint8_t type; /**< Indication or Notification, see @ref BLE_GATT_HVX_TYPES. */
|
||||
uint16_t offset; /**< Offset within the attribute value. */
|
||||
uint16_t* p_len; /**< Length in bytes to be written, length in bytes written after successful return. */
|
||||
uint8_t* p_data; /**< Actual data content, use NULL to use the current attribute value. */
|
||||
} ble_gatts_hvx_params_t;
|
||||
|
||||
/**@brief GATT Read Authorization parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
|
||||
uint8_t update : 1; /**< If set, data supplied in p_data will be used in the ATT response. */
|
||||
uint16_t offset; /**< Offset of the attribute value being updated. */
|
||||
uint16_t len; /**< Length in bytes of the value in p_data pointer, see @ref BLE_GATTS_ATTR_LENS_MAX. */
|
||||
uint8_t* p_data; /**< Pointer to new value used to update the attribute value. */
|
||||
} ble_gatts_read_authorize_params_t;
|
||||
|
||||
/**@brief GATT Write Authorisation parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t gatt_status; /**< GATT status code for the operation, see @ref BLE_GATT_STATUS_CODES. */
|
||||
} ble_gatts_write_authorize_params_t;
|
||||
|
||||
/**@brief GATT Read or Write Authorize Reply parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */
|
||||
union {
|
||||
ble_gatts_read_authorize_params_t read; /**< Read authorization parameters. */
|
||||
ble_gatts_write_authorize_params_t write; /**< Write authorization parameters. */
|
||||
} params;
|
||||
} ble_gatts_rw_authorize_reply_params_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief GATT Server Event IDs.
|
||||
*/
|
||||
enum BLE_GATTS_EVTS
|
||||
{
|
||||
BLE_GATTS_EVT_WRITE = BLE_GATTS_EVT_BASE, /**< Write operation performed. */
|
||||
BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST, /**< Read/Write Authorization request. */
|
||||
BLE_GATTS_EVT_SYS_ATTR_MISSING, /**< A persistent system attribute access is pending, awaiting a sd_ble_gatts_sys_attr_set(). */
|
||||
BLE_GATTS_EVT_HVC, /**< Handle Value Confirmation. */
|
||||
BLE_GATTS_EVT_SC_CONFIRM, /**< Service Changed Confirmation. */
|
||||
BLE_GATTS_EVT_TIMEOUT /**< Timeout. */
|
||||
};
|
||||
|
||||
|
||||
/**@brief Event structure for BLE_GATTS_EVT_WRITE. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
uint8_t op; /**< Type of write operation, see @ref BLE_GATTS_OPS. */
|
||||
ble_gatts_attr_context_t context; /**< Attribute Context. */
|
||||
uint16_t offset; /**< Offset for the write operation. */
|
||||
uint16_t len; /**< Length of the incoming data. */
|
||||
uint8_t data[1]; /**< Incoming data, variable length. */
|
||||
} ble_gatts_evt_write_t;
|
||||
|
||||
/**@brief Event structure for authorize read request. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
ble_gatts_attr_context_t context; /**< Attribute Context. */
|
||||
uint16_t offset; /**< Offset for the read operation. */
|
||||
} ble_gatts_evt_read_t;
|
||||
|
||||
/**@brief Event structure for BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type; /**< Type of authorize operation, see @ref BLE_GATTS_AUTHORIZE_TYPES. */
|
||||
union {
|
||||
ble_gatts_evt_read_t read; /**< Attribute Read Parameters. */
|
||||
ble_gatts_evt_write_t write; /**< Attribute Write Parameters. */
|
||||
} request;
|
||||
} ble_gatts_evt_rw_authorize_request_t;
|
||||
|
||||
/**@brief Event structure for BLE_GATTS_EVT_SYS_ATTR_MISSING. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t hint;
|
||||
} ble_gatts_evt_sys_attr_missing_t;
|
||||
|
||||
|
||||
/**@brief Event structure for BLE_GATTS_EVT_HVC. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t handle; /**< Attribute Handle. */
|
||||
} ble_gatts_evt_hvc_t;
|
||||
|
||||
/**@brief Event structure for BLE_GATTS_EVT_TIMEOUT. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t src; /**< Timeout source, see @ref BLE_GATT_TIMEOUT_SOURCES. */
|
||||
} ble_gatts_evt_timeout_t;
|
||||
|
||||
|
||||
/**@brief GATT Server event callback event structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which event occurred. */
|
||||
union
|
||||
{
|
||||
ble_gatts_evt_write_t write; /**< Write Event Parameters. */
|
||||
ble_gatts_evt_rw_authorize_request_t authorize_request; /**< Read or Write Authorize Request Parameters. */
|
||||
ble_gatts_evt_sys_attr_missing_t sys_attr_missing; /**< System attributes missing. */
|
||||
ble_gatts_evt_hvc_t hvc; /**< Handle Value Confirmation Event Parameters. */
|
||||
ble_gatts_evt_timeout_t timeout; /**< Timeout Event. */
|
||||
} params;
|
||||
} ble_gatts_evt_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_GATTS_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Add a service declaration to the local server ATT table.
|
||||
*
|
||||
* @param[in] type Toggles between primary and secondary services, see @ref BLE_GATTS_SRVC_TYPES.
|
||||
* @param[in] p_uuid Pointer to service UUID.
|
||||
* @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored.
|
||||
*
|
||||
* @note Secondary Services are only relevant in the context of the entity that references them, it is therefore forbidden to
|
||||
* add a secondary service declaration that is not referenced by another service later in the ATT table.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully added a service declaration.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, Vendor Specific UUIDs need to be present in the table.
|
||||
* @return @ref NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
|
||||
* @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_SERVICE_ADD, uint32_t, sd_ble_gatts_service_add(uint8_t type, ble_uuid_t const*const p_uuid, uint16_t *const p_handle));
|
||||
|
||||
|
||||
/**@brief Add an include declaration to the local server ATT table.
|
||||
*
|
||||
* @note It is currently only possible to add an include declaration to the last added service (i.e. only sequential addition is supported at this time).
|
||||
*
|
||||
* @note The included service must already be present in the ATT table prior to this call.
|
||||
*
|
||||
* @param[in] service_handle Handle of the service where the included service is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
|
||||
* @param[in] inc_srvc_handle Handle of the included service.
|
||||
* @param[out] p_include_handle Pointer to a 16-bit word where the assigned handle will be stored.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully added an include declaration.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, handle values need to match previously added services.
|
||||
* @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
|
||||
* @return @ref NRF_ERROR_FORBIDDEN Forbidden value supplied, self inclusions are not allowed.
|
||||
* @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @return @ref NRF_ERROR_NOT_FOUND Attribute not found.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_INCLUDE_ADD, uint32_t, sd_ble_gatts_include_add(uint16_t service_handle, uint16_t inc_srvc_handle, uint16_t *const p_include_handle));
|
||||
|
||||
|
||||
/**@brief Add a characteristic declaration, a characteristic value declaration and optional characteristic descriptor declarations to the local server ATT table.
|
||||
*
|
||||
* @note It is currently only possible to add a characteristic to the last added service (i.e. only sequential addition is supported at this time).
|
||||
*
|
||||
* @note Several restrictions apply to the parameters, such as matching permissions between the user description descriptor and the writeable auxiliaries bits,
|
||||
* readable (no security) and writeable (selectable) CCCDs and SCCDs and valid presentation format values.
|
||||
*
|
||||
* @note If no metadata is provided for the optional descriptors, their permissions will be derived from the characteristic permissions.
|
||||
*
|
||||
* @param[in] service_handle Handle of the service where the characteristic is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
|
||||
* @param[in] p_char_md Characteristic metadata.
|
||||
* @param[in] p_attr_char_value Pointer to the attribute structure corresponding to the characteristic value.
|
||||
* @param[out] p_handles Pointer to the structure where the assigned handles will be stored.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully added a characteristic.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, service handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
|
||||
* @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation, a service context is required.
|
||||
* @return @ref NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
|
||||
* @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_CHARACTERISTIC_ADD, uint32_t, sd_ble_gatts_characteristic_add(uint16_t service_handle, ble_gatts_char_md_t const*const p_char_md, ble_gatts_attr_t const*const p_attr_char_value, ble_gatts_char_handles_t *const p_handles));
|
||||
|
||||
|
||||
/**@brief Add a descriptor to the local server ATT table.
|
||||
*
|
||||
* @note It is currently only possible to add a descriptor to the last added characteristic (i.e. only sequential addition is supported at this time).
|
||||
*
|
||||
* @param[in] char_handle Handle of the characteristic where the descriptor is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
|
||||
* @param[in] p_attr Pointer to the attribute structure.
|
||||
* @param[out] p_handle Pointer to a 16-bit word where the assigned handle will be stored.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully added a descriptor.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, characteristic handle, Vendor Specific UUIDs, lengths, and permissions need to adhere to the constraints.
|
||||
* @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation, a characteristic context is required.
|
||||
* @return @ref NRF_ERROR_FORBIDDEN Forbidden value supplied, certain UUIDs are reserved for the stack.
|
||||
* @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_DESCRIPTOR_ADD, uint32_t, sd_ble_gatts_descriptor_add(uint16_t char_handle, ble_gatts_attr_t const * const p_attr, uint16_t* const p_handle));
|
||||
|
||||
/**@brief Set the value of a given attribute.
|
||||
*
|
||||
* @param[in] handle Attribute handle.
|
||||
* @param[in] offset Offset in bytes to write from.
|
||||
* @param[in,out] p_len Length in bytes to be written, length in bytes written after successful return.
|
||||
* @param[in] p_value Pointer to a buffer (at least len bytes long) containing the desired attribute value. If value is stored in user memory, only the attribute length is updated when p_value == NULL.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully set the value of the attribute.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @return @ref NRF_ERROR_NOT_FOUND Attribute not found.
|
||||
* @return @ref NRF_ERROR_FORBIDDEN Forbidden handle supplied, certain attributes are not modifiable by the application.
|
||||
* @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, attribute lengths are restricted by @ref BLE_GATTS_ATTR_LENS_MAX.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_VALUE_SET, uint32_t, sd_ble_gatts_value_set(uint16_t handle, uint16_t offset, uint16_t* const p_len, uint8_t const * const p_value));
|
||||
|
||||
/**@brief Get the value of a given attribute.
|
||||
*
|
||||
* @param[in] handle Attribute handle.
|
||||
* @param[in] offset Offset in bytes to read from.
|
||||
* @param[in,out] p_len Length in bytes to be read, total length of attribute value (in bytes, starting from offset) after successful return.
|
||||
* @param[in,out] p_data Pointer to a buffer (at least len bytes long) where to store the attribute value. Set to NULL to obtain the complete length of attribute value.
|
||||
*
|
||||
* @note If the attribute value is longer than the size of the supplied buffer,
|
||||
* p_len will return the total attribute value length (excluding offset),
|
||||
* and not the number of bytes actually returned in p_data.
|
||||
* The application may use this information to allocate a suitable buffer size.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully retrieved the value of the attribute.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_NOT_FOUND Attribute not found.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_VALUE_GET, uint32_t, sd_ble_gatts_value_get(uint16_t handle, uint16_t offset, uint16_t *const p_len, uint8_t* const p_data));
|
||||
|
||||
/**@brief Notify or Indicate an attribute value.
|
||||
*
|
||||
* @details This function checks for the relevant Client Characteristic Configuration descriptor value to verify that the relevant operation
|
||||
* (notification or indication) has been enabled by the client. It is also able to update the attribute value before issuing the PDU, so that
|
||||
* the application can atomically perform a value update and a server initiated transaction with a single API call.
|
||||
* If the application chooses to indicate an attribute value, a @ref BLE_GATTS_EVT_HVC will be sent up as soon as the confirmation arrives from
|
||||
* the peer.
|
||||
*
|
||||
* @note The local attribute value may be updated even if an outgoing packet is not sent to the peer due to an error during execution.
|
||||
* When receiveing the error codes @ref NRF_ERROR_INVALID_STATE, @ref NRF_ERROR_BUSY, @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING and
|
||||
* @ref BLE_ERROR_NO_TX_BUFFERS the ATT table has been updated.
|
||||
* The caller can check whether the value has been updated by looking at the contents of *(p_hvx_params->p_len).
|
||||
*
|
||||
* @note It is important to note that a notification will <b>consume an application buffer</b>, and will therefore
|
||||
* generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted. An indication on the other hand will use the
|
||||
* standard server internal buffer and thus will only generate a @ref BLE_GATTS_EVT_HVC event as soon as the confirmation
|
||||
* has been received from the peer. Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_hvx_params Pointer to an HVx parameters structure. If the p_data member contains a non-NULL pointer the attribute value will be updated with
|
||||
* the contents pointed by it before sending the notification or indication.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully queued a notification or indication for transmission, and optionally updated the attribute value.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @return @ref BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied. Only attributes added directly by the application are available to notify and indicate.
|
||||
* @return @ref BLE_ERROR_GATTS_INVALID_ATTR_TYPE Invalid attribute type(s) supplied, only characteristic values may be notified and indicated.
|
||||
* @return @ref NRF_ERROR_NOT_FOUND Attribute not found.
|
||||
* @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
|
||||
* @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation, notifications or indications must be enabled in the CCCD.
|
||||
* @return @ref NRF_ERROR_BUSY Procedure already in progress.
|
||||
* @return @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value.
|
||||
* @return @ref BLE_ERROR_NO_TX_BUFFERS There are no available buffers to send the data, applies only to notifications.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_HVX, uint32_t, sd_ble_gatts_hvx(uint16_t conn_handle, ble_gatts_hvx_params_t const*const p_hvx_params));
|
||||
|
||||
/**@brief Indicate the Service Changed attribute value.
|
||||
*
|
||||
* @details This call will send a Handle Value Indication to one or more peers connected to inform them that the attribute
|
||||
* table layout has changed. As soon as the peer has confirmed the indication, a @ref BLE_GATTS_EVT_SC_CONFIRM event will
|
||||
* be issued.
|
||||
*
|
||||
* @note Some of the restrictions and limitations that apply to @ref sd_ble_gatts_hvx also apply here.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] start_handle Start of affected attribute handle range.
|
||||
* @param[in] end_handle End of affected attribute handle range.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully queued the Service Changed indication for transmission.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @return @ref BLE_ERROR_INVALID_ATTR_HANDLE Invalid attribute handle(s) supplied, handles must be in the range populated by the application.
|
||||
* @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation, notifications or indications must be enabled in the CCCD.
|
||||
* @return @ref NRF_ERROR_BUSY Procedure already in progress.
|
||||
* @return @ref BLE_ERROR_GATTS_SYS_ATTR_MISSING System attributes missing, use @ref sd_ble_gatts_sys_attr_set to set them to a known value.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_SERVICE_CHANGED, uint32_t, sd_ble_gatts_service_changed(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle));
|
||||
|
||||
/**@brief Respond to a Read/Write authorization request.
|
||||
*
|
||||
* @note This call should only be used as a response to a @ref BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event issued to the application.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_rw_authorize_reply_params Pointer to a structure with the attribute provided by the application.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully queued a response to the peer, and in the case of a write operation, ATT table updated.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_STATE No authorization request pending.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Authorization op invalid,
|
||||
* or for Read Authorization reply: requested handles not replied with,
|
||||
* or for Write Authorization reply: handle supplied does not match requested handle.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_RW_AUTHORIZE_REPLY, uint32_t, sd_ble_gatts_rw_authorize_reply(uint16_t conn_handle, ble_gatts_rw_authorize_reply_params_t const*const p_rw_authorize_reply_params));
|
||||
|
||||
|
||||
/**@brief Update persistent system attribute information.
|
||||
*
|
||||
* @details Supply to the stack information about persistent system attributes.
|
||||
* This call is legal in the connected state only, and is usually
|
||||
* made immediately after a connection is established and the bond identified.
|
||||
* usually as a response to a BLE_GATTS_EVT_SYS_ATTR_MISSING.
|
||||
*
|
||||
* p_sysattrs may point directly to the application's stored copy of the struct.
|
||||
* If the pointer is NULL, the system attribute info is initialized, assuming that
|
||||
* the application does not have any previously saved data for this bond.
|
||||
*
|
||||
* @note The state of persistent system attributes is reset upon connection and then remembered for its duration.
|
||||
*
|
||||
* @note If this call returns with an error code different from @ref NRF_SUCCESS, the storage of persistent system attributes may have been completed only partially.
|
||||
* This means that the state of the attribute table is undefined, and the application should either provide a new set of attributes using this same call or
|
||||
* reset the SoftDevice to return to a known state.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle.
|
||||
* @param[in] p_sys_attr_data Pointer to a saved copy of system attributes supplied to the stack, or NULL.
|
||||
* @param[in] len Size of data pointed by p_sys_attr_data, in octets.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully set the system attribute information.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_DATA Invalid data supplied, the data should be exactly the same as retrieved with @ref sd_ble_gatts_sys_attr_get.
|
||||
* @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_SYS_ATTR_SET, uint32_t, sd_ble_gatts_sys_attr_set(uint16_t conn_handle, uint8_t const*const p_sys_attr_data, uint16_t len));
|
||||
|
||||
|
||||
/**@brief Retrieve persistent system attribute information from the stack.
|
||||
*
|
||||
* @details This call is used to retrieve information about values to be stored perisistently by the application
|
||||
* after a connection has been terminated. When a new connection is made to the same bond, the values
|
||||
* should be restored using @ref sd_ble_gatts_sys_attr_set.
|
||||
* The data should be read before any new advertising is started, or any new connection established. The connection handle for
|
||||
* the previous now defunct connection will remain valid until a new one is created to allow this API call to refer to it.
|
||||
*
|
||||
* @param[in] conn_handle Connection handle of the recently terminated connection.
|
||||
* @param[in] p_sys_attr_data Pointer to a buffer where updated information about system attributes will be filled in. NULL can be provided to
|
||||
* obtain the length of the data
|
||||
* @param[in,out] p_len Size of application buffer if p_sys_attr_data is not NULL. Unconditially updated to actual length of system attribute data.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully retrieved the system attribute information.
|
||||
* @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_DATA_SIZE The system attribute information did not fit into the provided buffer.
|
||||
*/
|
||||
SVCALL(SD_BLE_GATTS_SYS_ATTR_GET, uint32_t, sd_ble_gatts_sys_attr_get(uint16_t conn_handle, uint8_t * const p_sys_attr_data, uint16_t* const p_len));
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif // BLE_GATTS_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
|
||||
|
||||
The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
copying, transfer or disclosure of such information is prohibited except by express written
|
||||
agreement with Nordic Semiconductor.
|
||||
*/
|
||||
/**
|
||||
@addtogroup BLE_COMMON
|
||||
@{
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BLE_HCI_H__
|
||||
#define BLE_HCI_H__
|
||||
|
||||
/** @defgroup BLE_HCI_STATUS_CODES Bluetooth status codes
|
||||
* @{ */
|
||||
|
||||
#define BLE_HCI_STATUS_CODE_SUCCESS 0x00
|
||||
#define BLE_HCI_STATUS_CODE_UNKNOWN_BTLE_COMMAND 0x01
|
||||
#define BLE_HCI_STATUS_CODE_UNKNOWN_CONNECTION_IDENTIFIER 0x02
|
||||
/*0x03 Hardware Failure
|
||||
0x04 Page Timeout
|
||||
*/
|
||||
#define BLE_HCI_AUTHENTICATION_FAILURE 0x05
|
||||
#define BLE_HCI_STATUS_CODE_PIN_OR_KEY_MISSING 0x06
|
||||
#define BLE_HCI_MEMORY_CAPACITY_EXCEEDED 0x07
|
||||
#define BLE_HCI_CONNECTION_TIMEOUT 0x08
|
||||
/*0x09 Connection Limit Exceeded
|
||||
0x0A Synchronous Connection Limit To A Device Exceeded
|
||||
0x0B ACL Connection Already Exists*/
|
||||
#define BLE_HCI_STATUS_CODE_COMMAND_DISALLOWED 0x0C
|
||||
/*0x0D Connection Rejected due to Limited Resources
|
||||
0x0E Connection Rejected Due To Security Reasons
|
||||
0x0F Connection Rejected due to Unacceptable BD_ADDR
|
||||
0x10 Connection Accept Timeout Exceeded
|
||||
0x11 Unsupported Feature or Parameter Value*/
|
||||
#define BLE_HCI_STATUS_CODE_INVALID_BTLE_COMMAND_PARAMETERS 0x12
|
||||
#define BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION 0x13
|
||||
#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES 0x14
|
||||
#define BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF 0x15
|
||||
#define BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION 0x16
|
||||
/*
|
||||
0x17 Repeated Attempts
|
||||
0x18 Pairing Not Allowed
|
||||
0x19 Unknown LMP PDU
|
||||
*/
|
||||
#define BLE_HCI_UNSUPPORTED_REMOTE_FEATURE 0x1A
|
||||
/*
|
||||
0x1B SCO Offset Rejected
|
||||
0x1C SCO Interval Rejected
|
||||
0x1D SCO Air Mode Rejected*/
|
||||
#define BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS 0x1E
|
||||
#define BLE_HCI_STATUS_CODE_UNSPECIFIED_ERROR 0x1F
|
||||
/*0x20 Unsupported LMP Parameter Value
|
||||
0x21 Role Change Not Allowed
|
||||
*/
|
||||
#define BLE_HCI_STATUS_CODE_LMP_RESPONSE_TIMEOUT 0x22
|
||||
/*0x23 LMP Error Transaction Collision*/
|
||||
#define BLE_HCI_STATUS_CODE_LMP_PDU_NOT_ALLOWED 0x24
|
||||
/*0x25 Encryption Mode Not Acceptable
|
||||
0x26 Link Key Can Not be Changed
|
||||
0x27 Requested QoS Not Supported
|
||||
*/
|
||||
#define BLE_HCI_INSTANT_PASSED 0x28
|
||||
#define BLE_HCI_PAIRING_WITH_UNIT_KEY_UNSUPPORTED 0x29
|
||||
#define BLE_HCI_DIFFERENT_TRANSACTION_COLLISION 0x2A
|
||||
/*
|
||||
0x2B Reserved
|
||||
0x2C QoS Unacceptable Parameter
|
||||
0x2D QoS Rejected
|
||||
0x2E Channel Classification Not Supported
|
||||
0x2F Insufficient Security
|
||||
0x30 Parameter Out Of Mandatory Range
|
||||
0x31 Reserved
|
||||
0x32 Role Switch Pending
|
||||
0x33 Reserved
|
||||
0x34 Reserved Slot Violation
|
||||
0x35 Role Switch Failed
|
||||
0x36 Extended Inquiry Response Too Large
|
||||
0x37 Secure Simple Pairing Not Supported By Host.
|
||||
0x38 Host Busy - Pairing
|
||||
0x39 Connection Rejected due to No Suitable Channel Found*/
|
||||
#define BLE_HCI_CONTROLLER_BUSY 0x3A
|
||||
#define BLE_HCI_CONN_INTERVAL_UNACCEPTABLE 0x3B
|
||||
#define BLE_HCI_DIRECTED_ADVERTISER_TIMEOUT 0x3C
|
||||
#define BLE_HCI_CONN_TERMINATED_DUE_TO_MIC_FAILURE 0x3D
|
||||
#define BLE_HCI_CONN_FAILED_TO_BE_ESTABLISHED 0x3E
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
#endif // BLE_HCI_H__
|
||||
|
||||
/** @} */
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
/* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@addtogroup BLE_L2CAP Logical Link Control and Adaptation Protocol (L2CAP)
|
||||
@{
|
||||
@brief Definitions and prototypes for the L2CAP interface.
|
||||
*/
|
||||
|
||||
#ifndef BLE_L2CAP_H__
|
||||
#define BLE_L2CAP_H__
|
||||
|
||||
#include "ble_types.h"
|
||||
#include "ble_ranges.h"
|
||||
#include "ble_err.h"
|
||||
#include "nrf_svc.h"
|
||||
|
||||
/**@addtogroup BLE_L2CAP_ENUMERATIONS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief L2CAP API SVC numbers. */
|
||||
enum BLE_L2CAP_SVCS
|
||||
{
|
||||
SD_BLE_L2CAP_CID_REGISTER = BLE_L2CAP_SVC_BASE, /**< Register a CID. */
|
||||
SD_BLE_L2CAP_CID_UNREGISTER, /**< Unregister a CID. */
|
||||
SD_BLE_L2CAP_TX /**< Transmit a packet. */
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/**@addtogroup BLE_L2CAP_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@defgroup BLE_ERRORS_L2CAP SVC return values specific to L2CAP
|
||||
* @{ */
|
||||
#define BLE_ERROR_L2CAP_CID_IN_USE (NRF_L2CAP_ERR_BASE + 0x000) /**< CID already in use. */
|
||||
/** @} */
|
||||
|
||||
/**@brief Default L2CAP MTU. */
|
||||
#define BLE_L2CAP_MTU_DEF (23)
|
||||
|
||||
/**@brief Invalid Channel Identifier. */
|
||||
#define BLE_L2CAP_CID_INVALID (0x0000)
|
||||
|
||||
/**@brief Dynamic Channel Identifier base. */
|
||||
#define BLE_L2CAP_CID_DYN_BASE (0x0040)
|
||||
|
||||
/**@brief Maximum amount of dynamic CIDs. */
|
||||
#define BLE_L2CAP_CID_DYN_MAX (8)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**@addtogroup BLE_L2CAP_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/**@brief Packet header format for L2CAP transmission. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t len; /**< Length of valid info in data member. */
|
||||
uint16_t cid; /**< Channel ID on which packet is transmitted. */
|
||||
} ble_l2cap_header_t;
|
||||
|
||||
/**@brief L2CAP Event IDs. */
|
||||
enum BLE_L2CAP_EVTS
|
||||
{
|
||||
BLE_L2CAP_EVT_RX = BLE_L2CAP_EVT_BASE /**< L2CAP packet received. */
|
||||
};
|
||||
|
||||
|
||||
/**@brief L2CAP Received packet event report. */
|
||||
typedef struct
|
||||
{
|
||||
ble_l2cap_header_t header; /** L2CAP packet header. */
|
||||
uint8_t data[1]; /**< Packet data, variable length. */
|
||||
} ble_l2cap_evt_rx_t;
|
||||
|
||||
|
||||
/**@brief L2CAP event callback event structure. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t conn_handle; /**< Connection Handle on which event occured. */
|
||||
union
|
||||
{
|
||||
ble_l2cap_evt_rx_t rx; /**< RX Event parameters. */
|
||||
} params;
|
||||
} ble_l2cap_evt_t;
|
||||
|
||||
|
||||
/**@brief Register a CID with L2CAP.
|
||||
*
|
||||
* @details This registers a higher protocol layer with the L2CAP multiplexer, and is requried prior to all operations on the CID.
|
||||
*
|
||||
* @param[in] cid L2CAP CID.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully registered a CID with the L2CAP layer.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CID must be above @ref BLE_L2CAP_CID_DYN_BASE.
|
||||
* @return @ref BLE_ERROR_L2CAP_CID_IN_USE L2CAP CID already in use.
|
||||
* @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
*/
|
||||
SVCALL(SD_BLE_L2CAP_CID_REGISTER, uint32_t, sd_ble_l2cap_cid_register(uint16_t cid));
|
||||
|
||||
/**@brief Unregister a CID with L2CAP.
|
||||
*
|
||||
* @details This unregisters a previously registerd higher protocol layer with the L2CAP multiplexer.
|
||||
*
|
||||
* @param[in] cid L2CAP CID.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully unregistered the CID.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
|
||||
* @return @ref NRF_ERROR_NOT_FOUND CID not previously registered.
|
||||
*/
|
||||
SVCALL(SD_BLE_L2CAP_CID_UNREGISTER, uint32_t, sd_ble_l2cap_cid_unregister(uint16_t cid));
|
||||
|
||||
/**@brief Transmit an L2CAP packet.
|
||||
*
|
||||
* @note It is important to note that a call to this function will <b>consume an application buffer</b>, and will therefore
|
||||
* generate a @ref BLE_EVT_TX_COMPLETE event when the packet has been transmitted.
|
||||
* Please see the documentation of @ref sd_ble_tx_buffer_count_get for more details.
|
||||
*
|
||||
* @param[in] conn_handle Connection Handle.
|
||||
* @param[in] p_header Pointer to a packet header containing length and CID.
|
||||
* @param[in] p_data Pointer to the data to be transmitted.
|
||||
*
|
||||
* @return @ref NRF_SUCCESS Successfully queued an L2CAP packet for transmission.
|
||||
* @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
|
||||
* @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CIDs must be registered beforehand with @ref sd_ble_l2cap_cid_register.
|
||||
* @return @ref NRF_ERROR_NOT_FOUND CID not found.
|
||||
* @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
|
||||
* @return @ref BLE_ERROR_NO_TX_BUFFERS Not enough application buffers available.
|
||||
* @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, see @ref BLE_L2CAP_MTU_DEF.
|
||||
*/
|
||||
SVCALL(SD_BLE_L2CAP_TX, uint32_t, sd_ble_l2cap_tx(uint16_t conn_handle, ble_l2cap_header_t const * const p_header, uint8_t const * const p_data));
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif // BLE_L2CAP_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
|
||||
|
||||
The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
copying, transfer or disclosure of such information is prohibited except by express written
|
||||
agreement with Nordic Semiconductor.
|
||||
*/
|
||||
/**
|
||||
@addtogroup BLE_COMMON
|
||||
@{
|
||||
@defgroup ble_ranges Module specific SVC and event number subranges
|
||||
@{
|
||||
|
||||
@brief Definition of SVC and event number subranges for each API module.
|
||||
|
||||
@note
|
||||
SVCs and event numbers are split into subranges for each API module.
|
||||
Each module receives its entire allocated range of SVC calls, whether implemented or not,
|
||||
but return BLE_ERROR_NOT_SUPPORTED for unimplemented or undefined calls in its range.
|
||||
|
||||
Note that the symbols BLE_<module>_SVC_LAST is the end of the allocated SVC range,
|
||||
rather than the last SVC function call actually defined and implemented.
|
||||
|
||||
Specific SVC and event values are defined in each module's ble_<module>.h file,
|
||||
which defines names of each individual SVC code based on the range start value.
|
||||
*/
|
||||
|
||||
#ifndef BLE_RANGES_H__
|
||||
#define BLE_RANGES_H__
|
||||
|
||||
#define BLE_SVC_BASE 0x60
|
||||
#define BLE_SVC_LAST 0x6B /* Total: 12. */
|
||||
|
||||
#define BLE_RESERVED_SVC_BASE 0x6C
|
||||
#define BLE_RESERVED_SVC_LAST 0x6F /* Total: 4. */
|
||||
|
||||
#define BLE_GAP_SVC_BASE 0x70
|
||||
#define BLE_GAP_SVC_LAST 0x8F /* Total: 32. */
|
||||
|
||||
#define BLE_GATTC_SVC_BASE 0x90
|
||||
#define BLE_GATTC_SVC_LAST 0x9F /* Total: 16. */
|
||||
|
||||
#define BLE_GATTS_SVC_BASE 0xA0
|
||||
#define BLE_GATTS_SVC_LAST 0xAF /* Total: 16. */
|
||||
|
||||
#define BLE_L2CAP_SVC_BASE 0xB0
|
||||
#define BLE_L2CAP_SVC_LAST 0xBF /* Total: 16. */
|
||||
|
||||
|
||||
#define BLE_EVT_INVALID 0x00
|
||||
|
||||
#define BLE_EVT_BASE 0x01
|
||||
#define BLE_EVT_LAST 0x0F /* Total: 15. */
|
||||
|
||||
#define BLE_GAP_EVT_BASE 0x10
|
||||
#define BLE_GAP_EVT_LAST 0x2F /* Total: 32. */
|
||||
|
||||
#define BLE_GATTC_EVT_BASE 0x30
|
||||
#define BLE_GATTC_EVT_LAST 0x4F /* Total: 32. */
|
||||
|
||||
#define BLE_GATTS_EVT_BASE 0x50
|
||||
#define BLE_GATTS_EVT_LAST 0x6F /* Total: 32. */
|
||||
|
||||
#define BLE_L2CAP_EVT_BASE 0x70
|
||||
#define BLE_L2CAP_EVT_LAST 0x8F /* Total: 32. */
|
||||
|
||||
#define BLE_OPT_INVALID 0x00 /**< Invalid BLE Option. */
|
||||
|
||||
#define BLE_OPT_BASE 0x01 /**< Common BLE Option base. */
|
||||
#define BLE_OPT_LAST 0x1F /**< Total: 31. */
|
||||
|
||||
#define BLE_GAP_OPT_BASE 0x20 /**< GAP BLE Option base. */
|
||||
#define BLE_GAP_OPT_LAST 0x3F /**< Total: 32. */
|
||||
|
||||
#define BLE_GATTC_OPT_BASE 0x40 /**< GATTC BLE Option base. */
|
||||
#define BLE_GATTC_OPT_LAST 0x5F /**< Total: 32. */
|
||||
|
||||
#define BLE_GATTS_OPT_BASE 0x60 /**< GATTS BLE Option base. */
|
||||
#define BLE_GATTS_OPT_LAST 0x7F /**< Total: 32. */
|
||||
|
||||
#define BLE_L2CAP_OPT_BASE 0x80 /**< L2CAP BLE Option base. */
|
||||
#define BLE_L2CAP_OPT_LAST 0x9F /**< Total: 32. */
|
||||
|
||||
#endif /* BLE_RANGES_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
/* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@addtogroup BLE_COMMON
|
||||
@{
|
||||
@defgroup ble_types Common types and macro definitions
|
||||
@{
|
||||
|
||||
@brief Common types and macro definitions for the S110 SoftDevice.
|
||||
*/
|
||||
|
||||
#ifndef BLE_TYPES_H__
|
||||
#define BLE_TYPES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** @addtogroup BLE_COMMON_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/** @defgroup BLE_CONN_HANDLES BLE Connection Handles
|
||||
* @{ */
|
||||
#define BLE_CONN_HANDLE_INVALID 0xFFFF /**< Invalid Connection Handle. */
|
||||
#define BLE_CONN_HANDLE_ALL 0xFFFE /**< Applies to all Connection Handles. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_UUID_VALUES Assigned Values for BLE UUIDs
|
||||
* @{ */
|
||||
/* Generic UUIDs, applicable to all services */
|
||||
#define BLE_UUID_UNKNOWN 0x0000 /**< Reserved UUID. */
|
||||
#define BLE_UUID_SERVICE_PRIMARY 0x2800 /**< Primary Service. */
|
||||
#define BLE_UUID_SERVICE_SECONDARY 0x2801 /**< Secondary Service. */
|
||||
#define BLE_UUID_SERVICE_INCLUDE 0x2802 /**< Include. */
|
||||
#define BLE_UUID_CHARACTERISTIC 0x2803 /**< Characteristic. */
|
||||
#define BLE_UUID_DESCRIPTOR_CHAR_EXT_PROP 0x2900 /**< Characteristic Extended Properties Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_CHAR_USER_DESC 0x2901 /**< Characteristic User Description Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG 0x2902 /**< Client Characteristic Configuration Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_SERVER_CHAR_CONFIG 0x2903 /**< Server Characteristic Configuration Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_CHAR_PRESENTATION_FORMAT 0x2904 /**< Characteristic Presentation Format Descriptor. */
|
||||
#define BLE_UUID_DESCRIPTOR_CHAR_AGGREGATE_FORMAT 0x2905 /**< Characteristic Aggregate Format Descriptor. */
|
||||
/* GATT specific UUIDs */
|
||||
#define BLE_UUID_GATT 0x1801 /**< Generic Attribute Profile. */
|
||||
#define BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED 0x2A05 /**< Service Changed Characteristic. */
|
||||
/* GAP specific UUIDs */
|
||||
#define BLE_UUID_GAP 0x1800 /**< Generic Access Profile. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME 0x2A00 /**< Device Name Characteristic. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_APPEARANCE 0x2A01 /**< Appearance Characteristic. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_PPF 0x2A02 /**< Peripheral Privacy Flag Characteristic. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_RECONN_ADDR 0x2A03 /**< Reconnection Address Characteristic. */
|
||||
#define BLE_UUID_GAP_CHARACTERISTIC_PPCP 0x2A04 /**< Peripheral Preferred Connection Parameters Characteristic. */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_UUID_TYPES Types of UUID
|
||||
* @{ */
|
||||
#define BLE_UUID_TYPE_UNKNOWN 0x00 /**< Invalid UUID type. */
|
||||
#define BLE_UUID_TYPE_BLE 0x01 /**< Bluetooth SIG UUID (16-bit). */
|
||||
#define BLE_UUID_TYPE_VENDOR_BEGIN 0x02 /**< Vendor UUID types start at this index (128-bit). */
|
||||
/** @} */
|
||||
|
||||
|
||||
/** @defgroup BLE_APPEARANCES Bluetooth Appearance values
|
||||
* @note Retrieved from http://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
|
||||
* @{ */
|
||||
#define BLE_APPEARANCE_UNKNOWN 0 /**< Unknown. */
|
||||
#define BLE_APPEARANCE_GENERIC_PHONE 64 /**< Generic Phone. */
|
||||
#define BLE_APPEARANCE_GENERIC_COMPUTER 128 /**< Generic Computer. */
|
||||
#define BLE_APPEARANCE_GENERIC_WATCH 192 /**< Generic Watch. */
|
||||
#define BLE_APPEARANCE_WATCH_SPORTS_WATCH 193 /**< Watch: Sports Watch. */
|
||||
#define BLE_APPEARANCE_GENERIC_CLOCK 256 /**< Generic Clock. */
|
||||
#define BLE_APPEARANCE_GENERIC_DISPLAY 320 /**< Generic Display. */
|
||||
#define BLE_APPEARANCE_GENERIC_REMOTE_CONTROL 384 /**< Generic Remote Control. */
|
||||
#define BLE_APPEARANCE_GENERIC_EYE_GLASSES 448 /**< Generic Eye-glasses. */
|
||||
#define BLE_APPEARANCE_GENERIC_TAG 512 /**< Generic Tag. */
|
||||
#define BLE_APPEARANCE_GENERIC_KEYRING 576 /**< Generic Keyring. */
|
||||
#define BLE_APPEARANCE_GENERIC_MEDIA_PLAYER 640 /**< Generic Media Player. */
|
||||
#define BLE_APPEARANCE_GENERIC_BARCODE_SCANNER 704 /**< Generic Barcode Scanner. */
|
||||
#define BLE_APPEARANCE_GENERIC_THERMOMETER 768 /**< Generic Thermometer. */
|
||||
#define BLE_APPEARANCE_THERMOMETER_EAR 769 /**< Thermometer: Ear. */
|
||||
#define BLE_APPEARANCE_GENERIC_HEART_RATE_SENSOR 832 /**< Generic Heart rate Sensor. */
|
||||
#define BLE_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT 833 /**< Heart Rate Sensor: Heart Rate Belt. */
|
||||
#define BLE_APPEARANCE_GENERIC_BLOOD_PRESSURE 896 /**< Generic Blood Pressure. */
|
||||
#define BLE_APPEARANCE_BLOOD_PRESSURE_ARM 897 /**< Blood Pressure: Arm. */
|
||||
#define BLE_APPEARANCE_BLOOD_PRESSURE_WRIST 898 /**< Blood Pressure: Wrist. */
|
||||
#define BLE_APPEARANCE_GENERIC_HID 960 /**< Human Interface Device (HID). */
|
||||
#define BLE_APPEARANCE_HID_KEYBOARD 961 /**< Keyboard (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_MOUSE 962 /**< Mouse (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_JOYSTICK 963 /**< Joystiq (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_GAMEPAD 964 /**< Gamepad (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_DIGITIZERSUBTYPE 965 /**< Digitizer Tablet (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_CARD_READER 966 /**< Card Reader (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_DIGITAL_PEN 967 /**< Digital Pen (HID Subtype). */
|
||||
#define BLE_APPEARANCE_HID_BARCODE 968 /**< Barcode Scanner (HID Subtype). */
|
||||
#define BLE_APPEARANCE_GENERIC_GLUCOSE_METER 1024 /**< Generic Glucose Meter. */
|
||||
#define BLE_APPEARANCE_GENERIC_RUNNING_WALKING_SENSOR 1088 /**< Generic Running Walking Sensor. */
|
||||
#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_IN_SHOE 1089 /**< Running Walking Sensor: In-Shoe. */
|
||||
#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_SHOE 1090 /**< Running Walking Sensor: On-Shoe. */
|
||||
#define BLE_APPEARANCE_RUNNING_WALKING_SENSOR_ON_HIP 1091 /**< Running Walking Sensor: On-Hip. */
|
||||
#define BLE_APPEARANCE_GENERIC_CYCLING 1152 /**< Generic Cycling. */
|
||||
#define BLE_APPEARANCE_CYCLING_CYCLING_COMPUTER 1153 /**< Cycling: Cycling Computer. */
|
||||
#define BLE_APPEARANCE_CYCLING_SPEED_SENSOR 1154 /**< Cycling: Speed Sensor. */
|
||||
#define BLE_APPEARANCE_CYCLING_CADENCE_SENSOR 1155 /**< Cycling: Cadence Sensor. */
|
||||
#define BLE_APPEARANCE_CYCLING_POWER_SENSOR 1156 /**< Cycling: Power Sensor. */
|
||||
#define BLE_APPEARANCE_CYCLING_SPEED_CADENCE_SENSOR 1157 /**< Cycling: Speed and Cadence Sensor. */
|
||||
#define BLE_APPEARANCE_GENERIC_PULSE_OXIMETER 3136 /**< Generic Pulse Oximeter. */
|
||||
#define BLE_APPEARANCE_PULSE_OXIMETER_FINGERTIP 3137 /**< Fingertip (Pulse Oximeter subtype). */
|
||||
#define BLE_APPEARANCE_PULSE_OXIMETER_WRIST_WORN 3138 /**< Wrist Worn(Pulse Oximeter subtype). */
|
||||
#define BLE_APPEARANCE_GENERIC_WEIGHT_SCALE 3200 /**< Generic Weight Scale. */
|
||||
#define BLE_APPEARANCE_GENERIC_OUTDOOR_SPORTS_ACT 5184 /**< Generic Outdoor Sports Activity. */
|
||||
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_DISP 5185 /**< Location Display Device (Outdoor Sports Activity subtype). */
|
||||
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_DISP 5186 /**< Location and Navigation Display Device (Outdoor Sports Activity subtype). */
|
||||
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_POD 5187 /**< Location Pod (Outdoor Sports Activity subtype). */
|
||||
#define BLE_APPEARANCE_OUTDOOR_SPORTS_ACT_LOC_AND_NAV_POD 5188 /**< Location and Navigation Pod (Outdoor Sports Activity subtype). */
|
||||
/** @} */
|
||||
|
||||
/** @brief Set .type and .uuid fields of ble_uuid_struct to specified uuid value. */
|
||||
#define BLE_UUID_BLE_ASSIGN(instance, value) do {\
|
||||
instance.type = BLE_UUID_TYPE_BLE; \
|
||||
instance.uuid = value;} while(0)
|
||||
|
||||
/** @brief Copy type and uuid members from src to dst ble_uuid_t pointer. Both pointers must be valid/non-null. */
|
||||
#define BLE_UUID_COPY_PTR(dst, src) do {\
|
||||
(dst)->type = (src)->type; \
|
||||
(dst)->uuid = (src)->uuid;} while(0)
|
||||
|
||||
/** @brief Copy type and uuid members from src to dst ble_uuid_t struct. */
|
||||
#define BLE_UUID_COPY_INST(dst, src) do {\
|
||||
(dst).type = (src).type; \
|
||||
(dst).uuid = (src).uuid;} while(0)
|
||||
|
||||
/** @brief Compare for equality both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */
|
||||
#define BLE_UUID_EQ(p_uuid1, p_uuid2) \
|
||||
(((p_uuid1)->type == (p_uuid2)->type) && ((p_uuid1)->uuid == (p_uuid2)->uuid))
|
||||
|
||||
/** @brief Compare for difference both type and uuid members of two (valid, non-null) ble_uuid_t pointers. */
|
||||
#define BLE_UUID_NEQ(p_uuid1, p_uuid2) \
|
||||
(((p_uuid1)->type != (p_uuid2)->type) || ((p_uuid1)->uuid != (p_uuid2)->uuid))
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup BLE_TYPES_STRUCTURES Structures
|
||||
* @{ */
|
||||
|
||||
/** @brief 128 bit UUID values. */
|
||||
typedef struct
|
||||
{
|
||||
unsigned char uuid128[16];
|
||||
} ble_uuid128_t;
|
||||
|
||||
/** @brief Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t uuid; /**< 16-bit UUID value or octets 12-13 of 128-bit UUID. */
|
||||
uint8_t type; /**< UUID type, see @ref BLE_UUID_TYPES. If type is BLE_UUID_TYPE_UNKNOWN, the value of uuid is undefined. */
|
||||
} ble_uuid_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* BLE_TYPES_H__ */
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@defgroup nrf_error SoftDevice Global Error Codes
|
||||
@{
|
||||
|
||||
@brief Global Error definitions
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_ERROR_H__
|
||||
#define NRF_ERROR_H__
|
||||
|
||||
/** @defgroup NRF_ERRORS_BASE Error Codes Base number definitions
|
||||
* @{ */
|
||||
#define NRF_ERROR_BASE_NUM (0x0) ///< Global error base
|
||||
#define NRF_ERROR_SDM_BASE_NUM (0x1000) ///< SDM error base
|
||||
#define NRF_ERROR_SOC_BASE_NUM (0x2000) ///< SoC error base
|
||||
#define NRF_ERROR_STK_BASE_NUM (0x3000) ///< STK error base
|
||||
/** @} */
|
||||
|
||||
#define NRF_SUCCESS (NRF_ERROR_BASE_NUM + 0) ///< Successful command
|
||||
#define NRF_ERROR_SVC_HANDLER_MISSING (NRF_ERROR_BASE_NUM + 1) ///< SVC handler is missing
|
||||
#define NRF_ERROR_SOFTDEVICE_NOT_ENABLED (NRF_ERROR_BASE_NUM + 2) ///< SoftDevice has not been enabled
|
||||
#define NRF_ERROR_INTERNAL (NRF_ERROR_BASE_NUM + 3) ///< Internal Error
|
||||
#define NRF_ERROR_NO_MEM (NRF_ERROR_BASE_NUM + 4) ///< No Memory for operation
|
||||
#define NRF_ERROR_NOT_FOUND (NRF_ERROR_BASE_NUM + 5) ///< Not found
|
||||
#define NRF_ERROR_NOT_SUPPORTED (NRF_ERROR_BASE_NUM + 6) ///< Not supported
|
||||
#define NRF_ERROR_INVALID_PARAM (NRF_ERROR_BASE_NUM + 7) ///< Invalid Parameter
|
||||
#define NRF_ERROR_INVALID_STATE (NRF_ERROR_BASE_NUM + 8) ///< Invalid state, operation disallowed in this state
|
||||
#define NRF_ERROR_INVALID_LENGTH (NRF_ERROR_BASE_NUM + 9) ///< Invalid Length
|
||||
#define NRF_ERROR_INVALID_FLAGS (NRF_ERROR_BASE_NUM + 10) ///< Invalid Flags
|
||||
#define NRF_ERROR_INVALID_DATA (NRF_ERROR_BASE_NUM + 11) ///< Invalid Data
|
||||
#define NRF_ERROR_DATA_SIZE (NRF_ERROR_BASE_NUM + 12) ///< Data size exceeds limit
|
||||
#define NRF_ERROR_TIMEOUT (NRF_ERROR_BASE_NUM + 13) ///< Operation timed out
|
||||
#define NRF_ERROR_NULL (NRF_ERROR_BASE_NUM + 14) ///< Null Pointer
|
||||
#define NRF_ERROR_FORBIDDEN (NRF_ERROR_BASE_NUM + 15) ///< Forbidden Operation
|
||||
#define NRF_ERROR_INVALID_ADDR (NRF_ERROR_BASE_NUM + 16) ///< Bad Memory Address
|
||||
#define NRF_ERROR_BUSY (NRF_ERROR_BASE_NUM + 17) ///< Busy
|
||||
|
||||
#endif // NRF_ERROR_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@addtogroup nrf_sdm_api
|
||||
@{
|
||||
@defgroup nrf_sdm_error SoftDevice Manager Error Codes
|
||||
@{
|
||||
|
||||
@brief Error definitions for the SDM API
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_ERROR_SDM_H__
|
||||
#define NRF_ERROR_SDM_H__
|
||||
|
||||
#include "nrf_error.h"
|
||||
|
||||
#define NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN (NRF_ERROR_SDM_BASE_NUM + 0) ///< Unknown lfclk source
|
||||
#define NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION (NRF_ERROR_SDM_BASE_NUM + 1) ///< Incorrect interrupt configuration (can be caused by using illegal priority levels, or having enabled SoftDevice interrupts)
|
||||
#define NRF_ERROR_SDM_INCORRECT_CLENR0 (NRF_ERROR_SDM_BASE_NUM + 2) ///< Incorrect CLENR0 (can be caused by erronous SoftDevice flashing)
|
||||
|
||||
#endif // NRF_ERROR_SDM_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@addtogroup nrf_soc_api
|
||||
@{
|
||||
@defgroup nrf_soc_error SoC Library Error Codes
|
||||
@{
|
||||
|
||||
@brief Error definitions for the SoC library
|
||||
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_ERROR_SOC_H__
|
||||
#define NRF_ERROR_SOC_H__
|
||||
|
||||
#include "nrf_error.h"
|
||||
|
||||
/* Mutex Errors */
|
||||
#define NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN (NRF_ERROR_SOC_BASE_NUM + 0) ///< Mutex already taken
|
||||
|
||||
/* NVIC errors */
|
||||
#define NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE (NRF_ERROR_SOC_BASE_NUM + 1) ///< NVIC interrupt not available
|
||||
#define NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED (NRF_ERROR_SOC_BASE_NUM + 2) ///< NVIC interrupt priority not allowed
|
||||
#define NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 3) ///< NVIC should not return
|
||||
|
||||
/* Power errors */
|
||||
#define NRF_ERROR_SOC_POWER_MODE_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 4) ///< Power mode unknown
|
||||
#define NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN (NRF_ERROR_SOC_BASE_NUM + 5) ///< Power POF threshold unknown
|
||||
#define NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN (NRF_ERROR_SOC_BASE_NUM + 6) ///< Power off should not return
|
||||
|
||||
/* Rand errors */
|
||||
#define NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES (NRF_ERROR_SOC_BASE_NUM + 7) ///< RAND not enough values
|
||||
|
||||
/* PPI errors */
|
||||
#define NRF_ERROR_SOC_PPI_INVALID_CHANNEL (NRF_ERROR_SOC_BASE_NUM + 8) ///< Invalid PPI Channel
|
||||
#define NRF_ERROR_SOC_PPI_INVALID_GROUP (NRF_ERROR_SOC_BASE_NUM + 9) ///< Invalid PPI Group
|
||||
|
||||
#endif // NRF_ERROR_SOC_H__
|
||||
/**
|
||||
@}
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@defgroup nrf_mbr_api Master Boot Record API
|
||||
@{
|
||||
|
||||
@brief APIs for updating SoftDevice and BootLoader
|
||||
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_MBR_H__
|
||||
#define NRF_MBR_H__
|
||||
|
||||
#include "nrf_svc.h"
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
/** @addtogroup NRF_MBR_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@brief MBR SVC Base number. */
|
||||
#define MBR_SVC_BASE 0x18
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief nRF Master Boot Record API SVC numbers. */
|
||||
enum NRF_MBR_SVCS
|
||||
{
|
||||
SD_MBR_COMMAND = MBR_SVC_BASE, /**< ::sd_mbr_command */
|
||||
};
|
||||
|
||||
/**@brief Possible values for ::sd_mbr_command_t.command */
|
||||
enum NRF_MBR_COMMANDS
|
||||
{
|
||||
SD_MBR_COMMAND_COPY_BL, /**< Copy a new a new BootLoader. @see sd_mbr_command_copy_bl_t */
|
||||
SD_MBR_COMMAND_COPY_SD, /**< Copy a new SoftDevice. @see ::sd_mbr_command_copy_sd_t*/
|
||||
SD_MBR_COMMAND_INIT_SD, /**< Init forwarding interrupts to SD, and run reset function in SD*/
|
||||
SD_MBR_COMMAND_COMPARE, /**< This command works like memcmp. @see ::sd_mbr_command_compare_t*/
|
||||
SD_MBR_COMMAND_VECTOR_TABLE_BASE_SET, /**< Start forwarding all exception to this address @see ::sd_mbr_command_vector_table_base_set_t*/
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief This command copies part of a new SoftDevice
|
||||
* The destination area is erased before copying.
|
||||
* If dst is in the middle of a flash page, that whole flash page will be erased.
|
||||
* If (dst+len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* The user of this function is responsible for setting the PROTENSET registers.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of the memory blocks where copied correctly.
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates that the contents of the memory blocks where not verified correctly after copying.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *src; /**< Pointer to the source of data to be copied.*/
|
||||
uint32_t *dst; /**< Pointer to the destination where the content is to be copied.*/
|
||||
uint32_t len; /**< Number of 32 bit words to copy. Must be a multiple of 256 words*/
|
||||
}sd_mbr_command_copy_sd_t;
|
||||
|
||||
|
||||
/**@brief This command works like memcmp, but takes the length in words.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS indicates that the contents of both memory blocks are equal.
|
||||
* @retval ::NRF_ERROR_NULL indicates that the contents of the memory blocks are not equal.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *ptr1; /**< Pointer to block of memory */
|
||||
uint32_t *ptr2; /**< Pointer to block of memory */
|
||||
uint32_t len; /**< Number of 32 bit words to compare*/
|
||||
}sd_mbr_command_compare_t;
|
||||
|
||||
|
||||
/**@brief This command copies a new BootLoader.
|
||||
* With this command, destination of BootLoader is always the address written in NRF_UICR->BOOTADDR.
|
||||
*
|
||||
* Destination is erased by this function.
|
||||
* If (destination+bl_len) is in the middle of a flash page, that whole flash page will be erased.
|
||||
*
|
||||
* This function will use PROTENSET to protect the flash that is not intended to be written.
|
||||
*
|
||||
* On Success, this function will not return. It will start the new BootLoader from reset-vector as normal.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INVALID_STATE indicates that something was wrong.
|
||||
* @retval ::NRF_ERROR_INTERNAL indicates an internal error that should not happen.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN if NRF_UICR->BOOTADDR is not set
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH is invalid.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *bl_src; /**< Pointer to the source of the Bootloader to be be copied.*/
|
||||
uint32_t bl_len; /**< Number of 32 bit words to copy for BootLoader */
|
||||
}sd_mbr_command_copy_bl_t;
|
||||
|
||||
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the MBR
|
||||
*
|
||||
* Once this function has been called, this address is where the MBR will start to forward interrupts to after a reset.
|
||||
*
|
||||
* To restore default forwarding thiss function should be called with @param address set to 0.
|
||||
* The MBR will then start forwarding to interrupts to the adress in NFR_UICR->BOOTADDR or to the SoftDevice if the BOOTADDR is not set.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t address; /**< The base address of the interrupt vector table for forwarded interrupts.*/
|
||||
}sd_mbr_command_vector_table_base_set_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t command; /**< type of command to be issued see @ref NRF_MBR_COMMANDS. */
|
||||
union
|
||||
{
|
||||
sd_mbr_command_copy_sd_t copy_sd; /**< Parameters for copy*/
|
||||
sd_mbr_command_copy_bl_t copy_bl; /**< Parameters for copy SoftDevice and BootLoader*/
|
||||
sd_mbr_command_compare_t compare; /**< Parameters for verify*/
|
||||
sd_mbr_command_vector_table_base_set_t base_set; /**< Parameters for vector table base set.*/
|
||||
} params;
|
||||
}sd_mbr_command_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_MBR_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Issue Master Boot Record commands
|
||||
*
|
||||
* Commands used when updating a SoftDevice and bootloader
|
||||
*
|
||||
* @param[in] param Pointer to a struct describing the command
|
||||
*
|
||||
*@note for retvals see ::sd_mbr_command_copy_sd_t ::sd_mbr_command_copy_bl_t ::sd_mbr_command_compare_t
|
||||
|
||||
*/
|
||||
SVCALL(SD_MBR_COMMAND, uint32_t, sd_mbr_command(sd_mbr_command_t* param));
|
||||
|
||||
/** @} */
|
||||
#endif // NRF_MBR_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,167 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
/**
|
||||
@defgroup nrf_sdm_api SoftDevice Manager API
|
||||
@{
|
||||
|
||||
@brief APIs for SoftDevice management.
|
||||
|
||||
*/
|
||||
|
||||
/* Header guard */
|
||||
#ifndef NRF_SDM_H__
|
||||
#define NRF_SDM_H__
|
||||
|
||||
#include "nrf_svc.h"
|
||||
#include "nrf51.h"
|
||||
#include "nrf_soc.h"
|
||||
#include "nrf_error_sdm.h"
|
||||
|
||||
/** @addtogroup NRF_SDM_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@brief SoftDevice Manager SVC Base number. */
|
||||
#define SDM_SVC_BASE (0x10)
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SDM_ENUMS Enumerations
|
||||
* @{ */
|
||||
|
||||
/**@brief nRF SoftDevice Manager API SVC numbers. */
|
||||
enum NRF_SD_SVCS
|
||||
{
|
||||
SD_SOFTDEVICE_ENABLE = SDM_SVC_BASE, /**< ::sd_softdevice_enable */
|
||||
SD_SOFTDEVICE_DISABLE, /**< ::sd_softdevice_disable */
|
||||
SD_SOFTDEVICE_IS_ENABLED, /**< ::sd_softdevice_is_enabled */
|
||||
SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, /**< ::sd_softdevice_vector_table_base_set */
|
||||
SVC_SDM_LAST /**< Placeholder for last SDM SVC */
|
||||
};
|
||||
|
||||
/**@brief Possible lfclk oscillator sources. */
|
||||
enum NRF_CLOCK_LFCLKSRCS
|
||||
{
|
||||
NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM, /**< LFCLK Synthesized from HFCLK. */
|
||||
NRF_CLOCK_LFCLKSRC_XTAL_500_PPM, /**< LFCLK crystal oscillator 500 PPM accuracy. */
|
||||
NRF_CLOCK_LFCLKSRC_XTAL_250_PPM, /**< LFCLK crystal oscillator 250 PPM accuracy. */
|
||||
NRF_CLOCK_LFCLKSRC_XTAL_150_PPM, /**< LFCLK crystal oscillator 150 PPM accuracy. */
|
||||
NRF_CLOCK_LFCLKSRC_XTAL_100_PPM, /**< LFCLK crystal oscillator 100 PPM accuracy. */
|
||||
NRF_CLOCK_LFCLKSRC_XTAL_75_PPM, /**< LFCLK crystal oscillator 75 PPM accuracy. */
|
||||
NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, /**< LFCLK crystal oscillator 50 PPM accuracy. */
|
||||
NRF_CLOCK_LFCLKSRC_XTAL_30_PPM, /**< LFCLK crystal oscillator 30 PPM accuracy. */
|
||||
NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, /**< LFCLK crystal oscillator 20 PPM accuracy. */
|
||||
NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION, /**< LFCLK RC oscillator, 250ms calibration interval.*/
|
||||
NRF_CLOCK_LFCLKSRC_RC_250_PPM_500MS_CALIBRATION, /**< LFCLK RC oscillator, 500ms calibration interval.*/
|
||||
NRF_CLOCK_LFCLKSRC_RC_250_PPM_1000MS_CALIBRATION, /**< LFCLK RC oscillator, 1000ms calibration interval.*/
|
||||
NRF_CLOCK_LFCLKSRC_RC_250_PPM_2000MS_CALIBRATION, /**< LFCLK RC oscillator, 2000ms calibration interval.*/
|
||||
NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, /**< LFCLK RC oscillator, 4000ms calibration interval.*/
|
||||
NRF_CLOCK_LFCLKSRC_RC_250_PPM_8000MS_CALIBRATION, /**< LFCLK RC oscillator, 8000ms calibration interval.*/
|
||||
NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_1000MS_CALIBRATION, /**< LFCLK RC oscillator. Temperature checked every 1000ms, if changed above a threshold, a calibration is done.*/
|
||||
NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_2000MS_CALIBRATION, /**< LFCLK RC oscillator. Temperature checked every 2000ms, if changed above a threshold, a calibration is done.*/
|
||||
NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_4000MS_CALIBRATION, /**< LFCLK RC oscillator. Temperature checked every 4000ms, if changed above a threshold, a calibration is done.*/
|
||||
NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_8000MS_CALIBRATION, /**< LFCLK RC oscillator. Temperature checked every 8000ms, if changed above a threshold, a calibration is done.*/
|
||||
NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_16000MS_CALIBRATION, /**< LFCLK RC oscillator. Temperature checked every 16000ms, if changed above a threshold, a calibration is done.*/
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SDM_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief Type representing lfclk oscillator source. */
|
||||
typedef uint32_t nrf_clock_lfclksrc_t;
|
||||
|
||||
|
||||
/**@brief SoftDevice Assertion Handler type.
|
||||
*
|
||||
* When an unexpected error occurs within the SoftDevice it will call the SoftDevice assertion handler callback.
|
||||
* The protocol stack will be in an undefined state when this happens and the only way to recover will be to
|
||||
* perform a reset, using e.g. CMSIS NVIC_SystemReset().
|
||||
*
|
||||
* @note This callback is executed in HardFault context, thus SVC functions cannot be called from the SoftDevice assert callback.
|
||||
*
|
||||
* @param[in] pc The program counter of the failed assert.
|
||||
* @param[in] line_number Line number where the assert failed.
|
||||
* @param[in] file_name File name where the assert failed.
|
||||
*/
|
||||
typedef void (*softdevice_assertion_handler_t)(uint32_t pc, uint16_t line_number, const uint8_t * p_file_name);
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SDM_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Enables the SoftDevice and by extension the protocol stack.
|
||||
*
|
||||
* Idempotent function to enable the SoftDevice.
|
||||
*
|
||||
* @note Some care must be taken if a low frequency clock source is already running when calling this function:
|
||||
* If the LF clock has a different source then the one currently running, it will be stopped. Then, the new
|
||||
* clock source will be started.
|
||||
*
|
||||
* @note This function has no effect when returning with an error.
|
||||
*
|
||||
* @post If return code is ::NRF_SUCCESS
|
||||
* - SoC library and protocol stack APIs are made available
|
||||
* - A portion of RAM will be unavailable (see relevant SDS documentation)
|
||||
* - Some peripherals will be unavailable or available only through the SoC API (see relevant SDS documentation)
|
||||
* - Interrupts will not arrive from protected peripherals or interrupts
|
||||
* - nrf_nvic_ functions must be used instead of CMSIS NVIC_ functions for reliable usage of the softdevice.
|
||||
* - Interrupt latency may be affected by the SoftDevice (see relevant SDS documentation)
|
||||
* - Chosen low frequency clock source will be running
|
||||
*
|
||||
* @param clock_source Low frequency clock source and accuracy. (Note: In the case of XTAL source, the PPM accuracy of the chosen clock source must be greater than or equal to the actual characteristics of your XTAL clock).
|
||||
* @param assertion_handler Callback for SoftDevice assertions.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
* @retval ::NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION SoftDeviceinterrupt is already enabled, or an enabled interrupt has an illegal priority level
|
||||
* @retval ::NRF_ERROR_SDM_LFCLK_SOURCE_UNKNOWN Unknown low frequency clock source selected
|
||||
*/
|
||||
SVCALL(SD_SOFTDEVICE_ENABLE, uint32_t, sd_softdevice_enable(nrf_clock_lfclksrc_t clock_source, softdevice_assertion_handler_t assertion_handler));
|
||||
|
||||
/**@brief Disables the SoftDevice and by extension the protocol stack.
|
||||
*
|
||||
* Idempotent function to disable the SoftDevice.
|
||||
*
|
||||
* @post SoC library and protocol stack APIs are made unavailable.
|
||||
* @post All interrupts that was protected by the SoftDevice will be disabled and initialized to priority 0 (highest).
|
||||
* @post All peripherals used by the SoftDevice will be reset to default values.
|
||||
* @post All of RAM become available.
|
||||
* @post All interrupts are forwarded to the application.
|
||||
* @post LFCLK source chosen in ::sd_softdevice_enable will be left running.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_SOFTDEVICE_DISABLE, uint32_t, sd_softdevice_disable(void));
|
||||
|
||||
/**@brief Check if the SoftDevice is enabled.
|
||||
*
|
||||
* @param[out] p_softdevice_enabled If the SoftDevice is enabled: 1 else 0.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_SOFTDEVICE_IS_ENABLED, uint32_t, sd_softdevice_is_enabled(uint8_t * p_softdevice_enabled));
|
||||
|
||||
/**@brief Sets the base address of the interrupt vector table for interrupts forwarded from the SoftDevice
|
||||
*
|
||||
* This function is only intended to be called when a bootloader is enabled.
|
||||
*
|
||||
* @param[in] address The base address of the interrupt vector table for forwarded interrupts.
|
||||
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_SOFTDEVICE_VECTOR_TABLE_BASE_SET, uint32_t, sd_softdevice_vector_table_base_set(uint32_t address));
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif // NRF_SDM_H__
|
||||
|
||||
/**
|
||||
@}
|
||||
*/
|
||||
|
|
@ -1,958 +0,0 @@
|
|||
/* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup nrf_soc_api SoC Library API
|
||||
* @{
|
||||
*
|
||||
* @brief APIs for the SoC library.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NRF_SOC_H__
|
||||
#define NRF_SOC_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "nrf_svc.h"
|
||||
#include "nrf51.h"
|
||||
#include "nrf51_bitfields.h"
|
||||
#include "nrf_error_soc.h"
|
||||
|
||||
/** @addtogroup NRF_SOC_DEFINES Defines
|
||||
* @{ */
|
||||
|
||||
/**@brief The number of the lowest SVC number reserved for the SoC library. */
|
||||
#define SOC_SVC_BASE (0x20)
|
||||
#define SOC_SVC_BASE_NOT_AVAILABLE (0x23)
|
||||
|
||||
/**@brief Guranteed time for application to process radio inactive notification. */
|
||||
#define NRF_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US (62)
|
||||
|
||||
/**@brief The minimum allowed timeslot extension time. */
|
||||
#define NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US (200)
|
||||
|
||||
#define SOC_ECB_KEY_LENGTH (16) /**< ECB key length. */
|
||||
#define SOC_ECB_CLEARTEXT_LENGTH (16) /**< ECB cleartext length. */
|
||||
#define SOC_ECB_CIPHERTEXT_LENGTH (SOC_ECB_CLEARTEXT_LENGTH) /**< ECB ciphertext length. */
|
||||
|
||||
#define SD_EVT_IRQn (SWI2_IRQn) /**< SoftDevice Event IRQ number. Used for both protocol events and SoC events. */
|
||||
#define SD_EVT_IRQHandler (SWI2_IRQHandler) /**< SoftDevice Event IRQ handler. Used for both protocol events and SoC events. */
|
||||
#define RADIO_NOTIFICATION_IRQn (SWI1_IRQn) /**< The radio notification IRQ number. */
|
||||
#define RADIO_NOTIFICATION_IRQHandler (SWI1_IRQHandler) /**< The radio notification IRQ handler. */
|
||||
|
||||
#define NRF_RADIO_LENGTH_MIN_US (100) /**< The shortest allowed radio timeslot, in microseconds. */
|
||||
#define NRF_RADIO_LENGTH_MAX_US (100000) /**< The longest allowed radio timeslot, in microseconds. */
|
||||
|
||||
#define NRF_RADIO_DISTANCE_MAX_US (128000000UL - 1UL) /**< The longest timeslot distance, in microseconds, allowed for the distance parameter (see @ref nrf_radio_request_normal_t) in the request. */
|
||||
|
||||
#define NRF_RADIO_EARLIEST_TIMEOUT_MAX_US (128000000UL - 1UL) /**< The longest timeout, in microseconds, allowed when requesting the earliest possible timeslot. */
|
||||
|
||||
#define NRF_RADIO_START_JITTER_US (2) /**< The maximum jitter in NRF_RADIO_CALLBACK_SIGNAL_TYPE_START relative to the requested start time. */
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SOC_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief The SVC numbers used by the SVC functions in the SoC library. */
|
||||
enum NRF_SOC_SVCS
|
||||
{
|
||||
SD_FLASH_PAGE_ERASE = SOC_SVC_BASE,
|
||||
SD_FLASH_WRITE,
|
||||
SD_FLASH_PROTECT,
|
||||
SD_MUTEX_NEW = SOC_SVC_BASE_NOT_AVAILABLE,
|
||||
SD_MUTEX_ACQUIRE,
|
||||
SD_MUTEX_RELEASE,
|
||||
SD_NVIC_ENABLEIRQ,
|
||||
SD_NVIC_DISABLEIRQ,
|
||||
SD_NVIC_GETPENDINGIRQ,
|
||||
SD_NVIC_SETPENDINGIRQ,
|
||||
SD_NVIC_CLEARPENDINGIRQ,
|
||||
SD_NVIC_SETPRIORITY,
|
||||
SD_NVIC_GETPRIORITY,
|
||||
SD_NVIC_SYSTEMRESET,
|
||||
SD_NVIC_CRITICAL_REGION_ENTER,
|
||||
SD_NVIC_CRITICAL_REGION_EXIT,
|
||||
SD_RAND_APPLICATION_POOL_CAPACITY,
|
||||
SD_RAND_APPLICATION_BYTES_AVAILABLE,
|
||||
SD_RAND_APPLICATION_GET_VECTOR,
|
||||
SD_POWER_MODE_SET,
|
||||
SD_POWER_SYSTEM_OFF,
|
||||
SD_POWER_RESET_REASON_GET,
|
||||
SD_POWER_RESET_REASON_CLR,
|
||||
SD_POWER_POF_ENABLE,
|
||||
SD_POWER_POF_THRESHOLD_SET,
|
||||
SD_POWER_RAMON_SET,
|
||||
SD_POWER_RAMON_CLR,
|
||||
SD_POWER_RAMON_GET,
|
||||
SD_POWER_GPREGRET_SET,
|
||||
SD_POWER_GPREGRET_CLR,
|
||||
SD_POWER_GPREGRET_GET,
|
||||
SD_POWER_DCDC_MODE_SET,
|
||||
SD_APP_EVT_WAIT,
|
||||
SD_CLOCK_HFCLK_REQUEST,
|
||||
SD_CLOCK_HFCLK_RELEASE,
|
||||
SD_CLOCK_HFCLK_IS_RUNNING,
|
||||
SD_PPI_CHANNEL_ENABLE_GET,
|
||||
SD_PPI_CHANNEL_ENABLE_SET,
|
||||
SD_PPI_CHANNEL_ENABLE_CLR,
|
||||
SD_PPI_CHANNEL_ASSIGN,
|
||||
SD_PPI_GROUP_TASK_ENABLE,
|
||||
SD_PPI_GROUP_TASK_DISABLE,
|
||||
SD_PPI_GROUP_ASSIGN,
|
||||
SD_PPI_GROUP_GET,
|
||||
SD_RADIO_NOTIFICATION_CFG_SET,
|
||||
SD_ECB_BLOCK_ENCRYPT,
|
||||
SD_RADIO_SESSION_OPEN,
|
||||
SD_RADIO_SESSION_CLOSE,
|
||||
SD_RADIO_REQUEST,
|
||||
SD_EVT_GET,
|
||||
SD_TEMP_GET,
|
||||
SVC_SOC_LAST
|
||||
};
|
||||
|
||||
/**@brief Possible values of a ::nrf_mutex_t. */
|
||||
enum NRF_MUTEX_VALUES
|
||||
{
|
||||
NRF_MUTEX_FREE,
|
||||
NRF_MUTEX_TAKEN
|
||||
};
|
||||
|
||||
/**@brief Possible values of ::nrf_app_irq_priority_t. */
|
||||
enum NRF_APP_PRIORITIES
|
||||
{
|
||||
NRF_APP_PRIORITY_HIGH = 1,
|
||||
NRF_APP_PRIORITY_LOW = 3
|
||||
};
|
||||
|
||||
/**@brief Possible values of ::nrf_power_mode_t. */
|
||||
enum NRF_POWER_MODES
|
||||
{
|
||||
NRF_POWER_MODE_CONSTLAT, /**< Constant latency mode. See power management in the reference manual. */
|
||||
NRF_POWER_MODE_LOWPWR /**< Low power mode. See power management in the reference manual. */
|
||||
};
|
||||
|
||||
|
||||
/**@brief Possible values of ::nrf_power_failure_threshold_t */
|
||||
enum NRF_POWER_THRESHOLDS
|
||||
{
|
||||
NRF_POWER_THRESHOLD_V21, /**< 2.1 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLD_V23, /**< 2.3 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLD_V25, /**< 2.5 Volts power failure threshold. */
|
||||
NRF_POWER_THRESHOLD_V27 /**< 2.7 Volts power failure threshold. */
|
||||
};
|
||||
|
||||
|
||||
/**@brief Possible values of ::nrf_power_dcdc_mode_t. */
|
||||
enum NRF_POWER_DCDC_MODES
|
||||
{
|
||||
NRF_POWER_DCDC_MODE_OFF, /**< The DCDC is always off. */
|
||||
NRF_POWER_DCDC_MODE_ON, /**< The DCDC is always on. */
|
||||
NRF_POWER_DCDC_MODE_AUTOMATIC /**< The DCDC is automatically managed. */
|
||||
};
|
||||
|
||||
/**@brief Possible values of ::nrf_radio_notification_distance_t. */
|
||||
enum NRF_RADIO_NOTIFICATION_DISTANCES
|
||||
{
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_NONE = 0, /**< The event does not have a notification. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_800US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_1740US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_2680US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_3620US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_4560US, /**< The distance from the active notification to start of radio activity. */
|
||||
NRF_RADIO_NOTIFICATION_DISTANCE_5500US /**< The distance from the active notification to start of radio activity. */
|
||||
};
|
||||
|
||||
|
||||
/**@brief Possible values of ::nrf_radio_notification_type_t. */
|
||||
enum NRF_RADIO_NOTIFICATION_TYPES
|
||||
{
|
||||
NRF_RADIO_NOTIFICATION_TYPE_NONE = 0, /**< The event does not have a radio notification signal. */
|
||||
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE, /**< Using interrupt for notification when the radio will be enabled. */
|
||||
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE, /**< Using interrupt for notification when the radio has been disabled. */
|
||||
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, /**< Using interrupt for notification both when the radio will be enabled and disabled. */
|
||||
};
|
||||
|
||||
/**@brief SoC Events. */
|
||||
enum NRF_SOC_EVTS
|
||||
{
|
||||
NRF_EVT_HFCLKSTARTED, /**< Event indicating that the HFCLK has started. */
|
||||
NRF_EVT_POWER_FAILURE_WARNING, /**< Event indicating that a power failure warning has occurred. */
|
||||
NRF_EVT_FLASH_OPERATION_SUCCESS, /**< Event indicating that the ongoing flash operation has completed successfully. */
|
||||
NRF_EVT_FLASH_OPERATION_ERROR, /**< Event indicating that the ongoing flash operation has timed out with an error. */
|
||||
NRF_EVT_RADIO_BLOCKED, /**< Event indicating that a radio timeslot was blocked. */
|
||||
NRF_EVT_RADIO_CANCELED, /**< Event indicating that a radio timeslot was canceled by SoftDevice. */
|
||||
NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN, /**< Event indicating that a radio signal callback handler return was invalid. */
|
||||
NRF_EVT_RADIO_SESSION_IDLE, /**< Event indicating that a radio session is idle. */
|
||||
NRF_EVT_RADIO_SESSION_CLOSED, /**< Event indicating that a radio session is closed. */
|
||||
NRF_EVT_NUMBER_OF_EVTS
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SOC_TYPES Types
|
||||
* @{ */
|
||||
|
||||
/**@brief Represents a mutex for use with the nrf_mutex functions.
|
||||
* @note Accessing the value directly is not safe, use the mutex functions!
|
||||
*/
|
||||
typedef volatile uint8_t nrf_mutex_t;
|
||||
|
||||
/**@brief The interrupt priorities available to the application while the softdevice is active. */
|
||||
typedef uint8_t nrf_app_irq_priority_t;
|
||||
|
||||
/**@brief Represents a power mode, used in power mode functions */
|
||||
typedef uint8_t nrf_power_mode_t;
|
||||
|
||||
/**@brief Represents a power failure threshold value. */
|
||||
typedef uint8_t nrf_power_failure_threshold_t;
|
||||
|
||||
/**@brief Represents a DCDC mode value. */
|
||||
typedef uint32_t nrf_power_dcdc_mode_t;
|
||||
|
||||
/**@brief Radio notification distances. */
|
||||
typedef uint8_t nrf_radio_notification_distance_t;
|
||||
|
||||
/**@brief Radio notification types. */
|
||||
typedef uint8_t nrf_radio_notification_type_t;
|
||||
|
||||
/** @brief The Radio signal callback types. */
|
||||
enum NRF_RADIO_CALLBACK_SIGNAL_TYPE
|
||||
{
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_START, /**< This signal indicates the start of the radio timeslot. */
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0, /**< This signal indicates the NRF_TIMER0 interrupt. */
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO, /**< This signal indicates the NRF_RADIO interrupt. */
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_FAILED, /**< This signal indicates extend action failed. */
|
||||
NRF_RADIO_CALLBACK_SIGNAL_TYPE_EXTEND_SUCCEEDED /**< This signal indicates extend action succeeded. */
|
||||
};
|
||||
|
||||
/** @brief The actions requested by the signal callback.
|
||||
*
|
||||
* This code gives the SOC instructions about what action to take when the signal callback has
|
||||
* returned.
|
||||
*/
|
||||
enum NRF_RADIO_SIGNAL_CALLBACK_ACTION
|
||||
{
|
||||
NRF_RADIO_SIGNAL_CALLBACK_ACTION_NONE, /**< Return without action. */
|
||||
NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND, /**< Request an extension of the current timeslot (maximum execution time for this action is when the extension succeeded). */
|
||||
NRF_RADIO_SIGNAL_CALLBACK_ACTION_END, /**< End the current radio timeslot. */
|
||||
NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END /**< Request a new radio timeslot and end the current timeslot. */
|
||||
};
|
||||
|
||||
/**@brief Radio timeslot high frequency clock source configuration. */
|
||||
enum NRF_RADIO_HFCLK_CFG
|
||||
{
|
||||
NRF_RADIO_HFCLK_CFG_DEFAULT, /**< Use the currently selected oscillator as HF clock source during the timeslot (i.e. the source is not specified). */
|
||||
NRF_RADIO_HFCLK_CFG_FORCE_XTAL, /**< Force external crystal to be used as HF clock source during whole the timeslot. */
|
||||
};
|
||||
|
||||
/** @brief Radio timeslot priorities. */
|
||||
enum NRF_RADIO_PRIORITY
|
||||
{
|
||||
NRF_RADIO_PRIORITY_HIGH, /**< High (equal priority as the normal connection priority of the SoftDevice stack(s)). */
|
||||
NRF_RADIO_PRIORITY_NORMAL, /**< Normal (equal priority as the priority of secondary activites of the SoftDevice stack(s)). */
|
||||
};
|
||||
|
||||
/** @brief Radio timeslot request type. */
|
||||
enum NRF_RADIO_REQUEST_TYPE
|
||||
{
|
||||
NRF_RADIO_REQ_TYPE_EARLIEST, /**< Request timeslot as early as possible. This should always be used for the first request in a session. */
|
||||
NRF_RADIO_REQ_TYPE_NORMAL /**< Normal timeslot request. */
|
||||
};
|
||||
|
||||
/** @brief Parameters for a request for a timeslot as early as possible. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
|
||||
uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
|
||||
uint32_t length_us; /**< The radio timeslot length (in the range 100 to 100,000] microseconds). */
|
||||
uint32_t timeout_us; /**< Longest acceptable delay until the start of the requested timeslot (up to @ref NRF_RADIO_EARLIEST_TIMEOUT_MAX_US microseconds). */
|
||||
} nrf_radio_request_earliest_t;
|
||||
|
||||
/** @brief Parameters for a normal radio request. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t hfclk; /**< High frequency clock source, see @ref NRF_RADIO_HFCLK_CFG. */
|
||||
uint8_t priority; /**< The radio timeslot priority, see @ref NRF_RADIO_PRIORITY. */
|
||||
uint32_t distance_us; /**< Distance from the start of the previous radio timeslot (up to @ref NRF_RADIO_DISTANCE_MAX_US microseconds). */
|
||||
uint32_t length_us; /**< The radio timeslot length (in the range [100..100,000] microseconds). */
|
||||
} nrf_radio_request_normal_t;
|
||||
|
||||
/** @brief Radio request parameters. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t request_type; /**< Type of request, see @ref NRF_RADIO_REQUEST_TYPE. */
|
||||
union
|
||||
{
|
||||
nrf_radio_request_earliest_t earliest; /**< Parameters for a request for a timeslot as early as possible. */
|
||||
nrf_radio_request_normal_t normal; /**< Parameters for a normal radio request. */
|
||||
} params;
|
||||
} nrf_radio_request_t;
|
||||
|
||||
/**@brief Return parameters of the radio timeslot signal callback. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t callback_action; /**< The action requested by the application when returning from the signal callback, see @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION. */
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
nrf_radio_request_t * p_next; /**< The request parameters for the next radio timeslot. */
|
||||
} request; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_REQUEST_AND_END. */
|
||||
struct
|
||||
{
|
||||
uint32_t length_us; /**< Requested extension of the timeslot duration (microseconds) (for minimum time see @ref NRF_RADIO_MINIMUM_TIMESLOT_LENGTH_EXTENSION_TIME_US). */
|
||||
} extend; /**< Additional parameters for return_code @ref NRF_RADIO_SIGNAL_CALLBACK_ACTION_EXTEND. */
|
||||
} params;
|
||||
} nrf_radio_signal_callback_return_param_t;
|
||||
|
||||
/**@brief The radio signal callback type.
|
||||
*
|
||||
* @note In case of invalid return parameters, the radio timeslot will automatically end
|
||||
* immediately after returning from the signal callback and the
|
||||
* @ref NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN event will be sent.
|
||||
* @note The returned struct pointer must remain valid after the signal callback
|
||||
* function returns. For instance, this means that it must not point to a stack variable.
|
||||
*
|
||||
* @param[in] signal_type Type of signal, see @ref NRF_RADIO_CALLBACK_SIGNAL_TYPE.
|
||||
*
|
||||
* @return Pointer to structure containing action requested by the application.
|
||||
*/
|
||||
typedef nrf_radio_signal_callback_return_param_t * (*nrf_radio_signal_callback_t) (uint8_t signal_type);
|
||||
|
||||
/**@brief AES ECB data structure */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t key[SOC_ECB_KEY_LENGTH]; /**< Encryption key. */
|
||||
uint8_t cleartext[SOC_ECB_CLEARTEXT_LENGTH]; /**< Clear Text data. */
|
||||
uint8_t ciphertext[SOC_ECB_CIPHERTEXT_LENGTH]; /**< Cipher Text data. */
|
||||
} nrf_ecb_hal_data_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @addtogroup NRF_SOC_FUNCTIONS Functions
|
||||
* @{ */
|
||||
|
||||
/**@brief Initialize a mutex.
|
||||
*
|
||||
* @param[in] p_mutex Pointer to the mutex to initialize.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_MUTEX_NEW, uint32_t, sd_mutex_new(nrf_mutex_t * p_mutex));
|
||||
|
||||
/**@brief Attempt to acquire a mutex.
|
||||
*
|
||||
* @param[in] p_mutex Pointer to the mutex to acquire.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The mutex was successfully acquired.
|
||||
* @retval ::NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN The mutex could not be acquired.
|
||||
*/
|
||||
SVCALL(SD_MUTEX_ACQUIRE, uint32_t, sd_mutex_acquire(nrf_mutex_t * p_mutex));
|
||||
|
||||
/**@brief Release a mutex.
|
||||
*
|
||||
* @param[in] p_mutex Pointer to the mutex to release.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_MUTEX_RELEASE, uint32_t, sd_mutex_release(nrf_mutex_t * p_mutex));
|
||||
|
||||
/**@brief Enable External Interrupt.
|
||||
* @note Corresponds to NVIC_EnableIRQ in CMSIS.
|
||||
*
|
||||
* @pre{IRQn is valid and not reserved by the stack}
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_EnableIRQ documentation in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt was enabled.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt has a priority not available for the application.
|
||||
*/
|
||||
SVCALL(SD_NVIC_ENABLEIRQ, uint32_t, sd_nvic_EnableIRQ(IRQn_Type IRQn));
|
||||
|
||||
/**@brief Disable External Interrupt.
|
||||
* @note Corresponds to NVIC_DisableIRQ in CMSIS.
|
||||
*
|
||||
* @pre{IRQn is valid and not reserved by the stack}
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_DisableIRQ documentation in CMSIS
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt was disabled.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE The interrupt is not available for the application.
|
||||
*/
|
||||
SVCALL(SD_NVIC_DISABLEIRQ, uint32_t, sd_nvic_DisableIRQ(IRQn_Type IRQn));
|
||||
|
||||
/**@brief Get Pending Interrupt.
|
||||
* @note Corresponds to NVIC_GetPendingIRQ in CMSIS.
|
||||
*
|
||||
* @pre{IRQn is valid and not reserved by the stack}
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_GetPendingIRQ documentation in CMSIS.
|
||||
* @param[out] p_pending_irq Return value from NVIC_GetPendingIRQ.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt is available for the application.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
|
||||
*/
|
||||
SVCALL(SD_NVIC_GETPENDINGIRQ, uint32_t, sd_nvic_GetPendingIRQ(IRQn_Type IRQn, uint32_t * p_pending_irq));
|
||||
|
||||
/**@brief Set Pending Interrupt.
|
||||
* @note Corresponds to NVIC_SetPendingIRQ in CMSIS.
|
||||
*
|
||||
* @pre{IRQn is valid and not reserved by the stack}
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_SetPendingIRQ documentation in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt is set pending.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
|
||||
*/
|
||||
SVCALL(SD_NVIC_SETPENDINGIRQ, uint32_t, sd_nvic_SetPendingIRQ(IRQn_Type IRQn));
|
||||
|
||||
/**@brief Clear Pending Interrupt.
|
||||
* @note Corresponds to NVIC_ClearPendingIRQ in CMSIS.
|
||||
*
|
||||
* @pre{IRQn is valid and not reserved by the stack}
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_ClearPendingIRQ documentation in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt pending flag is cleared.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
|
||||
*/
|
||||
SVCALL(SD_NVIC_CLEARPENDINGIRQ, uint32_t, sd_nvic_ClearPendingIRQ(IRQn_Type IRQn));
|
||||
|
||||
/**@brief Set Interrupt Priority.
|
||||
* @note Corresponds to NVIC_SetPriority in CMSIS.
|
||||
*
|
||||
* @pre{IRQn is valid and not reserved by the stack}
|
||||
* @pre{priority is valid and not reserved by the stack}
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_SetPriority documentation in CMSIS.
|
||||
* @param[in] priority A valid IRQ priority for use by the application.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt and priority level is available for the application.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE IRQn is not available for the application.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_PRIORITY_NOT_ALLOWED The interrupt priority is not available for the application.
|
||||
*/
|
||||
SVCALL(SD_NVIC_SETPRIORITY, uint32_t, sd_nvic_SetPriority(IRQn_Type IRQn, nrf_app_irq_priority_t priority));
|
||||
|
||||
/**@brief Get Interrupt Priority.
|
||||
* @note Corresponds to NVIC_GetPriority in CMSIS.
|
||||
*
|
||||
* @pre{IRQn is valid and not reserved by the stack}
|
||||
*
|
||||
* @param[in] IRQn See the NVIC_GetPriority documentation in CMSIS.
|
||||
* @param[out] p_priority Return value from NVIC_GetPriority.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The interrupt priority is returned in p_priority.
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_INTERRUPT_NOT_AVAILABLE - IRQn is not available for the application.
|
||||
*/
|
||||
SVCALL(SD_NVIC_GETPRIORITY, uint32_t, sd_nvic_GetPriority(IRQn_Type IRQn, nrf_app_irq_priority_t * p_priority));
|
||||
|
||||
/**@brief System Reset.
|
||||
* @note Corresponds to NVIC_SystemReset in CMSIS.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_NVIC_SHOULD_NOT_RETURN
|
||||
*/
|
||||
SVCALL(SD_NVIC_SYSTEMRESET, uint32_t, sd_nvic_SystemReset(void));
|
||||
|
||||
/**@brief Enters critical region.
|
||||
*
|
||||
* @post Application interrupts will be disabled.
|
||||
* @sa sd_nvic_critical_region_exit
|
||||
*
|
||||
* @param[out] p_is_nested_critical_region 1: If in a nested critical region.
|
||||
* 0: Otherwise.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_NVIC_CRITICAL_REGION_ENTER, uint32_t, sd_nvic_critical_region_enter(uint8_t * p_is_nested_critical_region));
|
||||
|
||||
/**@brief Exit critical region.
|
||||
*
|
||||
* @pre Application has entered a critical region using ::sd_nvic_critical_region_enter.
|
||||
* @post If not in a nested critical region, the application interrupts will restored to the state before ::sd_nvic_critical_region_enter was called.
|
||||
*
|
||||
* @param[in] is_nested_critical_region If this is set to 1, the critical region won't be exited. @sa sd_nvic_critical_region_enter.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_NVIC_CRITICAL_REGION_EXIT, uint32_t, sd_nvic_critical_region_exit(uint8_t is_nested_critical_region));
|
||||
|
||||
/**@brief Query the capacity of the application random pool.
|
||||
*
|
||||
* @param[out] p_pool_capacity The capacity of the pool.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_RAND_APPLICATION_POOL_CAPACITY, uint32_t, sd_rand_application_pool_capacity_get(uint8_t * p_pool_capacity));
|
||||
|
||||
/**@brief Get number of random bytes available to the application.
|
||||
*
|
||||
* @param[out] p_bytes_available The number of bytes currently available in the pool.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_RAND_APPLICATION_BYTES_AVAILABLE, uint32_t, sd_rand_application_bytes_available_get(uint8_t * p_bytes_available));
|
||||
|
||||
/**@brief Get random bytes from the application pool.
|
||||
*
|
||||
* @param[out] p_buff Pointer to unit8_t buffer for storing the bytes.
|
||||
* @param[in] length Number of bytes to take from pool and place in p_buff.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The requested bytes were written to p_buff.
|
||||
* @retval ::NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES No bytes were written to the buffer, because there were not enough bytes available.
|
||||
*/
|
||||
SVCALL(SD_RAND_APPLICATION_GET_VECTOR, uint32_t, sd_rand_application_vector_get(uint8_t * p_buff, uint8_t length));
|
||||
|
||||
/**@brief Gets the reset reason register.
|
||||
*
|
||||
* @param[out] p_reset_reason Contents of the NRF_POWER->RESETREAS register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RESET_REASON_GET, uint32_t, sd_power_reset_reason_get(uint32_t * p_reset_reason));
|
||||
|
||||
/**@brief Clears the bits of the reset reason register.
|
||||
*
|
||||
* @param[in] reset_reason_clr_msk Contains the bits to clear from the reset reason register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RESET_REASON_CLR, uint32_t, sd_power_reset_reason_clr(uint32_t reset_reason_clr_msk));
|
||||
|
||||
/**@brief Sets the power mode when in CPU sleep.
|
||||
*
|
||||
* @param[in] power_mode The power mode to use when in CPU sleep. @sa sd_app_evt_wait
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The power mode was set.
|
||||
* @retval ::NRF_ERROR_SOC_POWER_MODE_UNKNOWN The power mode was unknown.
|
||||
*/
|
||||
SVCALL(SD_POWER_MODE_SET, uint32_t, sd_power_mode_set(nrf_power_mode_t power_mode));
|
||||
|
||||
/**@brief Puts the chip in System OFF mode.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_POWER_OFF_SHOULD_NOT_RETURN
|
||||
*/
|
||||
SVCALL(SD_POWER_SYSTEM_OFF, uint32_t, sd_power_system_off(void));
|
||||
|
||||
/**@brief Enables or disables the power-fail comparator.
|
||||
*
|
||||
* Enabling this will give a softdevice event (NRF_EVT_POWER_FAILURE_WARNING) when the power failure warning occurs.
|
||||
* The event can be retrieved with sd_evt_get();
|
||||
*
|
||||
* @param[in] pof_enable True if the power-fail comparator should be enabled, false if it should be disabled.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_POF_ENABLE, uint32_t, sd_power_pof_enable(uint8_t pof_enable));
|
||||
|
||||
/**@brief Sets the power-fail threshold value.
|
||||
*
|
||||
* @param[in] threshold The power-fail threshold value to use.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS The power failure threshold was set.
|
||||
* @retval ::NRF_ERROR_SOC_POWER_POF_THRESHOLD_UNKNOWN The power failure threshold is unknown.
|
||||
*/
|
||||
SVCALL(SD_POWER_POF_THRESHOLD_SET, uint32_t, sd_power_pof_threshold_set(nrf_power_failure_threshold_t threshold));
|
||||
|
||||
/**@brief Sets bits in the NRF_POWER->RAMON register.
|
||||
*
|
||||
* @param[in] ramon Contains the bits needed to be set in the NRF_POWER->RAMON register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RAMON_SET, uint32_t, sd_power_ramon_set(uint32_t ramon));
|
||||
|
||||
/** @brief Clears bits in the NRF_POWER->RAMON register.
|
||||
*
|
||||
* @param ramon Contains the bits needed to be cleared in the NRF_POWER->RAMON register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RAMON_CLR, uint32_t, sd_power_ramon_clr(uint32_t ramon));
|
||||
|
||||
/**@brief Get contents of NRF_POWER->RAMON register, indicates power status of ram blocks.
|
||||
*
|
||||
* @param[out] p_ramon Content of NRF_POWER->RAMON register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_RAMON_GET, uint32_t, sd_power_ramon_get(uint32_t * p_ramon));
|
||||
|
||||
/**@brief Set bits in the NRF_POWER->GPREGRET register.
|
||||
*
|
||||
* @param[in] gpregret_msk Bits to be set in the GPREGRET register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_GPREGRET_SET, uint32_t, sd_power_gpregret_set(uint32_t gpregret_msk));
|
||||
|
||||
/**@brief Clear bits in the NRF_POWER->GPREGRET register.
|
||||
*
|
||||
* @param[in] gpregret_msk Bits to be clear in the GPREGRET register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_GPREGRET_CLR, uint32_t, sd_power_gpregret_clr(uint32_t gpregret_msk));
|
||||
|
||||
/**@brief Get contents of the NRF_POWER->GPREGRET register.
|
||||
*
|
||||
* @param[out] p_gpregret Contents of the GPREGRET register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_POWER_GPREGRET_GET, uint32_t, sd_power_gpregret_get(uint32_t *p_gpregret));
|
||||
|
||||
/**@brief Sets the DCDC mode.
|
||||
*
|
||||
* Depending on the internal state of the SoftDevice, the mode change may not happen immediately.
|
||||
* The DCDC mode switch will be blocked when occurring in close proximity to radio transmissions. When
|
||||
* the radio transmission is done, the last mode will be used.
|
||||
*
|
||||
* @param[in] dcdc_mode The mode of the DCDC.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM The DCDC mode is invalid.
|
||||
*/
|
||||
SVCALL(SD_POWER_DCDC_MODE_SET, uint32_t, sd_power_dcdc_mode_set(nrf_power_dcdc_mode_t dcdc_mode));
|
||||
|
||||
/**@brief Request the high frequency crystal oscillator.
|
||||
*
|
||||
* Will start the high frequency crystal oscillator, the startup time of the crystal varies
|
||||
* and the ::sd_clock_hfclk_is_running function can be polled to check if it has started.
|
||||
*
|
||||
* @see sd_clock_hfclk_is_running
|
||||
* @see sd_clock_hfclk_release
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_CLOCK_HFCLK_REQUEST, uint32_t, sd_clock_hfclk_request(void));
|
||||
|
||||
/**@brief Releases the high frequency crystal oscillator.
|
||||
*
|
||||
* Will stop the high frequency crystal oscillator, this happens immediately.
|
||||
*
|
||||
* @see sd_clock_hfclk_is_running
|
||||
* @see sd_clock_hfclk_request
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_CLOCK_HFCLK_RELEASE, uint32_t, sd_clock_hfclk_release(void));
|
||||
|
||||
/**@brief Checks if the high frequency crystal oscillator is running.
|
||||
*
|
||||
* @see sd_clock_hfclk_request
|
||||
* @see sd_clock_hfclk_release
|
||||
*
|
||||
* @param[out] p_is_running 1 if the external crystal oscillator is running, 0 if not.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_CLOCK_HFCLK_IS_RUNNING, uint32_t, sd_clock_hfclk_is_running(uint32_t * p_is_running));
|
||||
|
||||
/**@brief Waits for an application event.
|
||||
*
|
||||
* An application event is either an application interrupt or a pended interrupt when the
|
||||
* interrupt is disabled. When the interrupt is enabled it will be taken immediately since
|
||||
* this function will wait in thread mode, then the execution will return in the application's
|
||||
* main thread. When an interrupt is disabled and gets pended it will return to the application's
|
||||
* thread main. The application must ensure that the pended flag is cleared using
|
||||
* ::sd_nvic_ClearPendingIRQ in order to sleep using this function. This is only necessary for
|
||||
* disabled interrupts, as the interrupt handler will clear the pending flag automatically for
|
||||
* enabled interrupts.
|
||||
*
|
||||
* In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M0
|
||||
* System Control Register (SCR). @sa CMSIS_SCB
|
||||
*
|
||||
* @note If an application interrupt has happened since the last time sd_app_evt_wait was
|
||||
* called this function will return immediately and not go to sleep. This is to avoid race
|
||||
* conditions that can occur when a flag is updated in the interrupt handler and processed
|
||||
* in the main loop.
|
||||
*
|
||||
* @post An application interrupt has happened or a interrupt pending flag is set.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void));
|
||||
|
||||
/**@brief Get PPI channel enable register contents.
|
||||
*
|
||||
* @param[out] p_channel_enable The contents of the PPI CHEN register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_CHANNEL_ENABLE_GET, uint32_t, sd_ppi_channel_enable_get(uint32_t * p_channel_enable));
|
||||
|
||||
/**@brief Set PPI channel enable register.
|
||||
*
|
||||
* @param[in] channel_enable_set_msk Mask containing the bits to set in the PPI CHEN register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_CHANNEL_ENABLE_SET, uint32_t, sd_ppi_channel_enable_set(uint32_t channel_enable_set_msk));
|
||||
|
||||
/**@brief Clear PPI channel enable register.
|
||||
*
|
||||
* @param[in] channel_enable_clr_msk Mask containing the bits to clear in the PPI CHEN register.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_CHANNEL_ENABLE_CLR, uint32_t, sd_ppi_channel_enable_clr(uint32_t channel_enable_clr_msk));
|
||||
|
||||
/**@brief Assign endpoints to a PPI channel.
|
||||
*
|
||||
* @param[in] channel_num Number of the PPI channel to assign.
|
||||
* @param[in] evt_endpoint Event endpoint of the PPI channel.
|
||||
* @param[in] task_endpoint Task endpoint of the PPI channel.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_CHANNEL The channel number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_CHANNEL_ASSIGN, uint32_t, sd_ppi_channel_assign(uint8_t channel_num, const volatile void * evt_endpoint, const volatile void * task_endpoint));
|
||||
|
||||
/**@brief Task to enable a channel group.
|
||||
*
|
||||
* @param[in] group_num Number of the channel group.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_GROUP_TASK_ENABLE, uint32_t, sd_ppi_group_task_enable(uint8_t group_num));
|
||||
|
||||
/**@brief Task to disable a channel group.
|
||||
*
|
||||
* @param[in] group_num Number of the PPI group.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_GROUP_TASK_DISABLE, uint32_t, sd_ppi_group_task_disable(uint8_t group_num));
|
||||
|
||||
/**@brief Assign PPI channels to a channel group.
|
||||
*
|
||||
* @param[in] group_num Number of the channel group.
|
||||
* @param[in] channel_msk Mask of the channels to assign to the group.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_GROUP_ASSIGN, uint32_t, sd_ppi_group_assign(uint8_t group_num, uint32_t channel_msk));
|
||||
|
||||
/**@brief Gets the PPI channels of a channel group.
|
||||
*
|
||||
* @param[in] group_num Number of the channel group.
|
||||
* @param[out] p_channel_msk Mask of the channels assigned to the group.
|
||||
*
|
||||
* @retval ::NRF_ERROR_SOC_PPI_INVALID_GROUP The group number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_PPI_GROUP_GET, uint32_t, sd_ppi_group_get(uint8_t group_num, uint32_t * p_channel_msk));
|
||||
|
||||
/**@brief Configures the Radio Notification signal.
|
||||
*
|
||||
* @note
|
||||
* - The notification signal latency depends on the interrupt priority settings of SWI used
|
||||
* for notification signal.
|
||||
* - In the period between the ACTIVE signal and the start of the Radio Event, the SoftDevice
|
||||
* will interrupt the application to do Radio Event preparation.
|
||||
* - Using the Radio Notification feature may limit the bandwidth, as the SoftDevice may have
|
||||
* to shorten the connection events to have time for the Radio Notification signals.
|
||||
*
|
||||
* @param[in] type Type of notification signal.
|
||||
* @ref NRF_RADIO_NOTIFICATION_TYPE_NONE shall be used to turn off radio
|
||||
* notification. Using @ref NRF_RADIO_NOTIFICATION_DISTANCE_NONE is
|
||||
* recommended (but not required) to be used with
|
||||
* @ref NRF_RADIO_NOTIFICATION_TYPE_NONE.
|
||||
*
|
||||
* @param[in] distance Distance between the notification signal and start of radio activity.
|
||||
* This parameter is ignored when @ref NRF_RADIO_NOTIFICATION_TYPE_NONE or
|
||||
* @ref NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE is used.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM The group number is invalid.
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_RADIO_NOTIFICATION_CFG_SET, uint32_t, sd_radio_notification_cfg_set(nrf_radio_notification_type_t type, nrf_radio_notification_distance_t distance));
|
||||
|
||||
/**@brief Encrypts a block according to the specified parameters.
|
||||
*
|
||||
* 128-bit AES encryption.
|
||||
*
|
||||
* @param[in, out] p_ecb_data Pointer to the ECB parameters' struct (two input
|
||||
* parameters and one output parameter).
|
||||
*
|
||||
* @retval ::NRF_SUCCESS
|
||||
*/
|
||||
SVCALL(SD_ECB_BLOCK_ENCRYPT, uint32_t, sd_ecb_block_encrypt(nrf_ecb_hal_data_t * p_ecb_data));
|
||||
|
||||
/**@brief Gets any pending events generated by the SoC API.
|
||||
*
|
||||
* The application should keep calling this function to get events, until ::NRF_ERROR_NOT_FOUND is returned.
|
||||
*
|
||||
* @param[out] p_evt_id Set to one of the values in @ref NRF_SOC_EVTS, if any events are pending.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS An event was pending. The event id is written in the p_evt_id parameter.
|
||||
* @retval ::NRF_ERROR_NOT_FOUND No pending events.
|
||||
*/
|
||||
SVCALL(SD_EVT_GET, uint32_t, sd_evt_get(uint32_t * p_evt_id));
|
||||
|
||||
/**@brief Get the temperature measured on the chip
|
||||
*
|
||||
* This function will block until the temperature measurement is done.
|
||||
* It takes around 50us from call to return.
|
||||
*
|
||||
* @note Pan #28 in PAN-028 v 1.6 "Negative measured values are not represented correctly" is corrected by this function.
|
||||
*
|
||||
* @param[out] p_temp Result of temperature measurement. Die temperature in 0.25 degrees celsius.
|
||||
*
|
||||
* @retval ::NRF_SUCCESS A temperature measurement was done, and the temperature was written to temp
|
||||
*/
|
||||
SVCALL(SD_TEMP_GET, uint32_t, sd_temp_get(int32_t * p_temp));
|
||||
|
||||
/**@brief Flash Write
|
||||
*
|
||||
* Commands to write a buffer to flash
|
||||
*
|
||||
* This call initiates the flash access command, and its completion will be communicated to the
|
||||
* application with exactly one of the following events:
|
||||
* - NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
|
||||
* - NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
|
||||
*
|
||||
* @note
|
||||
* - This call takes control over the radio and the CPU during flash erase and write to make sure that
|
||||
* they will not interfere with the flash access. This means that all interrupts will be blocked
|
||||
* for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual
|
||||
* and the command parameters).
|
||||
*
|
||||
*
|
||||
* @param[in] p_dst Pointer to start of flash location to be written.
|
||||
* @param[in] p_src Pointer to buffer with data to be written
|
||||
* @param[in] size Number of 32-bit words to write. Maximum size is 256 32bit words.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Tried to write to a non existing flash address, or p_dst or p_src was unaligned.
|
||||
* @retval ::NRF_ERROR_BUSY The previous command has not yet completed.
|
||||
* @retval ::NRF_ERROR_INVALID_LENGTH Size was 0, or more than 256 words.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Tried to write to or read from protected location.
|
||||
* @retval ::NRF_SUCCESS The command was accepted.
|
||||
*/
|
||||
SVCALL(SD_FLASH_WRITE, uint32_t, sd_flash_write(uint32_t * const p_dst, uint32_t const * const p_src, uint32_t size));
|
||||
|
||||
|
||||
/**@brief Flash Erase page
|
||||
*
|
||||
* Commands to erase a flash page
|
||||
*
|
||||
* This call initiates the flash access command, and its completion will be communicated to the
|
||||
* application with exactly one of the following events:
|
||||
* - NRF_EVT_FLASH_OPERATION_SUCCESS - The command was successfully completed.
|
||||
* - NRF_EVT_FLASH_OPERATION_ERROR - The command could not be started.
|
||||
*
|
||||
* @note
|
||||
* - This call takes control over the radio and the CPU during flash erase and write to make sure that
|
||||
* they will not interfere with the flash access. This means that all interrupts will be blocked
|
||||
* for a predictable time (depending on the NVMC specification in nRF51 Series Reference Manual
|
||||
* and the command parameters).
|
||||
*
|
||||
*
|
||||
* @param[in] page_number Pagenumber of the page to erase
|
||||
* @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR Tried to erase to a non existing flash page.
|
||||
* @retval ::NRF_ERROR_BUSY The previous command has not yet completed.
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Tried to erase a protected page.
|
||||
* @retval ::NRF_SUCCESS The command was accepted.
|
||||
*/
|
||||
SVCALL(SD_FLASH_PAGE_ERASE, uint32_t, sd_flash_page_erase(uint32_t page_number));
|
||||
|
||||
|
||||
/**@brief Flash Protection set
|
||||
*
|
||||
* Commands to set the flash protection registers PROTENSETx
|
||||
*
|
||||
* @note To read the values in PROTENSETx you can read them directly. They are only write-protected.
|
||||
*
|
||||
* @param[in] protenset0 Value to be written to PROTENSET0
|
||||
* @param[in] protenset1 Value to be written to PROTENSET1
|
||||
*
|
||||
* @retval ::NRF_ERROR_FORBIDDEN Tried to protect the SoftDevice
|
||||
* @retval ::NRF_SUCCESS Values successfully written to PROTENSETx
|
||||
*/
|
||||
SVCALL(SD_FLASH_PROTECT, uint32_t, sd_flash_protect(uint32_t protenset0, uint32_t protenset1));
|
||||
|
||||
/**@brief Opens a session for radio requests.
|
||||
*
|
||||
* @note Only one session can be open at a time.
|
||||
* @note p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) will be called when the radio timeslot
|
||||
* starts. From this point the NRF_RADIO and NRF_TIMER0 peripherals can be freely accessed
|
||||
* by the application.
|
||||
* @note p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_TIMER0) is called whenever the NRF_TIMER0
|
||||
* interrupt occurs.
|
||||
* @note p_radio_signal_callback(NRF_RADIO_CALLBACK_SIGNAL_TYPE_RADIO) is called whenever the NRF_RADIO
|
||||
* interrupt occurs.
|
||||
* @note p_radio_signal_callback() will be called at ARM interrupt priority level 0. This
|
||||
* implies that none of the sd_* API calls can be used from p_radio_signal_callback().
|
||||
*
|
||||
* @param[in] p_radio_signal_callback The signal callback.
|
||||
*
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR p_radio_signal_callback is an invalid function pointer.
|
||||
* @retval ::NRF_ERROR_BUSY If session cannot be opened.
|
||||
* @retval ::NRF_ERROR_INTERNAL If a new session could not be opened due to an internal error.
|
||||
* @retval ::NRF_SUCCESS Otherwise.
|
||||
*/
|
||||
SVCALL(SD_RADIO_SESSION_OPEN, uint32_t, sd_radio_session_open(nrf_radio_signal_callback_t p_radio_signal_callback));
|
||||
|
||||
/**@brief Closes a session for radio requests.
|
||||
*
|
||||
* @note Any current radio timeslot will be finished before the session is closed.
|
||||
* @note If a radio timeslot is scheduled when the session is closed, it will be canceled.
|
||||
* @note The application cannot consider the session closed until the NRF_EVT_RADIO_SESSION_CLOSED
|
||||
* event is received.
|
||||
*
|
||||
* @retval ::NRF_ERROR_FORBIDDEN If session not opened.
|
||||
* @retval ::NRF_ERROR_BUSY If session is currently being closed.
|
||||
* @retval ::NRF_SUCCESS Otherwise.
|
||||
*/
|
||||
SVCALL(SD_RADIO_SESSION_CLOSE, uint32_t, sd_radio_session_close(void));
|
||||
|
||||
/**@brief Requests a radio timeslot.
|
||||
*
|
||||
* @note The timing of the radio timeslot is specified by p_request->distance_us. For the first
|
||||
* request in a session, p_request->distance_us is required to be 0 by convention, and
|
||||
* the timeslot is scheduled at the first possible opportunity. All following radio timeslots are
|
||||
* requested with a distance of p_request->distance_us measured from the start of the
|
||||
* previous radio timeslot.
|
||||
* @note A too small p_request->distance_us will lead to a NRF_EVT_RADIO_BLOCKED event.
|
||||
* @note Timeslots scheduled too close will lead to a NRF_EVT_RADIO_BLOCKED event.
|
||||
* @note See the SoftDevice Specification for more on radio timeslot scheduling, distances and lengths.
|
||||
* @note If an opportunity for the first radio timeslot is not found before 100ms after the call to this
|
||||
* function, it is not scheduled, and instead a NRF_EVT_RADIO_BLOCKED event is sent.
|
||||
* The application may then try to schedule the first radio timeslot again.
|
||||
* @note Successful requests will result in nrf_radio_signal_callback_t(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START).
|
||||
* Unsuccessful requests will result in a NRF_EVT_RADIO_BLOCKED event, see @ref NRF_SOC_EVTS.
|
||||
* @note The jitter in the start time of the radio timeslots is +/- NRF_RADIO_START_JITTER_US us.
|
||||
* @note The nrf_radio_signal_callback_t(NRF_RADIO_CALLBACK_SIGNAL_TYPE_START) call has a latency relative to the
|
||||
* specified radio timeslot start, but this does not affect the actual start time of the timeslot.
|
||||
* @note NRF_TIMER0 is reset at the start of the radio timeslot, and is clocked at 1MHz from the high frequency
|
||||
* (16 MHz) clock source. If p_request->hfclk_force_xtal is true, the high frequency clock is
|
||||
* guaranteed to be clocked from the external crystal.
|
||||
* @note The SoftDevice will neither access the NRF_RADIO peripheral nor the NRF_TIMER0 peripheral
|
||||
* during the radio timeslot.
|
||||
*
|
||||
* @param[in] p_request Pointer to the request parameters.
|
||||
*
|
||||
* @retval ::NRF_ERROR_FORBIDDEN If session not opened or the session is not IDLE.
|
||||
* @retval ::NRF_ERROR_INVALID_ADDR If the p_request pointer is invalid.
|
||||
* @retval ::NRF_ERROR_INVALID_PARAM If the parameters of p_request are not valid.
|
||||
* @retval ::NRF_SUCCESS Otherwise.
|
||||
*/
|
||||
SVCALL(SD_RADIO_REQUEST, uint32_t, sd_radio_request(nrf_radio_request_t * p_request ));
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif // NRF_SOC_H__
|
||||
|
||||
/**@} */
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef NRF_SVC__
|
||||
#define NRF_SVC__
|
||||
|
||||
#ifdef SVCALL_AS_NORMAL_FUNCTION
|
||||
#define SVCALL(number, return_type, signature) return_type signature
|
||||
#else
|
||||
|
||||
#ifndef SVCALL
|
||||
#if defined (__CC_ARM)
|
||||
#define SVCALL(number, return_type, signature) return_type __svc(number) signature
|
||||
#elif defined (__GNUC__)
|
||||
#define SVCALL(number, return_type, signature) \
|
||||
_Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wunused-function\"") \
|
||||
__attribute__((naked)) static return_type signature \
|
||||
{ \
|
||||
__asm( \
|
||||
"svc %0\n" \
|
||||
"bx r14" : : "I" ((uint32_t)number) : "r0" \
|
||||
); \
|
||||
}
|
||||
#elif defined (__ICCARM__)
|
||||
#define PRAGMA(x) _Pragma(#x)
|
||||
#define SVCALL(number, return_type, signature) \
|
||||
PRAGMA(swi_number = number) \
|
||||
__swi return_type signature;
|
||||
#else
|
||||
#define SVCALL(number, return_type, signature) return_type signature
|
||||
#endif
|
||||
#endif // SVCALL
|
||||
|
||||
#endif // SVCALL_AS_NORMAL_FUNCTION
|
||||
#endif // NRF_SVC__
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2012 Nordic Semiconductor. All Rights Reserved.
|
||||
*
|
||||
* The information contained herein is confidential property of Nordic Semiconductor. The use,
|
||||
* copying, transfer or disclosure of such information is prohibited except by express written
|
||||
* agreement with Nordic Semiconductor.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @brief Utilities for verifying program logic
|
||||
*/
|
||||
|
||||
#ifndef SOFTDEVICE_ASSERT_H_
|
||||
#define SOFTDEVICE_ASSERT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** @brief This function handles assertions.
|
||||
*
|
||||
*
|
||||
* @note
|
||||
* This function is called when an assertion has triggered.
|
||||
*
|
||||
*
|
||||
* @param line_num The line number where the assertion is called
|
||||
* @param file_name Pointer to the file name
|
||||
*/
|
||||
void assert_softdevice_callback(uint16_t line_num, const uint8_t *file_name);
|
||||
|
||||
|
||||
/*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */
|
||||
/*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \
|
||||
/** @brief Check intended for production code
|
||||
*
|
||||
* Check passes if "expr" evaluates to true. */
|
||||
#define ASSERT(expr) \
|
||||
if (expr) \
|
||||
{ \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
assert_softdevice_callback((uint16_t)__LINE__, (uint8_t *)__FILE__); \
|
||||
/*lint -unreachable */ \
|
||||
}
|
||||
|
||||
#endif /* SOFTDEVICE_ASSERT_H_ */
|
||||
Binary file not shown.
|
|
@ -1,16 +0,0 @@
|
|||
s110_nrf51822_7.1.0
|
||||
|
||||
This release consists of the following:
|
||||
- This readme file
|
||||
- The s110_nrf51822_7.1.0 license
|
||||
- The s110_nrf51822_7.1.0 softdevice (binary hex file)
|
||||
- The s110_nrf51822_7.1.0 API (softdevice header files)
|
||||
- The s110_nrf51822_7.1.0 release notes
|
||||
|
||||
|
||||
IMPORTANT NOTE:
|
||||
If you intend to use the CPU unlock feature of this relase, replace
|
||||
the header files in the SDK (nRF51 SDK version 6.0.0) with the header
|
||||
files in this release.
|
||||
Otherwise, you may continue to use the header files already installed
|
||||
as part of the nRF51 SDK versions 6.0.0.
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -77,9 +77,8 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
|
|||
pinmap_pinout(pin, PinMap_PWM);
|
||||
LPC_SCT0_Type* pwm = obj->pwm;
|
||||
|
||||
// Two 16-bit counters, autolimit
|
||||
pwm->CONFIG &= ~(0x1);
|
||||
pwm->CONFIG |= (1 << 17);
|
||||
// Unified 32-bit counter, autolimit
|
||||
pwm->CONFIG |= ((0x3 << 17) | 0x01);
|
||||
|
||||
// halt and clear the counter
|
||||
pwm->CTRL |= (1 << 2) | (1 << 3);
|
||||
|
|
@ -170,8 +169,8 @@ void pwmout_period_us(pwmout_t* obj, int us) {
|
|||
uint32_t t_off = obj->pwm->MATCHREL0;
|
||||
uint32_t t_on = obj->pwm->MATCHREL1;
|
||||
float v = (float)t_on/(float)t_off;
|
||||
obj->pwm->MATCHREL0 = (uint64_t)us;
|
||||
obj->pwm->MATCHREL1 = (uint64_t)((float)us * (float)v);
|
||||
obj->pwm->MATCHREL0 = (uint32_t)us;
|
||||
obj->pwm->MATCHREL1 = (uint32_t)((float)us * (float)v);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth(pwmout_t* obj, float seconds) {
|
||||
|
|
@ -183,7 +182,7 @@ void pwmout_pulsewidth_ms(pwmout_t* obj, int ms) {
|
|||
}
|
||||
|
||||
void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
|
||||
obj->pwm->MATCHREL1 = (uint64_t)us;
|
||||
obj->pwm->MATCHREL1 = (uint32_t)us;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -59,33 +59,32 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
|
|||
LPC_SYSCON->PRESETCTRL1 &= ~(1 << (obj->pwm_ch + 2));
|
||||
|
||||
switch(obj->pwm_ch) {
|
||||
case 0:
|
||||
case 0:
|
||||
// SCT0_OUT0
|
||||
LPC_SWM->PINASSIGN[7] &= ~0x0000FF00;
|
||||
LPC_SWM->PINASSIGN[7] |= (pin << 8);
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 1:
|
||||
// SCT1_OUT0
|
||||
LPC_SWM->PINASSIGN[8] &= ~0x000000FF;
|
||||
LPC_SWM->PINASSIGN[8] |= (pin);
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 2:
|
||||
// SCT2_OUT0
|
||||
LPC_SWM->PINASSIGN[8] &= ~0xFF000000;
|
||||
LPC_SWM->PINASSIGN[8] |= (pin << 24);
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 3:
|
||||
// SCT3_OUT0
|
||||
LPC_SWM->PINASSIGN[9] &= ~0x00FF0000;
|
||||
LPC_SWM->PINASSIGN[9] |= (pin << 16);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Two 16-bit counters, autolimit
|
||||
pwm->CONFIG &= ~(0x1);
|
||||
pwm->CONFIG |= (1 << 17);
|
||||
// Unified 32-bit counter, autolimit
|
||||
pwm->CONFIG |= ((0x3 << 17) | 0x01);
|
||||
|
||||
// halt and clear the counter
|
||||
pwm->CTRL |= (1 << 2) | (1 << 3);
|
||||
|
|
@ -101,10 +100,10 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
|
|||
pwm->OUT0_SET = (1 << 0); // event 0
|
||||
pwm->OUT0_CLR = (1 << 1); // event 1
|
||||
|
||||
pwm->EV0_CTRL = (1 << 12);
|
||||
pwm->EV0_STATE = 0xFFFFFFFF;
|
||||
pwm->EV1_CTRL = (1 << 12) | (1 << 0);
|
||||
pwm->EV1_STATE = 0xFFFFFFFF;
|
||||
pwm->EV0_CTRL = (1 << 12);
|
||||
pwm->EV0_STATE = 0xFFFFFFFF;
|
||||
pwm->EV1_CTRL = (1 << 12) | (1 << 0);
|
||||
pwm->EV1_STATE = 0xFFFFFFFF;
|
||||
|
||||
// unhalt the counter:
|
||||
// - clearing bit 2 of the CTRL register
|
||||
|
|
@ -135,7 +134,7 @@ void pwmout_write(pwmout_t* obj, float value) {
|
|||
float pwmout_read(pwmout_t* obj) {
|
||||
uint32_t t_off = obj->pwm->MATCHREL0;
|
||||
uint32_t t_on = obj->pwm->MATCHREL1;
|
||||
float v = (float)t_on/(float)t_off;
|
||||
float v = (float)t_on/(float)t_off;
|
||||
return (v > 1.0f) ? (1.0f) : (v);
|
||||
}
|
||||
|
||||
|
|
@ -152,9 +151,9 @@ void pwmout_period_us(pwmout_t* obj, int us) {
|
|||
LPC_SCT0_Type* pwm = obj->pwm;
|
||||
uint32_t t_off = pwm->MATCHREL0;
|
||||
uint32_t t_on = pwm->MATCHREL1;
|
||||
float v = (float)t_on/(float)t_off;
|
||||
pwm->MATCHREL0 = (uint64_t)us;
|
||||
pwm->MATCHREL1 = (uint64_t)((float)us * (float)v);
|
||||
float v = (float)t_on/(float)t_off;
|
||||
pwm->MATCHREL0 = (uint32_t)us;
|
||||
pwm->MATCHREL1 = (uint32_t)((float)us * (float)v);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth(pwmout_t* obj, float seconds) {
|
||||
|
|
@ -166,6 +165,6 @@ void pwmout_pulsewidth_ms(pwmout_t* obj, int ms) {
|
|||
}
|
||||
|
||||
void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
|
||||
obj->pwm->MATCHREL1 = (uint64_t)us;
|
||||
obj->pwm->MATCHREL1 = (uint32_t)us;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,22 +72,23 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
|
|||
LPC_SYSCON->PRESETCTRL |= (1 << 8);
|
||||
|
||||
// Two 16-bit counters, autolimit (ie reset on Match_0)
|
||||
pwm->CONFIG &= ~(0x1);
|
||||
pwm->CONFIG |= (1 << 17);
|
||||
//pwm->CONFIG &= ~(0x1);
|
||||
//pwm->CONFIG |= (1 << 17);
|
||||
pwm->CONFIG |= ((0x3 << 17) | 0x01);
|
||||
|
||||
// halt and clear the counter
|
||||
pwm->CTRL_L |= (1 << 2) | (1 << 3);
|
||||
pwm->CTRL_U |= (1 << 2) | (1 << 3);
|
||||
|
||||
// System Clock (30 Mhz) -> Prescaler -> us_ticker (1 MHz)
|
||||
pwm->CTRL_L &= ~(0x7F << 5);
|
||||
pwm->CTRL_L |= (((SystemCoreClock/1000000 - 1) & 0x7F) << 5);
|
||||
pwm->CTRL_U &= ~(0x7F << 5);
|
||||
pwm->CTRL_U |= (((SystemCoreClock/1000000 - 1) & 0x7F) << 5);
|
||||
|
||||
pwm->EVENT[0].CTRL = (1 << 12) | 0; // Event_0 on Match_0
|
||||
pwm->EVENT[0].STATE = 0xFFFFFFFF; // All states
|
||||
|
||||
// unhalt the counter:
|
||||
// - clearing bit 2 of the CTRL register
|
||||
pwm->CTRL_L &= ~(1 << 2);
|
||||
pwm->CTRL_U &= ~(1 << 2);
|
||||
|
||||
// Not using IRQs
|
||||
//NVIC_SetVector(PWM_IRQn, (uint32_t)pwm_irq_handler);
|
||||
|
|
@ -154,20 +155,20 @@ void pwmout_write(pwmout_t* obj, float value) {
|
|||
}
|
||||
|
||||
// Match_0 is PWM period. Compute new endtime of pulse for current channel
|
||||
uint32_t t_off = (uint32_t)((float)(obj->pwm->MATCHREL[0].L) * value);
|
||||
obj->pwm->MATCHREL[(obj->pwm_ch) + 1].L = t_off; // New endtime
|
||||
uint32_t t_off = (uint32_t)((float)(obj->pwm->MATCHREL[0].U) * value);
|
||||
obj->pwm->MATCHREL[(obj->pwm_ch) + 1].U = t_off; // New endtime
|
||||
}
|
||||
|
||||
// Get dutycycle (0.0 .. 1.0)
|
||||
float pwmout_read(pwmout_t* obj) {
|
||||
uint32_t t_period = obj->pwm->MATCHREL[0].L;
|
||||
uint32_t t_period = obj->pwm->MATCHREL[0].U;
|
||||
|
||||
//Sanity check
|
||||
if (t_period == 0) {
|
||||
return 0.0;
|
||||
};
|
||||
|
||||
uint32_t t_off = obj->pwm->MATCHREL[(obj->pwm_ch) + 1].L;
|
||||
uint32_t t_off = obj->pwm->MATCHREL[(obj->pwm_ch) + 1].U;
|
||||
float v = (float)t_off/(float)t_period;
|
||||
//Sanity check
|
||||
return (v > 1.0f) ? (1.0f) : (v);
|
||||
|
|
@ -186,8 +187,8 @@ void pwmout_period_ms(pwmout_t* obj, int ms) {
|
|||
// Set the PWM period, keeping the duty cycle the same (for this channel only!).
|
||||
void pwmout_period_us(pwmout_t* obj, int us) {
|
||||
|
||||
uint32_t t_period = obj->pwm->MATCHREL[0].L; // Current PWM period
|
||||
obj->pwm->MATCHREL[0].L = (uint64_t)us; // New PWM period
|
||||
uint32_t t_period = obj->pwm->MATCHREL[0].U; // Current PWM period
|
||||
obj->pwm->MATCHREL[0].U = (uint32_t)us; // New PWM period
|
||||
|
||||
//Keep the dutycycle for the new PWM period
|
||||
//Should really do this for all active channels!!
|
||||
|
|
@ -199,9 +200,9 @@ void pwmout_period_us(pwmout_t* obj, int us) {
|
|||
// obj->pwm->MATCHREL[(obj->pwm_ch) + 1].L = 0; // New endtime for this channel
|
||||
}
|
||||
else {
|
||||
uint32_t t_off = obj->pwm->MATCHREL[(obj->pwm_ch) + 1].L;
|
||||
uint32_t t_off = obj->pwm->MATCHREL[(obj->pwm_ch) + 1].U;
|
||||
float v = (float)t_off/(float)t_period;
|
||||
obj->pwm->MATCHREL[(obj->pwm_ch) + 1].L = (uint64_t)((float)us * (float)v); // New endtime for this channel
|
||||
obj->pwm->MATCHREL[(obj->pwm_ch) + 1].U = (uint32_t)((float)us * (float)v); // New endtime for this channel
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +221,7 @@ void pwmout_pulsewidth_ms(pwmout_t* obj, int ms){
|
|||
void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
|
||||
|
||||
//Should add Sanity check to make sure pulsewidth < period!
|
||||
obj->pwm->MATCHREL[(obj->pwm_ch) + 1].L = (uint64_t)us; // New endtime for this channel
|
||||
obj->pwm->MATCHREL[(obj->pwm_ch) + 1].U = (uint32_t)us; // New endtime for this channel
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ void pwmout_init(pwmout_t* obj, PinName pin)
|
|||
obj->pwm = (LPC_SCT_Type*)LPC_SCT;
|
||||
obj->pwm_ch = sct_n;
|
||||
|
||||
LPC_SCT_Type* pwm = obj->pwm;
|
||||
LPC_SCT_Type* pwm = obj->pwm;
|
||||
|
||||
// Enable the SCT clock
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 8);
|
||||
|
|
@ -81,9 +81,8 @@ void pwmout_init(pwmout_t* obj, PinName pin)
|
|||
break;
|
||||
}
|
||||
|
||||
// Two 16-bit counters, autolimit
|
||||
pwm->CONFIG &= ~(0x1);
|
||||
pwm->CONFIG |= (1 << 17);
|
||||
// Unified 32-bit counter, autolimit
|
||||
pwm->CONFIG |= ((0x3 << 17) | 0x01);
|
||||
|
||||
// halt and clear the counter
|
||||
pwm->CTRL |= (1 << 2) | (1 << 3);
|
||||
|
|
@ -151,8 +150,8 @@ void pwmout_period_us(pwmout_t* obj, int us)
|
|||
uint32_t t_off = obj->pwm->MATCHREL[(obj->pwm_ch * 2) + 0];
|
||||
uint32_t t_on = obj->pwm->MATCHREL[(obj->pwm_ch * 2) + 1];
|
||||
float v = (float)t_on/(float)t_off;
|
||||
obj->pwm->MATCHREL[(obj->pwm_ch * 2) + 0] = (uint64_t)us;
|
||||
obj->pwm->MATCHREL[(obj->pwm_ch * 2) + 1] = (uint64_t)((float)us * (float)v);
|
||||
obj->pwm->MATCHREL[(obj->pwm_ch * 2) + 0] = (uint32_t)us;
|
||||
obj->pwm->MATCHREL[(obj->pwm_ch * 2) + 1] = (uint32_t)((float)us * (float)v);
|
||||
}
|
||||
|
||||
void pwmout_pulsewidth(pwmout_t* obj, float seconds)
|
||||
|
|
@ -167,7 +166,7 @@ void pwmout_pulsewidth_ms(pwmout_t* obj, int ms)
|
|||
|
||||
void pwmout_pulsewidth_us(pwmout_t* obj, int us)
|
||||
{
|
||||
obj->pwm->MATCHREL[(obj->pwm_ch * 2) + 1] = (uint64_t)us;
|
||||
obj->pwm->MATCHREL[(obj->pwm_ch * 2) + 1] = (uint32_t)us;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef MBED_PERIPHERALNAMES_H
|
||||
#define MBED_PERIPHERALNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ADC_1 = (int)ADC1_BASE
|
||||
} ADCName;
|
||||
|
||||
typedef enum {
|
||||
DAC_1 = (int)DAC_BASE
|
||||
} DACName;
|
||||
|
||||
typedef enum {
|
||||
UART_1 = (int)USART1_BASE,
|
||||
UART_2 = (int)USART2_BASE,
|
||||
UART_3 = (int)USART3_BASE
|
||||
} UARTName;
|
||||
|
||||
#define STDIO_UART_TX PA_2
|
||||
#define STDIO_UART_RX PA_3
|
||||
#define STDIO_UART UART_2
|
||||
|
||||
typedef enum {
|
||||
SPI_1 = (int)SPI1_BASE,
|
||||
SPI_2 = (int)SPI2_BASE,
|
||||
SPI_3 = (int)SPI3_BASE
|
||||
} SPIName;
|
||||
|
||||
typedef enum {
|
||||
I2C_1 = (int)I2C1_BASE,
|
||||
I2C_2 = (int)I2C2_BASE
|
||||
} I2CName;
|
||||
|
||||
typedef enum {
|
||||
PWM_2 = (int)TIM2_BASE,
|
||||
PWM_3 = (int)TIM3_BASE,
|
||||
PWM_4 = (int)TIM4_BASE,
|
||||
PWM_5 = (int)TIM5_BASE,
|
||||
PWM_9 = (int)TIM9_BASE,
|
||||
PWM_10 = (int)TIM10_BASE,
|
||||
PWM_11 = (int)TIM11_BASE
|
||||
} PWMName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,188 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "PeripheralPins.h"
|
||||
|
||||
// =====
|
||||
// Note: Commented lines are alternative possibilities which are not used per default.
|
||||
// If you change them, you will have also to modify the corresponding xxx_api.c file
|
||||
// for pwmout, analogin, analogout, ...
|
||||
// =====
|
||||
|
||||
//*** ADC ***
|
||||
|
||||
const PinMap PinMap_ADC[] = {
|
||||
{PA_0, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN0
|
||||
{PA_1, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN1
|
||||
{PA_2, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN2
|
||||
{PA_3, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN3
|
||||
{PA_4, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN4
|
||||
{PA_5, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN5
|
||||
{PA_6, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN6
|
||||
{PA_7, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN7
|
||||
{PB_0, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN8
|
||||
{PB_1, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN9
|
||||
{PB_12, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN18
|
||||
{PB_13, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN19
|
||||
{PB_14, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN20
|
||||
{PB_15, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN21
|
||||
{PC_0, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN10
|
||||
{PC_1, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN11
|
||||
{PC_2, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN12
|
||||
{PC_3, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN13
|
||||
{PC_4, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN14
|
||||
{PC_5, ADC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // ADC_IN15
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
//*** DAC ***
|
||||
|
||||
const PinMap PinMap_DAC[] = {
|
||||
{PA_4, DAC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // DAC_OUT1
|
||||
{PA_5, DAC_1, STM_PIN_DATA(STM_MODE_ANALOG, GPIO_NOPULL, 0)}, // DAC_OUT2 (Warning: LED1 is also on this pin)
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
//*** I2C ***
|
||||
|
||||
const PinMap PinMap_I2C_SDA[] = {
|
||||
{PB_7, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PB_9, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PB_11, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
const PinMap PinMap_I2C_SCL[] = {
|
||||
{PB_6, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PB_8, I2C_1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)},
|
||||
{PB_10, I2C_2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
//*** PWM ***
|
||||
|
||||
// TIM5 cannot be used because already used by the us_ticker.
|
||||
const PinMap PinMap_PWM[] = {
|
||||
// {PA_0, PWM_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5)}, // TIM5_CH1
|
||||
{PA_1, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH2
|
||||
// {PA_1, PWM_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5)}, // TIM5_CH1
|
||||
{PA_2, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH3
|
||||
// {PA_2, PWM_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5)}, // TIM5_CH3
|
||||
// {PA_2, PWM_9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9)}, // TIM9_CH1
|
||||
{PA_3, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH4
|
||||
// {PA_3, PWM_5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5)}, // TIM5_CH4
|
||||
// {PA_3, PWM_9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9)}, // TIM9_CH2
|
||||
{PA_6, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH1
|
||||
// {PA_6, PWM_10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10)}, // TIM10_CH1
|
||||
{PA_7, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH2
|
||||
// {PA_7, PWM_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11)}, // TIM11_CH1
|
||||
{PB_0, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH3
|
||||
{PB_1, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH4
|
||||
{PB_3, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH2
|
||||
{PB_4, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH1
|
||||
{PB_5, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH2
|
||||
{PB_6, PWM_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4)}, // TIM4_CH1
|
||||
{PB_7, PWM_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4)}, // TIM4_CH2
|
||||
{PB_8, PWM_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4)}, // TIM4_CH3
|
||||
// {PB_8, PWM_10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10)}, // TIM10_CH1
|
||||
{PB_9, PWM_4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4)}, // TIM4_CH4
|
||||
// {PB_9, PWM_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11)}, // TIM11_CH1
|
||||
{PB_10, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH3
|
||||
{PB_11, PWM_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2)}, // TIM2_CH4
|
||||
{PB_12, PWM_10, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10)}, // TIM10_CH1
|
||||
{PB_13, PWM_9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9)}, // TIM9_CH1
|
||||
{PB_14, PWM_9, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9)}, // TIM9_CH2
|
||||
{PB_15, PWM_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11)}, // TIM11_CH1
|
||||
{PC_6, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH1
|
||||
{PC_7, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH2
|
||||
{PC_8, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH3
|
||||
{PC_9, PWM_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3)}, // TIM3_CH4
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
//*** SERIAL ***
|
||||
|
||||
const PinMap PinMap_UART_TX[] = {
|
||||
{PA_2, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_9, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_6, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
// {PC_10, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
const PinMap PinMap_UART_RX[] = {
|
||||
{PA_3, UART_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
|
||||
{PA_10, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_7, UART_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
|
||||
{PB_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
// {PC_11, UART_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
//*** SPI ***
|
||||
|
||||
const PinMap PinMap_SPI_MOSI[] = {
|
||||
{PA_7, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PA_12, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PB_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PB_5, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PB_15, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_12, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
const PinMap PinMap_SPI_MISO[] = {
|
||||
{PA_6, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PA_11, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PB_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PB_4, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PB_14, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_11, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
const PinMap PinMap_SPI_SCLK[] = {
|
||||
{PA_5, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
{PB_3, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PB_3, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PB_13, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{PC_10, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
const PinMap PinMap_SPI_SSEL[] = {
|
||||
{PA_4, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PA_4, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PA_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
|
||||
// {PA_15, SPI_3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)},
|
||||
{PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef MBED_PINNAMES_H
|
||||
#define MBED_PINNAMES_H
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// See stm32l0xx_hal_gpio.h and stm32l0xx_hal_gpio_ex.h for values of MODE, PUPD and AFNUM
|
||||
#define STM_PIN_DATA(MODE, PUPD, AFNUM) ((int)(((AFNUM) << 7) | ((PUPD) << 4) | ((MODE) << 0)))
|
||||
#define STM_PIN_MODE(X) (((X) >> 0) & 0x0F)
|
||||
#define STM_PIN_PUPD(X) (((X) >> 4) & 0x07)
|
||||
#define STM_PIN_AFNUM(X) (((X) >> 7) & 0x0F)
|
||||
#define STM_MODE_INPUT (0)
|
||||
#define STM_MODE_OUTPUT_PP (1)
|
||||
#define STM_MODE_OUTPUT_OD (2)
|
||||
#define STM_MODE_AF_PP (3)
|
||||
#define STM_MODE_AF_OD (4)
|
||||
#define STM_MODE_ANALOG (5)
|
||||
#define STM_MODE_IT_RISING (6)
|
||||
#define STM_MODE_IT_FALLING (7)
|
||||
#define STM_MODE_IT_RISING_FALLING (8)
|
||||
#define STM_MODE_EVT_RISING (9)
|
||||
#define STM_MODE_EVT_FALLING (10)
|
||||
#define STM_MODE_EVT_RISING_FALLING (11)
|
||||
#define STM_MODE_IT_EVT_RESET (12)
|
||||
|
||||
// High nibble = port number (0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, 7=H)
|
||||
// Low nibble = pin number
|
||||
#define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
|
||||
#define STM_PIN(X) ((uint32_t)(X) & 0xF)
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
typedef enum {
|
||||
PA_0 = 0x00,
|
||||
PA_1 = 0x01,
|
||||
PA_2 = 0x02,
|
||||
PA_3 = 0x03,
|
||||
PA_4 = 0x04,
|
||||
PA_5 = 0x05,
|
||||
PA_6 = 0x06,
|
||||
PA_7 = 0x07,
|
||||
PA_8 = 0x08,
|
||||
PA_9 = 0x09,
|
||||
PA_10 = 0x0A,
|
||||
PA_11 = 0x0B,
|
||||
PA_12 = 0x0C,
|
||||
PA_13 = 0x0D,
|
||||
PA_14 = 0x0E,
|
||||
PA_15 = 0x0F,
|
||||
|
||||
PB_0 = 0x10,
|
||||
PB_1 = 0x11,
|
||||
PB_2 = 0x12,
|
||||
PB_3 = 0x13,
|
||||
PB_4 = 0x14,
|
||||
PB_5 = 0x15,
|
||||
PB_6 = 0x16,
|
||||
PB_7 = 0x17,
|
||||
PB_8 = 0x18,
|
||||
PB_9 = 0x19,
|
||||
PB_10 = 0x1A,
|
||||
PB_11 = 0x1B,
|
||||
PB_12 = 0x1C,
|
||||
PB_13 = 0x1D,
|
||||
PB_14 = 0x1E,
|
||||
PB_15 = 0x1F,
|
||||
|
||||
PC_0 = 0x20,
|
||||
PC_1 = 0x21,
|
||||
PC_2 = 0x22,
|
||||
PC_3 = 0x23,
|
||||
PC_4 = 0x24,
|
||||
PC_5 = 0x25,
|
||||
PC_6 = 0x26,
|
||||
PC_7 = 0x27,
|
||||
PC_8 = 0x28,
|
||||
PC_9 = 0x29,
|
||||
PC_10 = 0x2A,
|
||||
PC_11 = 0x2B,
|
||||
PC_12 = 0x2C,
|
||||
PC_13 = 0x2D,
|
||||
PC_14 = 0x2E,
|
||||
PC_15 = 0x2F,
|
||||
|
||||
PD_2 = 0x32,
|
||||
|
||||
//PH_0 = 0x70,
|
||||
//PH_1 = 0x71,
|
||||
|
||||
// Arduino connector namings
|
||||
A0 = PA_0,
|
||||
A1 = PA_1,
|
||||
A2 = PA_4,
|
||||
A3 = PB_0,
|
||||
A4 = PC_1,
|
||||
A5 = PC_0,
|
||||
D0 = PA_3,
|
||||
D1 = PA_2,
|
||||
D2 = PA_10,
|
||||
D3 = PB_3,
|
||||
D4 = PB_5,
|
||||
D5 = PB_4,
|
||||
D6 = PB_10,
|
||||
D7 = PA_8,
|
||||
D8 = PA_9,
|
||||
D9 = PC_7,
|
||||
D10 = PB_6,
|
||||
D11 = PA_7,
|
||||
D12 = PA_6,
|
||||
D13 = PA_5,
|
||||
D14 = PB_9,
|
||||
D15 = PB_8,
|
||||
|
||||
// Generic signals namings
|
||||
LED1 = PB_1,
|
||||
LED2 = PB_7,
|
||||
LED3 = PA_10,
|
||||
//LED4 = PA_5,
|
||||
//USER_BUTTON = PC_13,
|
||||
SERIAL_TX = PA_2,
|
||||
SERIAL_RX = PA_3,
|
||||
USBTX = PA_2,
|
||||
USBRX = PA_3,
|
||||
I2C_SCL = PB_8,
|
||||
I2C_SDA = PB_9,
|
||||
SPI_MOSI = PA_7,
|
||||
SPI_MISO = PA_6,
|
||||
SPI_SCK = PA_5,
|
||||
SPI_CS = PB_6,
|
||||
PWM_OUT = PB_3,
|
||||
|
||||
// Not connected
|
||||
NC = (int)0xFFFFFFFF
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullUp = 1,
|
||||
PullDown = 2,
|
||||
OpenDrain = 3,
|
||||
PullDefault = PullNone
|
||||
} PinMode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef MBED_PORTNAMES_H
|
||||
#define MBED_PORTNAMES_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PortA = 0,
|
||||
PortB = 1,
|
||||
PortC = 2,
|
||||
PortD = 3,
|
||||
PortH = 7
|
||||
} PortName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef MBED_DEVICE_H
|
||||
#define MBED_DEVICE_H
|
||||
|
||||
#define DEVICE_PORTIN 1
|
||||
#define DEVICE_PORTOUT 1
|
||||
#define DEVICE_PORTINOUT 1
|
||||
|
||||
#define DEVICE_INTERRUPTIN 1
|
||||
|
||||
#define DEVICE_ANALOGIN 1
|
||||
#define DEVICE_ANALOGOUT 1
|
||||
|
||||
#define DEVICE_SERIAL 1
|
||||
|
||||
#define DEVICE_I2C 1
|
||||
#define DEVICE_I2CSLAVE 1
|
||||
|
||||
#define DEVICE_SPI 1
|
||||
#define DEVICE_SPISLAVE 1
|
||||
|
||||
#define DEVICE_RTC 1
|
||||
|
||||
#define DEVICE_PWMOUT 1
|
||||
|
||||
#define DEVICE_SLEEP 1
|
||||
|
||||
//=======================================
|
||||
|
||||
#define DEVICE_SEMIHOST 0
|
||||
#define DEVICE_LOCALFILESYSTEM 0
|
||||
#define DEVICE_ID_LENGTH 24
|
||||
|
||||
#define DEVICE_DEBUG_AWARENESS 0
|
||||
|
||||
#define DEVICE_STDIO_MESSAGES 1
|
||||
|
||||
#define DEVICE_ERROR_RED 0
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#ifndef MBED_OBJECTS_H
|
||||
#define MBED_OBJECTS_H
|
||||
|
||||
#include "cmsis.h"
|
||||
#include "PortNames.h"
|
||||
#include "PeripheralNames.h"
|
||||
#include "PinNames.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct gpio_irq_s {
|
||||
IRQn_Type irq_n;
|
||||
uint32_t irq_index;
|
||||
uint32_t event;
|
||||
PinName pin;
|
||||
};
|
||||
|
||||
struct port_s {
|
||||
PortName port;
|
||||
uint32_t mask;
|
||||
PinDirection direction;
|
||||
__IO uint32_t *reg_in;
|
||||
__IO uint32_t *reg_out;
|
||||
};
|
||||
|
||||
struct analogin_s {
|
||||
ADCName adc;
|
||||
PinName pin;
|
||||
};
|
||||
|
||||
struct dac_s {
|
||||
DACName dac;
|
||||
PinName pin;
|
||||
};
|
||||
|
||||
struct serial_s {
|
||||
UARTName uart;
|
||||
int index; // Used by irq
|
||||
uint32_t baudrate;
|
||||
uint32_t databits;
|
||||
uint32_t stopbits;
|
||||
uint32_t parity;
|
||||
PinName pin_tx;
|
||||
PinName pin_rx;
|
||||
};
|
||||
|
||||
struct spi_s {
|
||||
SPIName spi;
|
||||
uint32_t bits;
|
||||
uint32_t cpol;
|
||||
uint32_t cpha;
|
||||
uint32_t mode;
|
||||
uint32_t nss;
|
||||
uint32_t br_presc;
|
||||
PinName pin_miso;
|
||||
PinName pin_mosi;
|
||||
PinName pin_sclk;
|
||||
PinName pin_ssel;
|
||||
};
|
||||
|
||||
struct i2c_s {
|
||||
I2CName i2c;
|
||||
uint32_t slave;
|
||||
};
|
||||
|
||||
struct pwmout_s {
|
||||
PWMName pwm;
|
||||
PinName pin;
|
||||
uint32_t period;
|
||||
uint32_t pulse;
|
||||
};
|
||||
|
||||
#include "gpio_object.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -54,7 +54,11 @@ static inline void gpio_write(gpio_t *obj, int value)
|
|||
if (value) {
|
||||
*obj->reg_set = obj->mask;
|
||||
} else {
|
||||
#if defined(TARGET_STM32L152RC)
|
||||
*obj->reg_set = obj->mask << 16;
|
||||
#else
|
||||
*obj->reg_clr = obj->mask;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,8 +86,14 @@ void rtc_init(void)
|
|||
__HAL_RCC_RTC_ENABLE();
|
||||
|
||||
RtcHandle.Init.HourFormat = RTC_HOURFORMAT_24;
|
||||
#ifdef TARGET_MOTE_L152RC
|
||||
/* SubSecond resolution of 16384Hz */
|
||||
RtcHandle.Init.AsynchPrediv = 1;
|
||||
RtcHandle.Init.SynchPrediv = (rtc_freq / 2) - 1;
|
||||
#else
|
||||
RtcHandle.Init.AsynchPrediv = 127;
|
||||
RtcHandle.Init.SynchPrediv = (rtc_freq / 128) - 1;
|
||||
#endif
|
||||
RtcHandle.Init.OutPut = RTC_OUTPUT_DISABLE;
|
||||
RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
|
||||
RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
|
||||
|
|
|
|||
|
|
@ -95,15 +95,18 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
|
|||
obj->index = 2;
|
||||
}
|
||||
|
||||
#if defined(USART4_BASE)
|
||||
if (obj->uart == UART_4) {
|
||||
__UART4_CLK_ENABLE();
|
||||
obj->index = 3;
|
||||
}
|
||||
|
||||
#endif
|
||||
#if defined(USART5_BASE)
|
||||
if (obj->uart == UART_5) {
|
||||
__UART5_CLK_ENABLE();
|
||||
obj->index = 4;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Configure the UART pins
|
||||
pinmap_pinout(tx, PinMap_UART_TX);
|
||||
|
|
@ -153,17 +156,20 @@ void serial_free(serial_t *obj)
|
|||
__USART3_CLK_DISABLE();
|
||||
}
|
||||
|
||||
#if defined(USART4_BASE)
|
||||
if (obj->uart == UART_4) {
|
||||
__UART4_FORCE_RESET();
|
||||
__UART4_RELEASE_RESET();
|
||||
__UART4_CLK_DISABLE();
|
||||
}
|
||||
|
||||
#endif
|
||||
#if defined(USART5_BASE)
|
||||
if (obj->uart == UART_5) {
|
||||
__UART5_FORCE_RESET();
|
||||
__UART5_RELEASE_RESET();
|
||||
__UART5_CLK_DISABLE();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Configure GPIOs
|
||||
pin_function(obj->pin_tx, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0));
|
||||
|
|
@ -243,15 +249,19 @@ static void uart3_irq(void)
|
|||
uart_irq(UART_3, 2);
|
||||
}
|
||||
|
||||
#if defined(USART4_BASE)
|
||||
static void uart4_irq(void)
|
||||
{
|
||||
uart_irq(UART_4, 3);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USART5_BASE)
|
||||
static void uart5_irq(void)
|
||||
{
|
||||
uart_irq(UART_5, 4);
|
||||
}
|
||||
#endif
|
||||
|
||||
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id)
|
||||
{
|
||||
|
|
@ -281,15 +291,19 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
|
|||
vector = (uint32_t)&uart3_irq;
|
||||
}
|
||||
|
||||
#if defined(USART4_BASE)
|
||||
if (obj->uart == UART_4) {
|
||||
irq_n = UART4_IRQn;
|
||||
vector = (uint32_t)&uart4_irq;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USART5_BASE)
|
||||
if (obj->uart == UART_5) {
|
||||
irq_n = UART5_IRQn;
|
||||
vector = (uint32_t)&uart5_irq;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (enable) {
|
||||
|
||||
|
|
|
|||
|
|
@ -50,12 +50,43 @@ void sleep(void)
|
|||
|
||||
void deepsleep(void)
|
||||
{
|
||||
#if defined(TARGET_MOTE_L152RC)
|
||||
int8_t STOPEntry = PWR_STOPENTRY_WFI;
|
||||
#endif
|
||||
|
||||
// Disable HAL tick interrupt
|
||||
TimMasterHandle.Instance = TIM5;
|
||||
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
|
||||
#if defined(TARGET_MOTE_L152RC)
|
||||
/* Select the regulator state in Stop mode: Set PDDS and LPSDSR bit according to PWR_Regulator value */
|
||||
MODIFY_REG(PWR->CR, (PWR_CR_PDDS | PWR_CR_LPSDSR), PWR_LOWPOWERREGULATOR_ON);
|
||||
|
||||
/* Set SLEEPDEEP bit of Cortex System Control Register */
|
||||
SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
|
||||
|
||||
/* Select Stop mode entry --------------------------------------------------*/
|
||||
if(STOPEntry == PWR_STOPENTRY_WFI)
|
||||
{
|
||||
/* Request Wait For Interrupt */
|
||||
__WFI();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Request Wait For Event */
|
||||
__SEV();
|
||||
__WFE();
|
||||
__WFE();
|
||||
}
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
/* Reset SLEEPDEEP bit of Cortex System Control Register */
|
||||
CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
|
||||
#else
|
||||
// Request to enter STOP mode with regulator in low power mode
|
||||
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
|
||||
#endif
|
||||
|
||||
// After wake-up from STOP reconfigure the PLL
|
||||
SetSysClock();
|
||||
|
|
|
|||
|
|
@ -304,6 +304,9 @@ osThreadDef_t os_thread_def_main = {(os_pthread)main, osPriorityNormal, 0, NULL}
|
|||
#elif defined(TARGET_MAX32610) || defined(TARGET_MAX32600)
|
||||
#define INITIAL_SP (0x20008000UL)
|
||||
|
||||
#elif defined(TARGET_TEENSY3_1)
|
||||
#define INITIAL_SP (0x20008000UL)
|
||||
|
||||
#else
|
||||
#error "no target defined"
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
#ifndef OS_TASKCNT
|
||||
# if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) || defined(TARGET_LPC4330) || defined(TARGET_LPC4337) || defined(TARGET_LPC1347) || defined(TARGET_K64F) || defined(TARGET_STM32F401RE)\
|
||||
|| defined(TARGET_KL46Z) || defined(TARGET_KL43Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68) \
|
||||
|| defined(TARGET_STM32F411RE) || defined(TARGET_STM32F405RG) || defined(TARGET_K22F) || defined(TARGET_STM32F429ZI) || defined(TARGET_STM32F401VC) || defined(TARGET_MAX32610) || defined(TARGET_MAX32600)
|
||||
|| defined(TARGET_STM32F411RE) || defined(TARGET_STM32F405RG) || defined(TARGET_K22F) || defined(TARGET_STM32F429ZI) || defined(TARGET_STM32F401VC) || defined(TARGET_MAX32610) || defined(TARGET_MAX32600) || defined(TARGET_TEENSY3_1)
|
||||
# define OS_TASKCNT 14
|
||||
# elif defined(TARGET_LPC11U24) || defined(TARGET_STM32F303RE) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) \
|
||||
|| defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_KL05Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8) \
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
#ifndef OS_SCHEDULERSTKSIZE
|
||||
# if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) || defined(TARGET_LPC4330) || defined(TARGET_LPC4337) || defined(TARGET_LPC1347) || defined(TARGET_K64F) || defined(TARGET_STM32F401RE)\
|
||||
|| defined(TARGET_KL46Z) || defined(TARGET_KL43Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68) \
|
||||
|| defined(TARGET_STM32F411RE) || defined(TARGET_STM32F405RG) || defined(TARGET_K22F) || defined(TARGET_STM32F429ZI) || defined(TARGET_STM32F401VC) || defined(TARGET_MAX32610) || defined(TARGET_MAX32600)
|
||||
|| defined(TARGET_STM32F411RE) || defined(TARGET_STM32F405RG) || defined(TARGET_K22F) || defined(TARGET_STM32F429ZI) || defined(TARGET_STM32F401VC) || defined(TARGET_MAX32610) || defined(TARGET_MAX32600) || defined(TARGET_TEENSY3_1)
|
||||
# define OS_SCHEDULERSTKSIZE 256
|
||||
# elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) \
|
||||
|| defined(TARGET_LPC812) || defined(TARGET_KL25Z) || defined(TARGET_KL05Z) || defined(TARGET_STM32F100RB) || defined(TARGET_STM32F051R8) \
|
||||
|
|
@ -119,7 +119,7 @@
|
|||
# if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
|
||||
# define OS_CLOCK 96000000
|
||||
|
||||
# elif defined(TARGET_LPC1347) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_STM32F334R8) || defined(TARGET_STM32F334C8) || defined(TARGET_STM32F303RE)
|
||||
# elif defined(TARGET_LPC1347) || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_STM32F334R8) || defined(TARGET_STM32F334C8) || defined(TARGET_STM32F303RE) || defined(TARGET_TEENSY3_1)
|
||||
# define OS_CLOCK 72000000
|
||||
|
||||
# elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401) || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO) || defined(TARGET_LPC1114) || defined(TARGET_KL25Z) \
|
||||
|
|
|
|||
|
|
@ -210,8 +210,12 @@ SVC_Handler_Veneer:
|
|||
|
||||
CBZ R1,SVC_Next /* Runtask deleted? */
|
||||
TST LR,#0x10 /* is it extended frame? */
|
||||
#ifdef __FPU_PRESENT
|
||||
ITTE EQ
|
||||
VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */
|
||||
#else
|
||||
ITE EQ
|
||||
#endif
|
||||
MOVEQ R0,#0x01 /* os_tsk->stack_frame val */
|
||||
MOVNE R0,#0x00
|
||||
STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */
|
||||
|
|
@ -229,8 +233,12 @@ SVC_Next:
|
|||
LDMIA R12!,{R4-R11} /* Restore New Context */
|
||||
LDRB R0,[R2,#TCB_STACKF] /* Stack Frame */
|
||||
CMP R0,#0 /* Basic/Extended Stack Frame */
|
||||
#ifdef __FPU_PRESENT
|
||||
ITTE NE
|
||||
VLDMIANE R12!,{S16-S31} /* restore VFP hi-registers */
|
||||
#else
|
||||
ITE NE
|
||||
#endif
|
||||
MVNNE LR,#~0xFFFFFFED /* set EXC_RETURN value */
|
||||
MVNEQ LR,#~0xFFFFFFFD
|
||||
MSR PSP,R12 /* Write PSP */
|
||||
|
|
@ -303,8 +311,12 @@ Sys_Switch:
|
|||
|
||||
MRS R12,PSP /* Read PSP */
|
||||
TST LR,#0x10 /* is it extended frame? */
|
||||
#ifdef __FPU_PRESENT
|
||||
ITTE EQ
|
||||
VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */
|
||||
#else
|
||||
ITE EQ
|
||||
#endif
|
||||
MOVEQ R0,#0x01 /* os_tsk->stack_frame val */
|
||||
MOVNE R0,#0x00
|
||||
STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */
|
||||
|
|
@ -321,8 +333,12 @@ Sys_Switch:
|
|||
LDMIA R12!,{R4-R11} /* Restore New Context */
|
||||
LDRB R0,[R2,#TCB_STACKF] /* Stack Frame */
|
||||
CMP R0,#0 /* Basic/Extended Stack Frame */
|
||||
#ifdef __FPU_PRESENT
|
||||
ITTE NE
|
||||
VLDMIANE R12!,{S16-S31} /* restore VFP hi-registers */
|
||||
#else
|
||||
ITE NE
|
||||
#endif
|
||||
MVNNE LR,#~0xFFFFFFED /* set EXC_RETURN value */
|
||||
MVNEQ LR,#~0xFFFFFFFD
|
||||
MSR PSP,R12 /* Write PSP */
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd");
|
|||
SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd");
|
||||
|
||||
#elif defined(TARGET_K64F)
|
||||
SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd");
|
||||
SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd");
|
||||
|
||||
#elif defined(TARGET_K22F)
|
||||
SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd");
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd");
|
|||
SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd");
|
||||
|
||||
#elif defined(TARGET_K64F)
|
||||
SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd");
|
||||
SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd");
|
||||
|
||||
#elif defined(TARGET_K22F)
|
||||
SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd");
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd");
|
|||
SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd");
|
||||
|
||||
#elif defined(TARGET_K64F)
|
||||
SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd");
|
||||
SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd");
|
||||
|
||||
#elif defined(TARGET_K22F)
|
||||
SDFileSystem sd(PTD6, PTD7, PTD5, PTD4, "sd");
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue