motify compile link error

motify compile link error
This commit is contained in:
ant 2016-09-18 09:03:25 +08:00
parent 923914edae
commit 03e74a8e50
5418 changed files with 1367914 additions and 206149 deletions

View file

@ -1,14 +1,14 @@
/* mbed Microcontroller Library - CMSIS
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
*
* A generic CMSIS include header, pulling in RTL8195A specifics
*/
#ifndef MBED_CMSIS_H
#define MBED_CMSIS_H
#include <platform/platform_stdlib.h>
#include <hal_platform.h>
#endif
/* mbed Microcontroller Library - CMSIS
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
*
* A generic CMSIS include header, pulling in RTL8195A specifics
*/
#ifndef MBED_CMSIS_H
#define MBED_CMSIS_H
#include <platform/platform_stdlib.h>
#include <hal_platform.h>
#endif

View file

@ -1,100 +1,100 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_PERIPHERALNAMES_H
#define MBED_PERIPHERALNAMES_H
#include "cmsis.h"
#ifdef __cplusplus
extern "C" {
#endif
#if 0
typedef enum {
UART_1 = (int)USART1_BASE,
UART_2 = (int)USART2_BASE,
UART_3 = (int)USART3_BASE,
UART_4 = (int)UART4_BASE,
UART_5 = (int)UART5_BASE,
UART_6 = (int)USART6_BASE
} UARTName;
typedef enum {
ADC0_0 = 0,
ADC0_1,
ADC0_2,
ADC0_3,
ADC0_4,
ADC0_5,
ADC0_6,
ADC0_7,
ADC0_8,
ADC0_9,
ADC0_10,
ADC0_11,
ADC0_12,
ADC0_13,
ADC0_14,
ADC0_15
} ADCName;
typedef enum {
DAC_0 = 0,
DAC_1
} DACName;
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,
I2C_3 = (int)I2C3_BASE
} I2CName;
typedef enum {
PWM_1 = 1,
PWM_2,
PWM_3,
PWM_4,
PWM_5,
PWM_6
} PWMName;
typedef enum {
CAN_1 = (int)CAN1_BASE,
CAN_2 = (int)CAN2_BASE
} CANName;
#endif
#define STDIO_UART_TX PA_6
#define STDIO_UART_RX PA_7
#define STDIO_UART UART0
typedef enum {
DAC_0 = 0,
DAC_1
} DACName;
#ifdef __cplusplus
}
#endif
#endif
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_PERIPHERALNAMES_H
#define MBED_PERIPHERALNAMES_H
#include "cmsis.h"
#ifdef __cplusplus
extern "C" {
#endif
#if 0
typedef enum {
UART_1 = (int)USART1_BASE,
UART_2 = (int)USART2_BASE,
UART_3 = (int)USART3_BASE,
UART_4 = (int)UART4_BASE,
UART_5 = (int)UART5_BASE,
UART_6 = (int)USART6_BASE
} UARTName;
typedef enum {
ADC0_0 = 0,
ADC0_1,
ADC0_2,
ADC0_3,
ADC0_4,
ADC0_5,
ADC0_6,
ADC0_7,
ADC0_8,
ADC0_9,
ADC0_10,
ADC0_11,
ADC0_12,
ADC0_13,
ADC0_14,
ADC0_15
} ADCName;
typedef enum {
DAC_0 = 0,
DAC_1
} DACName;
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,
I2C_3 = (int)I2C3_BASE
} I2CName;
typedef enum {
PWM_1 = 1,
PWM_2,
PWM_3,
PWM_4,
PWM_5,
PWM_6
} PWMName;
typedef enum {
CAN_1 = (int)CAN1_BASE,
CAN_2 = (int)CAN2_BASE
} CANName;
#endif
#define STDIO_UART_TX PA_6
#define STDIO_UART_RX PA_7
#define STDIO_UART UART0
typedef enum {
DAC_0 = 0,
DAC_1
} DACName;
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,215 +1,215 @@
#ifndef _PINNAMES_H_
#define _PINNAMES_H_
#include "cmsis.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
PORT_A = 0,
PORT_B = 1,
PORT_C = 2,
PORT_D = 3,
PORT_E = 4,
PORT_F = 5,
PORT_G = 6,
PORT_H = 7,
PORT_I = 8,
PORT_J = 9,
PORT_K = 10,
PORT_V = 11,
PORT_U = 12,
PORT_MAX
} GPIO_PORT;
#define RTL_PIN_PERI(FUN, IDX, SEL) ((int)(((FUN) << 8) | ((IDX)<<4) | (SEL)))
#define RTL_PIN_FUNC(FUN, SEL) ((int)(((FUN) << 7) | (SEL)))
#define RTL_GET_PERI_SEL(peri) ((int)((peri)&0x0F))
#define RTL_GET_PERI_IDX(peri) ((int)(((peri) >> 4)&0x0F))
typedef enum {
PIN_INPUT=0,
PIN_OUTPUT
} PinDirection;
typedef enum {
PA_0 = (PORT_A<<4|0),
PA_1 = (PORT_A<<4|1),
PA_2 = (PORT_A<<4|2),
PA_3 = (PORT_A<<4|3),
PA_4 = (PORT_A<<4|4),
PA_5 = (PORT_A<<4|5),
PA_6 = (PORT_A<<4|6),
PA_7 = (PORT_A<<4|7),
PB_0 = (PORT_B<<4|0),
PB_1 = (PORT_B<<4|1),
PB_2 = (PORT_B<<4|2),
PB_3 = (PORT_B<<4|3),
PB_4 = (PORT_B<<4|4),
PB_5 = (PORT_B<<4|5),
PB_6 = (PORT_B<<4|6),
PB_7 = (PORT_B<<4|7),
PC_0 = (PORT_C<<4|0),
PC_1 = (PORT_C<<4|1),
PC_2 = (PORT_C<<4|2),
PC_3 = (PORT_C<<4|3),
PC_4 = (PORT_C<<4|4),
PC_5 = (PORT_C<<4|5),
PC_6 = (PORT_C<<4|6),
PC_7 = (PORT_C<<4|7),
PC_8 = (PORT_C<<4|8),
PC_9 = (PORT_C<<4|9),
PD_0 = (PORT_D<<4|0),
PD_1 = (PORT_D<<4|1),
PD_2 = (PORT_D<<4|2),
PD_3 = (PORT_D<<4|3),
PD_4 = (PORT_D<<4|4),
PD_5 = (PORT_D<<4|5),
PD_6 = (PORT_D<<4|6),
PD_7 = (PORT_D<<4|7),
PD_8 = (PORT_D<<4|8),
PD_9 = (PORT_D<<4|9),
PE_0 = (PORT_E<<4|0),
PE_1 = (PORT_E<<4|1),
PE_2 = (PORT_E<<4|2),
PE_3 = (PORT_E<<4|3),
PE_4 = (PORT_E<<4|4),
PE_5 = (PORT_E<<4|5),
PE_6 = (PORT_E<<4|6),
PE_7 = (PORT_E<<4|7),
PE_8 = (PORT_E<<4|8),
PE_9 = (PORT_E<<4|9),
PE_A = (PORT_E<<4|10),
PF_0 = (PORT_F<<4|0),
PF_1 = (PORT_F<<4|1),
PF_2 = (PORT_F<<4|2),
PF_3 = (PORT_F<<4|3),
PF_4 = (PORT_F<<4|4),
PF_5 = (PORT_F<<4|5),
// PF_6 = (PORT_F<<4|6),
// PF_7 = (PORT_F<<4|7),
PG_0 = (PORT_G<<4|0),
PG_1 = (PORT_G<<4|1),
PG_2 = (PORT_G<<4|2),
PG_3 = (PORT_G<<4|3),
PG_4 = (PORT_G<<4|4),
PG_5 = (PORT_G<<4|5),
PG_6 = (PORT_G<<4|6),
PG_7 = (PORT_G<<4|7),
PH_0 = (PORT_H<<4|0),
PH_1 = (PORT_H<<4|1),
PH_2 = (PORT_H<<4|2),
PH_3 = (PORT_H<<4|3),
PH_4 = (PORT_H<<4|4),
PH_5 = (PORT_H<<4|5),
PH_6 = (PORT_H<<4|6),
PH_7 = (PORT_H<<4|7),
PI_0 = (PORT_I<<4|0),
PI_1 = (PORT_I<<4|1),
PI_2 = (PORT_I<<4|2),
PI_3 = (PORT_I<<4|3),
PI_4 = (PORT_I<<4|4),
PI_5 = (PORT_I<<4|5),
PI_6 = (PORT_I<<4|6),
PI_7 = (PORT_I<<4|7),
PJ_0 = (PORT_J<<4|0),
PJ_1 = (PORT_J<<4|1),
PJ_2 = (PORT_J<<4|2),
PJ_3 = (PORT_J<<4|3),
PJ_4 = (PORT_J<<4|4),
PJ_5 = (PORT_J<<4|5),
PJ_6 = (PORT_J<<4|6),
// PJ_7 = (PORT_J<<4|7),
PK_0 = (PORT_K<<4|0),
PK_1 = (PORT_K<<4|1),
PK_2 = (PORT_K<<4|2),
PK_3 = (PORT_K<<4|3),
PK_4 = (PORT_K<<4|4),
PK_5 = (PORT_K<<4|5),
PK_6 = (PORT_K<<4|6),
// PK_7 = (PORT_K<<4|7),
AD_1 = (PORT_V<<4|1),
AD_2 = (PORT_V<<4|2),
AD_3 = (PORT_V<<4|3),
DA_0 = (PORT_U<<4|0),
DA_1 = (PORT_U<<4|1),
// 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_4,
LED2 = PB_5,
LED3 = PB_6,
LED4 = PB_7,
USER_BUTTON = PA_3,
SERIAL_TX = PA_7,
SERIAL_RX = PA_6,
USBTX = PA_7,
USBRX = PA_6,
I2C_SCL = PC_5,
I2C_SDA = PC_4,
SPI_MOSI = PC_2,
SPI_MISO = PC_3,
SPI_SCK = PC_1,
SPI_CS = PC_0,
PWM_OUT = PD_4,
// Not connected
NC = (uint32_t)0xFFFFFFFF
} PinName;
typedef enum {
PullNone = 0,
PullUp = 1,
PullDown = 2,
OpenDrain = 3,
PullDefault = PullNone
} PinMode;
#define PORT_NUM(pin) (((uint32_t)(pin) >> 4) & 0xF)
#define PIN_NUM(pin) ((uint32_t)(pin) & 0xF)
#ifdef __cplusplus
}
#endif
#endif
#ifndef _PINNAMES_H_
#define _PINNAMES_H_
#include "cmsis.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
PORT_A = 0,
PORT_B = 1,
PORT_C = 2,
PORT_D = 3,
PORT_E = 4,
PORT_F = 5,
PORT_G = 6,
PORT_H = 7,
PORT_I = 8,
PORT_J = 9,
PORT_K = 10,
PORT_V = 11,
PORT_U = 12,
PORT_MAX
} GPIO_PORT;
#define RTL_PIN_PERI(FUN, IDX, SEL) ((int)(((FUN) << 8) | ((IDX)<<4) | (SEL)))
#define RTL_PIN_FUNC(FUN, SEL) ((int)(((FUN) << 7) | (SEL)))
#define RTL_GET_PERI_SEL(peri) ((int)((peri)&0x0F))
#define RTL_GET_PERI_IDX(peri) ((int)(((peri) >> 4)&0x0F))
typedef enum {
PIN_INPUT=0,
PIN_OUTPUT
} PinDirection;
typedef enum {
PA_0 = (PORT_A<<4|0),
PA_1 = (PORT_A<<4|1),
PA_2 = (PORT_A<<4|2),
PA_3 = (PORT_A<<4|3),
PA_4 = (PORT_A<<4|4),
PA_5 = (PORT_A<<4|5),
PA_6 = (PORT_A<<4|6),
PA_7 = (PORT_A<<4|7),
PB_0 = (PORT_B<<4|0),
PB_1 = (PORT_B<<4|1),
PB_2 = (PORT_B<<4|2),
PB_3 = (PORT_B<<4|3),
PB_4 = (PORT_B<<4|4),
PB_5 = (PORT_B<<4|5),
PB_6 = (PORT_B<<4|6),
PB_7 = (PORT_B<<4|7),
PC_0 = (PORT_C<<4|0),
PC_1 = (PORT_C<<4|1),
PC_2 = (PORT_C<<4|2),
PC_3 = (PORT_C<<4|3),
PC_4 = (PORT_C<<4|4),
PC_5 = (PORT_C<<4|5),
PC_6 = (PORT_C<<4|6),
PC_7 = (PORT_C<<4|7),
PC_8 = (PORT_C<<4|8),
PC_9 = (PORT_C<<4|9),
PD_0 = (PORT_D<<4|0),
PD_1 = (PORT_D<<4|1),
PD_2 = (PORT_D<<4|2),
PD_3 = (PORT_D<<4|3),
PD_4 = (PORT_D<<4|4),
PD_5 = (PORT_D<<4|5),
PD_6 = (PORT_D<<4|6),
PD_7 = (PORT_D<<4|7),
PD_8 = (PORT_D<<4|8),
PD_9 = (PORT_D<<4|9),
PE_0 = (PORT_E<<4|0),
PE_1 = (PORT_E<<4|1),
PE_2 = (PORT_E<<4|2),
PE_3 = (PORT_E<<4|3),
PE_4 = (PORT_E<<4|4),
PE_5 = (PORT_E<<4|5),
PE_6 = (PORT_E<<4|6),
PE_7 = (PORT_E<<4|7),
PE_8 = (PORT_E<<4|8),
PE_9 = (PORT_E<<4|9),
PE_A = (PORT_E<<4|10),
PF_0 = (PORT_F<<4|0),
PF_1 = (PORT_F<<4|1),
PF_2 = (PORT_F<<4|2),
PF_3 = (PORT_F<<4|3),
PF_4 = (PORT_F<<4|4),
PF_5 = (PORT_F<<4|5),
// PF_6 = (PORT_F<<4|6),
// PF_7 = (PORT_F<<4|7),
PG_0 = (PORT_G<<4|0),
PG_1 = (PORT_G<<4|1),
PG_2 = (PORT_G<<4|2),
PG_3 = (PORT_G<<4|3),
PG_4 = (PORT_G<<4|4),
PG_5 = (PORT_G<<4|5),
PG_6 = (PORT_G<<4|6),
PG_7 = (PORT_G<<4|7),
PH_0 = (PORT_H<<4|0),
PH_1 = (PORT_H<<4|1),
PH_2 = (PORT_H<<4|2),
PH_3 = (PORT_H<<4|3),
PH_4 = (PORT_H<<4|4),
PH_5 = (PORT_H<<4|5),
PH_6 = (PORT_H<<4|6),
PH_7 = (PORT_H<<4|7),
PI_0 = (PORT_I<<4|0),
PI_1 = (PORT_I<<4|1),
PI_2 = (PORT_I<<4|2),
PI_3 = (PORT_I<<4|3),
PI_4 = (PORT_I<<4|4),
PI_5 = (PORT_I<<4|5),
PI_6 = (PORT_I<<4|6),
PI_7 = (PORT_I<<4|7),
PJ_0 = (PORT_J<<4|0),
PJ_1 = (PORT_J<<4|1),
PJ_2 = (PORT_J<<4|2),
PJ_3 = (PORT_J<<4|3),
PJ_4 = (PORT_J<<4|4),
PJ_5 = (PORT_J<<4|5),
PJ_6 = (PORT_J<<4|6),
// PJ_7 = (PORT_J<<4|7),
PK_0 = (PORT_K<<4|0),
PK_1 = (PORT_K<<4|1),
PK_2 = (PORT_K<<4|2),
PK_3 = (PORT_K<<4|3),
PK_4 = (PORT_K<<4|4),
PK_5 = (PORT_K<<4|5),
PK_6 = (PORT_K<<4|6),
// PK_7 = (PORT_K<<4|7),
AD_1 = (PORT_V<<4|1),
AD_2 = (PORT_V<<4|2),
AD_3 = (PORT_V<<4|3),
DA_0 = (PORT_U<<4|0),
DA_1 = (PORT_U<<4|1),
// 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_4,
LED2 = PB_5,
LED3 = PB_6,
LED4 = PB_7,
USER_BUTTON = PA_3,
SERIAL_TX = PA_7,
SERIAL_RX = PA_6,
USBTX = PA_7,
USBRX = PA_6,
I2C_SCL = PC_5,
I2C_SDA = PC_4,
SPI_MOSI = PC_2,
SPI_MISO = PC_3,
SPI_SCK = PC_1,
SPI_CS = PC_0,
PWM_OUT = PD_4,
// Not connected
NC = (uint32_t)0xFFFFFFFF
} PinName;
typedef enum {
PullNone = 0,
PullUp = 1,
PullDown = 2,
OpenDrain = 3,
PullDefault = PullNone
} PinMode;
#define PORT_NUM(pin) (((uint32_t)(pin) >> 4) & 0xF)
#define PIN_NUM(pin) ((uint32_t)(pin) & 0xF)
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,38 +1,38 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_PORTNAMES_H
#define MBED_PORTNAMES_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
PortA = 0,
PortB = 1,
PortC = 2,
PortD = 3,
PortE = 4,
PortF = 5,
PortG = 6,
PortH = 7,
PortI = 8
} PortName;
#ifdef __cplusplus
}
#endif
#endif
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_PORTNAMES_H
#define MBED_PORTNAMES_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
PortA = 0,
PortB = 1,
PortC = 2,
PortD = 3,
PortE = 4,
PortF = 5,
PortG = 6,
PortH = 7,
PortI = 8
} PortName;
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,48 +1,48 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#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_CAN 0
#define DEVICE_RTC 1
#define DEVICE_ETHERNET 1
#define DEVICE_PWMOUT 1
#define DEVICE_SLEEP 1
#include "objects.h"
#endif
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#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_CAN 0
#define DEVICE_RTC 1
#define DEVICE_ETHERNET 1
#define DEVICE_PWMOUT 1
#define DEVICE_SLEEP 1
#include "objects.h"
#endif

View file

@ -1,89 +1,89 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, Realtek
* All rights reserved.
*
* 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 "dma_api.h"
#include "cmsis.h"
extern BOOL HalGdmaMemCpyInit(PHAL_GDMA_OBJ pHalGdmaObj);
extern VOID HalGdmaMemCpyDeInit(PHAL_GDMA_OBJ pHalGdmaObj);
extern VOID* HalGdmaMemCpy(PHAL_GDMA_OBJ pHalGdmaObj, void* pDest, void* pSrc, u32 len);
extern VOID HalGdmaMemAggr(PHAL_GDMA_OBJ pHalGdmaObj, PHAL_GDMA_BLOCK pHalGdmaBlock);
extern BOOL HalGdmaMemCpyAggrInit(PHAL_GDMA_OBJ pHalGdmaObj);
/**
* @brief Initial the GDMA
*
* @param dma_obj: the GDMA object
* handler: the callback function for a DMA transfer complete.
* id: the argument of the callback function.
* @return None
*
*/
void dma_memcpy_aggr_init(gdma_t *dma_obj, dma_irq_handler handler, uint32_t id)
{
dma_obj->gdma_obj.GdmaIrqHandle.IrqFun = (IRQ_FUN)handler;
dma_obj->gdma_obj.GdmaIrqHandle.Data = (u32)id;
dma_obj->gdma_allocated = HalGdmaMemCpyAggrInit(&(dma_obj->gdma_obj));
}
void dma_memcpy_init(gdma_t *dma_obj, dma_irq_handler handler, uint32_t id)
{
dma_obj->gdma_obj.GdmaIrqHandle.IrqFun = (IRQ_FUN)handler;
dma_obj->gdma_obj.GdmaIrqHandle.Data = (u32)id;
dma_obj->gdma_allocated = HalGdmaMemCpyInit(&(dma_obj->gdma_obj));
}
/**
* @brief De-Initial the GDMA
*
* @param dma_obj: the GDMA object
* @return None
*
*/
void dma_memcpy_deinit(gdma_t *dma_obj)
{
if (dma_obj->gdma_allocated) {
HalGdmaMemCpyDeInit(&(dma_obj->gdma_obj));
}
}
/**
* @brief To do a memory copy by DMA
*
* @param None
* @return None
*
*/
void dma_memcpy(gdma_t *dma_obj, void *dst, void* src, uint32_t len)
{
#if 0
if (!dma_obj->gdma_allocated) {
dma_irq_handler handler;
_memcpy(dst, src, len);
handler = dma_obj->GdmaIrqHandle.IrqFun;
handler(dma_obj->GdmaIrqHandle.Data);
}
#endif
HalGdmaMemCpy(&(dma_obj->gdma_obj), dst, src, len);
}
void dma_memcpy_aggr(gdma_t *dma_obj, PHAL_GDMA_BLOCK block_info)
{
HalGdmaMemAggr(&(dma_obj->gdma_obj), block_info);
}
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, Realtek
* All rights reserved.
*
* 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 "dma_api.h"
#include "cmsis.h"
extern BOOL HalGdmaMemCpyInit(PHAL_GDMA_OBJ pHalGdmaObj);
extern VOID HalGdmaMemCpyDeInit(PHAL_GDMA_OBJ pHalGdmaObj);
extern VOID* HalGdmaMemCpy(PHAL_GDMA_OBJ pHalGdmaObj, void* pDest, void* pSrc, u32 len);
extern VOID HalGdmaMemAggr(PHAL_GDMA_OBJ pHalGdmaObj, PHAL_GDMA_BLOCK pHalGdmaBlock);
extern BOOL HalGdmaMemCpyAggrInit(PHAL_GDMA_OBJ pHalGdmaObj);
/**
* @brief Initial the GDMA
*
* @param dma_obj: the GDMA object
* handler: the callback function for a DMA transfer complete.
* id: the argument of the callback function.
* @return None
*
*/
void dma_memcpy_aggr_init(gdma_t *dma_obj, dma_irq_handler handler, uint32_t id)
{
dma_obj->gdma_obj.GdmaIrqHandle.IrqFun = (IRQ_FUN)handler;
dma_obj->gdma_obj.GdmaIrqHandle.Data = (u32)id;
dma_obj->gdma_allocated = HalGdmaMemCpyAggrInit(&(dma_obj->gdma_obj));
}
void dma_memcpy_init(gdma_t *dma_obj, dma_irq_handler handler, uint32_t id)
{
dma_obj->gdma_obj.GdmaIrqHandle.IrqFun = (IRQ_FUN)handler;
dma_obj->gdma_obj.GdmaIrqHandle.Data = (u32)id;
dma_obj->gdma_allocated = HalGdmaMemCpyInit(&(dma_obj->gdma_obj));
}
/**
* @brief De-Initial the GDMA
*
* @param dma_obj: the GDMA object
* @return None
*
*/
void dma_memcpy_deinit(gdma_t *dma_obj)
{
if (dma_obj->gdma_allocated) {
HalGdmaMemCpyDeInit(&(dma_obj->gdma_obj));
}
}
/**
* @brief To do a memory copy by DMA
*
* @param None
* @return None
*
*/
void dma_memcpy(gdma_t *dma_obj, void *dst, void* src, uint32_t len)
{
#if 0
if (!dma_obj->gdma_allocated) {
dma_irq_handler handler;
_memcpy(dst, src, len);
handler = dma_obj->GdmaIrqHandle.IrqFun;
handler(dma_obj->GdmaIrqHandle.Data);
}
#endif
HalGdmaMemCpy(&(dma_obj->gdma_obj), dst, src, len);
}
void dma_memcpy_aggr(gdma_t *dma_obj, PHAL_GDMA_BLOCK block_info)
{
HalGdmaMemAggr(&(dma_obj->gdma_obj), block_info);
}

View file

@ -1,241 +1,241 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
#include "objects.h"
#include "pinmap.h"
#if CONFIG_GPIO_EN
#include "gpio_api.h"
// convert Mbed pin mode to HAL Pin Mode
const u8 GPIO_InPinMode[] = {
DIN_PULL_NONE, // PullNone
DIN_PULL_HIGH, // PullUp
DIN_PULL_LOW, // PullDown
DIN_PULL_NONE // OpenDrain
};
const u8 GPIO_SWPORT_DR_TBL[] = {
GPIO_PORTA_DR,
GPIO_PORTB_DR,
GPIO_PORTC_DR
};
const u8 GPIO_EXT_PORT_TBL[] = {
GPIO_EXT_PORTA,
GPIO_EXT_PORTB,
GPIO_EXT_PORTC
};
const u8 GPIO_SWPORT_DDR_TBL[] = {
GPIO_PORTA_DDR,
GPIO_PORTB_DDR,
GPIO_PORTC_DDR
};
#if 0
void gpio_set_hal_pin_mode(gpio_t *obj)
{
if (obj->direction == PIN_OUTPUT) {
switch (obj->mode) {
case PullNone:
case PullDown:
case PullUp:
obj->hal_pin.pin_mode = DOUT_PUSH_PULL;
break;
case OpenDrain:
obj->hal_pin.pin_mode = DOUT_OPEN_DRAIN;
break;
default:
obj->hal_pin.pin_mode = DOUT_PUSH_PULL;
break;
}
}
else {
switch (obj->mode) {
case PullNone:
case OpenDrain:
obj->hal_pin.pin_mode = DIN_PULL_NONE;
break;
case PullDown:
obj->hal_pin.pin_mode = DIN_PULL_LOW;
break;
case PullUp:
obj->hal_pin.pin_mode = DIN_PULL_HIGH;
break;
default:
obj->hal_pin.pin_mode = DIN_PULL_NONE;
break;
}
}
}
#endif
void gpio_set_hal_pin_mode(gpio_t *obj)
{
uint32_t mode;
mode = obj->mode;
if (obj->direction == PIN_OUTPUT) {
if (mode == OpenDrain) {
obj->hal_pin.pin_mode = DOUT_OPEN_DRAIN;
} else {
obj->hal_pin.pin_mode = DOUT_PUSH_PULL;
}
} else {
if (mode < 4) {
obj->hal_pin.pin_mode = GPIO_InPinMode[mode];
} else {
obj->hal_pin.pin_mode = DIN_PULL_NONE;
}
}
}
uint32_t gpio_set(PinName pin)
{
u32 ip_pin;
//MBED_ASSERT(pin != (PinName)NC);
DBG_ASSERT(pin != (PinName)NC);
pin_function(pin, 0);
ip_pin = HAL_GPIO_GetPinName((u32)pin);
return ip_pin;
}
void gpio_init(gpio_t *obj, PinName pin)
{
uint32_t pin_name;
if (pin == (PinName)NC)
return;
obj->pin = pin;
obj->mode = PullNone;
obj->direction = PIN_INPUT;
pin_name = gpio_set(pin); // get the IP pin name
obj->hal_pin.pin_name = pin_name;
obj->hal_pin.pin_mode = DIN_PULL_NONE;
obj->hal_port_num = HAL_GPIO_GET_PORT_BY_NAME(pin_name);
obj->hal_pin_num = HAL_GPIO_GET_PIN_BY_NAME(pin_name);
HAL_GPIO_Init(&obj->hal_pin);
}
void gpio_mode(gpio_t *obj, PinMode mode)
{
obj->mode = mode;
gpio_set_hal_pin_mode(obj);
HAL_GPIO_Init(&obj->hal_pin);
}
// Initial the Pin direction
void gpio_dir(gpio_t *obj, PinDirection direction) {
// DBG_ASSERT(obj->pin != (PinName)NC);
obj->direction = direction;
gpio_set_hal_pin_mode(obj);
HAL_GPIO_Init(&obj->hal_pin);
}
// Change the pin direction directly
void gpio_change_dir(gpio_t *obj, PinDirection direction) {
uint32_t reg_value;
uint8_t port_num;
uint8_t pin_num;
obj->direction = direction;
gpio_set_hal_pin_mode(obj);
port_num = obj->hal_port_num;
pin_num = obj->hal_pin_num;
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_SWPORT_DDR_TBL[port_num]);
if (direction) {
// Out
reg_value |= (1 << pin_num);
} else {
// In
reg_value &= ~(1 << pin_num);
}
HAL_WRITE32(GPIO_REG_BASE, GPIO_SWPORT_DDR_TBL[port_num], reg_value);
}
void gpio_write(gpio_t *obj, int value)
{
HAL_GPIO_PIN *hal_pin=&obj->hal_pin;
volatile uint32_t reg_value;
uint8_t port_num;
uint8_t pin_num;
if (hal_pin->pin_mode != DOUT_OPEN_DRAIN) {
port_num = obj->hal_port_num;
pin_num = obj->hal_pin_num;
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num]);
reg_value &= ~(1 << pin_num);
reg_value |= ((value&0x01)<< pin_num);
HAL_WRITE32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num], reg_value);
} else {
HAL_GPIO_WritePin(&obj->hal_pin, value);
}
}
int gpio_read(gpio_t *obj) {
volatile uint32_t reg_value;
uint8_t port_num;
uint8_t pin_num;
// HAL_GPIO_PIN_STATE pin_status;
HAL_GPIO_PIN_MODE pin_mode;
port_num = obj->hal_port_num;
pin_num = obj->hal_pin_num;
pin_mode = obj->hal_pin.pin_mode;
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_EXT_PORT_TBL[port_num]);
if (pin_mode != DOUT_OPEN_DRAIN) {
return ((reg_value >> pin_num) & 0x01);
} else {
return (!((reg_value >> pin_num) & 0x01));
}
// return pin_status;
}
// This API only works for non-Open-Drain pin
void gpio_direct_write(gpio_t *obj, BOOL value)
{
uint8_t port_num;
uint8_t pin_num;
uint32_t reg_value;
port_num = obj->hal_port_num;
pin_num = obj->hal_pin_num;
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num]);
reg_value &= ~(1 << pin_num);
reg_value |= (value<< pin_num);
HAL_WRITE32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num], reg_value);
}
void gpio_pull_ctrl(gpio_t *obj, PinMode pull_type)
{
// obj->mode = pull_type;
// gpio_set_hal_pin_mode(obj);
HAL_GPIO_PullCtrl((u32) obj->pin, (u32)pull_type);
}
void gpio_deinit(gpio_t *obj) {
HAL_GPIO_DeInit(&obj->hal_pin);
}
#endif
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
#include "objects.h"
#include "pinmap.h"
#if CONFIG_GPIO_EN
#include "gpio_api.h"
// convert Mbed pin mode to HAL Pin Mode
const u8 GPIO_InPinMode[] = {
DIN_PULL_NONE, // PullNone
DIN_PULL_HIGH, // PullUp
DIN_PULL_LOW, // PullDown
DIN_PULL_NONE // OpenDrain
};
const u8 GPIO_SWPORT_DR_TBL[] = {
GPIO_PORTA_DR,
GPIO_PORTB_DR,
GPIO_PORTC_DR
};
const u8 GPIO_EXT_PORT_TBL[] = {
GPIO_EXT_PORTA,
GPIO_EXT_PORTB,
GPIO_EXT_PORTC
};
const u8 GPIO_SWPORT_DDR_TBL[] = {
GPIO_PORTA_DDR,
GPIO_PORTB_DDR,
GPIO_PORTC_DDR
};
#if 0
void gpio_set_hal_pin_mode(gpio_t *obj)
{
if (obj->direction == PIN_OUTPUT) {
switch (obj->mode) {
case PullNone:
case PullDown:
case PullUp:
obj->hal_pin.pin_mode = DOUT_PUSH_PULL;
break;
case OpenDrain:
obj->hal_pin.pin_mode = DOUT_OPEN_DRAIN;
break;
default:
obj->hal_pin.pin_mode = DOUT_PUSH_PULL;
break;
}
}
else {
switch (obj->mode) {
case PullNone:
case OpenDrain:
obj->hal_pin.pin_mode = DIN_PULL_NONE;
break;
case PullDown:
obj->hal_pin.pin_mode = DIN_PULL_LOW;
break;
case PullUp:
obj->hal_pin.pin_mode = DIN_PULL_HIGH;
break;
default:
obj->hal_pin.pin_mode = DIN_PULL_NONE;
break;
}
}
}
#endif
void gpio_set_hal_pin_mode(gpio_t *obj)
{
uint32_t mode;
mode = obj->mode;
if (obj->direction == PIN_OUTPUT) {
if (mode == OpenDrain) {
obj->hal_pin.pin_mode = DOUT_OPEN_DRAIN;
} else {
obj->hal_pin.pin_mode = DOUT_PUSH_PULL;
}
} else {
if (mode < 4) {
obj->hal_pin.pin_mode = GPIO_InPinMode[mode];
} else {
obj->hal_pin.pin_mode = DIN_PULL_NONE;
}
}
}
uint32_t gpio_set(PinName pin)
{
u32 ip_pin;
//MBED_ASSERT(pin != (PinName)NC);
DBG_ASSERT(pin != (PinName)NC);
pin_function(pin, 0);
ip_pin = HAL_GPIO_GetPinName((u32)pin);
return ip_pin;
}
void gpio_init(gpio_t *obj, PinName pin)
{
uint32_t pin_name;
if (pin == (PinName)NC)
return;
obj->pin = pin;
obj->mode = PullNone;
obj->direction = PIN_INPUT;
pin_name = gpio_set(pin); // get the IP pin name
obj->hal_pin.pin_name = pin_name;
obj->hal_pin.pin_mode = DIN_PULL_NONE;
obj->hal_port_num = HAL_GPIO_GET_PORT_BY_NAME(pin_name);
obj->hal_pin_num = HAL_GPIO_GET_PIN_BY_NAME(pin_name);
HAL_GPIO_Init(&obj->hal_pin);
}
void gpio_mode(gpio_t *obj, PinMode mode)
{
obj->mode = mode;
gpio_set_hal_pin_mode(obj);
HAL_GPIO_Init(&obj->hal_pin);
}
// Initial the Pin direction
void gpio_dir(gpio_t *obj, PinDirection direction) {
// DBG_ASSERT(obj->pin != (PinName)NC);
obj->direction = direction;
gpio_set_hal_pin_mode(obj);
HAL_GPIO_Init(&obj->hal_pin);
}
// Change the pin direction directly
void gpio_change_dir(gpio_t *obj, PinDirection direction) {
uint32_t reg_value;
uint8_t port_num;
uint8_t pin_num;
obj->direction = direction;
gpio_set_hal_pin_mode(obj);
port_num = obj->hal_port_num;
pin_num = obj->hal_pin_num;
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_SWPORT_DDR_TBL[port_num]);
if (direction) {
// Out
reg_value |= (1 << pin_num);
} else {
// In
reg_value &= ~(1 << pin_num);
}
HAL_WRITE32(GPIO_REG_BASE, GPIO_SWPORT_DDR_TBL[port_num], reg_value);
}
void gpio_write(gpio_t *obj, int value)
{
HAL_GPIO_PIN *hal_pin=&obj->hal_pin;
volatile uint32_t reg_value;
uint8_t port_num;
uint8_t pin_num;
if (hal_pin->pin_mode != DOUT_OPEN_DRAIN) {
port_num = obj->hal_port_num;
pin_num = obj->hal_pin_num;
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num]);
reg_value &= ~(1 << pin_num);
reg_value |= ((value&0x01)<< pin_num);
HAL_WRITE32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num], reg_value);
} else {
HAL_GPIO_WritePin(&obj->hal_pin, value);
}
}
int gpio_read(gpio_t *obj) {
volatile uint32_t reg_value;
uint8_t port_num;
uint8_t pin_num;
// HAL_GPIO_PIN_STATE pin_status;
HAL_GPIO_PIN_MODE pin_mode;
port_num = obj->hal_port_num;
pin_num = obj->hal_pin_num;
pin_mode = obj->hal_pin.pin_mode;
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_EXT_PORT_TBL[port_num]);
if (pin_mode != DOUT_OPEN_DRAIN) {
return ((reg_value >> pin_num) & 0x01);
} else {
return (!((reg_value >> pin_num) & 0x01));
}
// return pin_status;
}
// This API only works for non-Open-Drain pin
void gpio_direct_write(gpio_t *obj, BOOL value)
{
uint8_t port_num;
uint8_t pin_num;
uint32_t reg_value;
port_num = obj->hal_port_num;
pin_num = obj->hal_pin_num;
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num]);
reg_value &= ~(1 << pin_num);
reg_value |= (value<< pin_num);
HAL_WRITE32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num], reg_value);
}
void gpio_pull_ctrl(gpio_t *obj, PinMode pull_type)
{
// obj->mode = pull_type;
// gpio_set_hal_pin_mode(obj);
HAL_GPIO_PullCtrl((u32) obj->pin, (u32)pull_type);
}
void gpio_deinit(gpio_t *obj) {
HAL_GPIO_DeInit(&obj->hal_pin);
}
#endif

View file

@ -1,145 +1,145 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
#include "objects.h"
#include "pinmap.h"
//static uint32_t channel_ids[32] = {0};
//static gpio_irq_handler irq_handler;
#if CONFIG_GPIO_EN
#include "gpio_irq_api.h"
#include "gpio_irq_ex_api.h"
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id)
{
uint32_t pin_name;
if (pin == NC) return -1;
obj->pin = pin;
pin_name = HAL_GPIO_GetPinName((u32)pin);; // get the IP pin name
obj->hal_pin.pin_name = pin_name;
obj->hal_pin.pin_mode = INT_FALLING; // default use Falling trigger
obj->hal_port_num = HAL_GPIO_GET_PORT_BY_NAME(pin_name);
obj->hal_pin_num = HAL_GPIO_GET_PIN_BY_NAME(pin_name);
HAL_GPIO_Irq_Init(&obj->hal_pin);
HAL_GPIO_UserRegIrq(&obj->hal_pin, (VOID*) handler, (VOID*) id);
return 0;
}
void gpio_irq_free(gpio_irq_t *obj)
{
HAL_GPIO_UserUnRegIrq(&obj->hal_pin);
HAL_GPIO_DeInit(&obj->hal_pin);
}
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
{
switch((uint32_t)event) {
case IRQ_RISE:
obj->hal_pin.pin_mode = INT_RISING;
break;
case IRQ_FALL:
obj->hal_pin.pin_mode = INT_FALLING;
break;
case IRQ_LOW:
obj->hal_pin.pin_mode = INT_LOW;
break;
case IRQ_HIGH:
obj->hal_pin.pin_mode = INT_HIGH;
break;
case IRQ_NONE:
// ?
break;
default:
break;
}
// HAL_GPIO_Irq_Init(&obj->hal_pin);
HAL_GPIO_Init_8195a(&obj->hal_pin);
HAL_GPIO_IntCtrl(&obj->hal_pin, enable);
}
void gpio_irq_enable(gpio_irq_t *obj)
{
HAL_GPIO_UnMaskIrq(&obj->hal_pin);
}
void gpio_irq_disable(gpio_irq_t *obj)
{
HAL_GPIO_MaskIrq(&obj->hal_pin);
}
void gpio_irq_deinit(gpio_irq_t *obj)
{
HAL_GPIO_DeInit(&obj->hal_pin);
}
void gpio_irq_pull_ctrl(gpio_irq_t *obj, PinMode pull_type)
{
HAL_GPIO_PullCtrl((u32) obj->pin, (u32)pull_type);
}
void gpio_irq_set_event(gpio_irq_t *obj, gpio_irq_event event)
{
uint32_t reg_value;
uint32_t level_edge;
uint32_t polarity;
uint8_t pin_num;
pin_num = obj->hal_pin_num & 0x1f; // Max 31
switch (event) {
case IRQ_LOW:
level_edge = 0; // level trigger
polarity = 0; // active low
break;
case IRQ_HIGH:
level_edge = 0; // level trigger
polarity = 1; // active high
break;
case IRQ_FALL:
level_edge = 1; // edge trigger
polarity = 0; // active low
break;
case IRQ_RISE:
level_edge = 1; // edge trigger
polarity = 1; // active high
break;
default:
DBG_GPIO_ERR("Unknow Interrupt Trigger Type(%d)\n", event);
return;
}
// Config Level or Edge trigger
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_INT_TYPE);
reg_value &= ~(1 << pin_num);
reg_value |= (level_edge << pin_num);
HAL_WRITE32(GPIO_REG_BASE, GPIO_INT_TYPE, reg_value);
// Config Low active or Gigh active
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_INT_POLARITY);
reg_value &= ~(1 << pin_num);
reg_value |= (polarity << pin_num);
HAL_WRITE32(GPIO_REG_BASE, GPIO_INT_POLARITY, reg_value);
}
#endif
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
#include "objects.h"
#include "pinmap.h"
//static uint32_t channel_ids[32] = {0};
//static gpio_irq_handler irq_handler;
#if CONFIG_GPIO_EN
#include "gpio_irq_api.h"
#include "gpio_irq_ex_api.h"
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id)
{
uint32_t pin_name;
if (pin == NC) return -1;
obj->pin = pin;
pin_name = HAL_GPIO_GetPinName((u32)pin);; // get the IP pin name
obj->hal_pin.pin_name = pin_name;
obj->hal_pin.pin_mode = INT_FALLING; // default use Falling trigger
obj->hal_port_num = HAL_GPIO_GET_PORT_BY_NAME(pin_name);
obj->hal_pin_num = HAL_GPIO_GET_PIN_BY_NAME(pin_name);
HAL_GPIO_Irq_Init(&obj->hal_pin);
HAL_GPIO_UserRegIrq(&obj->hal_pin, (VOID*) handler, (VOID*) id);
return 0;
}
void gpio_irq_free(gpio_irq_t *obj)
{
HAL_GPIO_UserUnRegIrq(&obj->hal_pin);
HAL_GPIO_DeInit(&obj->hal_pin);
}
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
{
switch((uint32_t)event) {
case IRQ_RISE:
obj->hal_pin.pin_mode = INT_RISING;
break;
case IRQ_FALL:
obj->hal_pin.pin_mode = INT_FALLING;
break;
case IRQ_LOW:
obj->hal_pin.pin_mode = INT_LOW;
break;
case IRQ_HIGH:
obj->hal_pin.pin_mode = INT_HIGH;
break;
case IRQ_NONE:
// ?
break;
default:
break;
}
// HAL_GPIO_Irq_Init(&obj->hal_pin);
HAL_GPIO_Init_8195a(&obj->hal_pin);
HAL_GPIO_IntCtrl(&obj->hal_pin, enable);
}
void gpio_irq_enable(gpio_irq_t *obj)
{
HAL_GPIO_UnMaskIrq(&obj->hal_pin);
}
void gpio_irq_disable(gpio_irq_t *obj)
{
HAL_GPIO_MaskIrq(&obj->hal_pin);
}
void gpio_irq_deinit(gpio_irq_t *obj)
{
HAL_GPIO_DeInit(&obj->hal_pin);
}
void gpio_irq_pull_ctrl(gpio_irq_t *obj, PinMode pull_type)
{
HAL_GPIO_PullCtrl((u32) obj->pin, (u32)pull_type);
}
void gpio_irq_set_event(gpio_irq_t *obj, gpio_irq_event event)
{
uint32_t reg_value;
uint32_t level_edge;
uint32_t polarity;
uint8_t pin_num;
pin_num = obj->hal_pin_num & 0x1f; // Max 31
switch (event) {
case IRQ_LOW:
level_edge = 0; // level trigger
polarity = 0; // active low
break;
case IRQ_HIGH:
level_edge = 0; // level trigger
polarity = 1; // active high
break;
case IRQ_FALL:
level_edge = 1; // edge trigger
polarity = 0; // active low
break;
case IRQ_RISE:
level_edge = 1; // edge trigger
polarity = 1; // active high
break;
default:
DBG_GPIO_ERR("Unknow Interrupt Trigger Type(%d)\n", event);
return;
}
// Config Level or Edge trigger
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_INT_TYPE);
reg_value &= ~(1 << pin_num);
reg_value |= (level_edge << pin_num);
HAL_WRITE32(GPIO_REG_BASE, GPIO_INT_TYPE, reg_value);
// Config Low active or Gigh active
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_INT_POLARITY);
reg_value &= ~(1 << pin_num);
reg_value |= (polarity << pin_num);
HAL_WRITE32(GPIO_REG_BASE, GPIO_INT_POLARITY, reg_value);
}
#endif

View file

@ -1,39 +1,39 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_GPIO_OBJECT_H
#define MBED_GPIO_OBJECT_H
#include "mbed_assert.h"
#include "basic_types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PinName pin;
uint32_t mask;
uint32_t reg_out_offset;
uint32_t reg_dir_offset;
} gpio_t;
#ifdef __cplusplus
}
#endif
#endif
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_GPIO_OBJECT_H
#define MBED_GPIO_OBJECT_H
#include "mbed_assert.h"
#include "basic_types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PinName pin;
uint32_t mask;
uint32_t reg_out_offset;
uint32_t reg_dir_offset;
} gpio_t;
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,243 +1,243 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
#include "objects.h"
#include "pinmap.h"
#if CONFIG_NFC_NORMAL
#include "nfc_api.h"
/**
* @brief The NFC tag write callback function wrapper
*
* @return None
*
*/
void nfc_tagwrite_callback(PNFC_ADAPTER pNFCAdp, uint32_t page, uint32_t wr_data)
{
nfctag_t *obj;
nfc_write_cb handler;
obj = pNFCAdp->nfc_obj;
handler = (nfc_write_cb)obj->nfc_wr_cb;
if (NULL != handler) {
handler(obj->wr_cb_arg, page, wr_data);
}
}
/**
* @brief The NFC tag read callback function wrapper
*
* @return None
*
*/
void nfc_event_callback(PNFC_ADAPTER pNFCAdp, uint32_t event)
{
nfctag_t *obj;
nfc_event_cb handler;
obj = pNFCAdp->nfc_obj;
handler = (nfc_event_cb)obj->nfc_ev_cb;
if (NULL != handler) {
if (obj->event_mask & event) {
handler(obj->ev_cb_arg, event);
}
}
}
/**
* @brief The NFC tag read callback function wrapper
*
* @return None
*
*/
void nfc_tagread_callback(PNFC_ADAPTER pNFCAdp, uint32_t page)
{
// notify upper layer when read tag page 0 only
if (0 == page) {
nfc_event_callback(pNFCAdp, NFC_EV_READ);
}
}
/**
* @brief The NFC cache read done callback function wrapper
*
* @return None
*
*/
void nfc_cache_read_callback(PNFC_ADAPTER pNFCAdp, uint32_t start_pg, uint32_t *pbuf)
{
nfctag_t *obj;
nfc_write_cb handler;
obj = pNFCAdp->nfc_obj;
handler = (nfc_write_cb)obj->nfc_cache_rd_cb;
if (NULL != handler) {
handler(obj->cache_read_cb_arg, start_pg, (uint32_t)pbuf);
}
}
/**
* @brief To initial NFC tag hardware and resource
*
* @return The result
*
*/
int nfc_init(nfctag_t *obj, uint32_t *pg_init_val)
{
_memset((void *)obj, 0, sizeof(nfctag_t));
HalNFCDmemInit(pg_init_val, NFCTAGLENGTH);
HalNFCInit(&(obj->NFCAdapter));
HalNFCFwDownload();
obj->NFCAdapter.nfc_obj = obj;
obj->pwr_status = NFC_PWR_RUNNING;
return NFC_OK;
}
/**
* @brief To free NFC tag hardware and resource
*
* @return The result
*
*/
int nfc_free(nfctag_t *obj)
{
HalNFCDeinit(&(obj->NFCAdapter));
return NFC_OK;
}
/**
* @brief To register the callback function for NFC read occurred
*
* @return None
*
*/
void nfc_read(nfctag_t *obj, nfc_read_cb handler, void *arg)
{
obj->nfc_rd_cb = (void *)handler;
obj->rd_cb_arg = arg;
}
/**
* @brief To register the callback function for NFC write occurred
*
* @return None
*
*/
void nfc_write(nfctag_t *obj, nfc_write_cb handler, void *arg)
{
obj->nfc_wr_cb = (void *)handler;
obj->wr_cb_arg = arg;
}
/**
* @brief To register the callback function for NFC events occurred
* and the event mask
*
* @return None
*
*/
void nfc_event(nfctag_t *obj, nfc_event_cb handler, void *arg, unsigned int event_mask)
{
obj->nfc_ev_cb = (void *)handler;
obj->ev_cb_arg = arg;
obj->event_mask = event_mask;
}
/**
* @brief To set a new power mode to the NFC device
*
* @return The result
*
*/
int nfc_power(nfctag_t *obj, int pwr_mode, int wake_event)
{
// TODO:
return NFC_OK;
}
/**
* @brief to update the NFC read cache. The data in the NFC read cache
* buffer will be transmitted out when NFC read occurred
*
* @return The result
*
*/
int nfc_cache_write(nfctag_t *obj, uint32_t *tbuf, unsigned int spage, unsigned int pg_num)
{
u8 remain_pg;
u8 pg_offset=0;
u8 i;
if ((spage+pg_num) > NFC_MAX_CACHE_PAGE_NUM) {
return NFC_ERROR;
}
remain_pg = pg_num;
while (remain_pg > 0) {
if (remain_pg >= 4) {
A2NWriteCatch (&obj->NFCAdapter, (spage+pg_offset), 4, (u32*)(&tbuf[pg_offset]));
remain_pg -= 4;
pg_offset += 4;
}
else {
for(i=0;i<remain_pg;i++) {
A2NWriteCatch (&obj->NFCAdapter, (spage+pg_offset), 1, (u32*)(&tbuf[pg_offset]));
pg_offset++;
}
remain_pg = 0;
}
}
return NFC_OK;
}
/**
* @brief To get current NFC status
*
* @return The result
*
*/
int nfc_cache_raed(nfctag_t *obj, nfc_cache_read_cb handler,
void *arg, unsigned int start_pg)
{
if (start_pg > NFC_MAX_CACHE_PAGE_NUM) {
return NFC_ERROR;
}
obj->nfc_cache_rd_cb = (void *)handler;
obj->cache_read_cb_arg = arg;
A2NReadCatch(&(obj->NFCAdapter), (u8)start_pg);
return NFC_OK;
}
/**
* @brief to read back the NFC read cache.
*
* @return The result
*
*/
int nfc_status(nfctag_t *obj)
{
// TODO:
return (obj->pwr_status);
}
#endif
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
#include "objects.h"
#include "pinmap.h"
#if CONFIG_NFC_NORMAL
#include "nfc_api.h"
/**
* @brief The NFC tag write callback function wrapper
*
* @return None
*
*/
void nfc_tagwrite_callback(PNFC_ADAPTER pNFCAdp, uint32_t page, uint32_t wr_data)
{
nfctag_t *obj;
nfc_write_cb handler;
obj = pNFCAdp->nfc_obj;
handler = (nfc_write_cb)obj->nfc_wr_cb;
if (NULL != handler) {
handler(obj->wr_cb_arg, page, wr_data);
}
}
/**
* @brief The NFC tag read callback function wrapper
*
* @return None
*
*/
void nfc_event_callback(PNFC_ADAPTER pNFCAdp, uint32_t event)
{
nfctag_t *obj;
nfc_event_cb handler;
obj = pNFCAdp->nfc_obj;
handler = (nfc_event_cb)obj->nfc_ev_cb;
if (NULL != handler) {
if (obj->event_mask & event) {
handler(obj->ev_cb_arg, event);
}
}
}
/**
* @brief The NFC tag read callback function wrapper
*
* @return None
*
*/
void nfc_tagread_callback(PNFC_ADAPTER pNFCAdp, uint32_t page)
{
// notify upper layer when read tag page 0 only
if (0 == page) {
nfc_event_callback(pNFCAdp, NFC_EV_READ);
}
}
/**
* @brief The NFC cache read done callback function wrapper
*
* @return None
*
*/
void nfc_cache_read_callback(PNFC_ADAPTER pNFCAdp, uint32_t start_pg, uint32_t *pbuf)
{
nfctag_t *obj;
nfc_write_cb handler;
obj = pNFCAdp->nfc_obj;
handler = (nfc_write_cb)obj->nfc_cache_rd_cb;
if (NULL != handler) {
handler(obj->cache_read_cb_arg, start_pg, (uint32_t)pbuf);
}
}
/**
* @brief To initial NFC tag hardware and resource
*
* @return The result
*
*/
int nfc_init(nfctag_t *obj, uint32_t *pg_init_val)
{
_memset((void *)obj, 0, sizeof(nfctag_t));
HalNFCDmemInit(pg_init_val, NFCTAGLENGTH);
HalNFCInit(&(obj->NFCAdapter));
HalNFCFwDownload();
obj->NFCAdapter.nfc_obj = obj;
obj->pwr_status = NFC_PWR_RUNNING;
return NFC_OK;
}
/**
* @brief To free NFC tag hardware and resource
*
* @return The result
*
*/
int nfc_free(nfctag_t *obj)
{
HalNFCDeinit(&(obj->NFCAdapter));
return NFC_OK;
}
/**
* @brief To register the callback function for NFC read occurred
*
* @return None
*
*/
void nfc_read(nfctag_t *obj, nfc_read_cb handler, void *arg)
{
obj->nfc_rd_cb = (void *)handler;
obj->rd_cb_arg = arg;
}
/**
* @brief To register the callback function for NFC write occurred
*
* @return None
*
*/
void nfc_write(nfctag_t *obj, nfc_write_cb handler, void *arg)
{
obj->nfc_wr_cb = (void *)handler;
obj->wr_cb_arg = arg;
}
/**
* @brief To register the callback function for NFC events occurred
* and the event mask
*
* @return None
*
*/
void nfc_event(nfctag_t *obj, nfc_event_cb handler, void *arg, unsigned int event_mask)
{
obj->nfc_ev_cb = (void *)handler;
obj->ev_cb_arg = arg;
obj->event_mask = event_mask;
}
/**
* @brief To set a new power mode to the NFC device
*
* @return The result
*
*/
int nfc_power(nfctag_t *obj, int pwr_mode, int wake_event)
{
// TODO:
return NFC_OK;
}
/**
* @brief to update the NFC read cache. The data in the NFC read cache
* buffer will be transmitted out when NFC read occurred
*
* @return The result
*
*/
int nfc_cache_write(nfctag_t *obj, uint32_t *tbuf, unsigned int spage, unsigned int pg_num)
{
u8 remain_pg;
u8 pg_offset=0;
u8 i;
if ((spage+pg_num) > NFC_MAX_CACHE_PAGE_NUM) {
return NFC_ERROR;
}
remain_pg = pg_num;
while (remain_pg > 0) {
if (remain_pg >= 4) {
A2NWriteCatch (&obj->NFCAdapter, (spage+pg_offset), 4, (u32*)(&tbuf[pg_offset]));
remain_pg -= 4;
pg_offset += 4;
}
else {
for(i=0;i<remain_pg;i++) {
A2NWriteCatch (&obj->NFCAdapter, (spage+pg_offset), 1, (u32*)(&tbuf[pg_offset]));
pg_offset++;
}
remain_pg = 0;
}
}
return NFC_OK;
}
/**
* @brief To get current NFC status
*
* @return The result
*
*/
int nfc_cache_raed(nfctag_t *obj, nfc_cache_read_cb handler,
void *arg, unsigned int start_pg)
{
if (start_pg > NFC_MAX_CACHE_PAGE_NUM) {
return NFC_ERROR;
}
obj->nfc_cache_rd_cb = (void *)handler;
obj->cache_read_cb_arg = arg;
A2NReadCatch(&(obj->NFCAdapter), (u8)start_pg);
return NFC_OK;
}
/**
* @brief to read back the NFC read cache.
*
* @return The result
*
*/
int nfc_status(nfctag_t *obj)
{
// TODO:
return (obj->pwr_status);
}
#endif

View file

@ -1,206 +1,206 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#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
#ifdef CONFIG_GPIO_EN
struct gpio_irq_s {
PinName pin;
uint32_t event;
HAL_GPIO_PIN hal_pin;
uint8_t hal_port_num;
uint8_t hal_pin_num;
};
typedef struct gpio_irq_s gpio_irq_t;
struct gpio_s {
PinName pin;
PinMode mode;
PinDirection direction;
HAL_GPIO_PIN hal_pin;
uint8_t hal_port_num;
uint8_t hal_pin_num;
};
typedef struct gpio_s gpio_t;
struct port_s {
PortName port;
uint32_t mask;
PinDirection direction;
uint8_t *pin_def;
};
#endif // end of "#ifdef CONFIG_GPIO_EN"
#ifdef CONFIG_UART_EN
struct serial_s {
HAL_RUART_OP hal_uart_op;
HAL_RUART_ADAPTER hal_uart_adp;
#ifdef CONFIG_GDMA_EN
UART_DMA_CONFIG uart_gdma_cfg;
HAL_GDMA_ADAPTER uart_gdma_adp_tx;
HAL_GDMA_ADAPTER uart_gdma_adp_rx;
UART_DMA_MULTIBLK gdma_multiblk_list_tx;
UART_DMA_MULTIBLK gdma_multiblk_list_rx;
#endif
uint32_t tx_len;
uint32_t rx_len;
};
#endif // end of "#ifdef CONFIG_UART_EN"
struct log_uart_s {
HAL_LOG_UART_ADAPTER log_hal_uart;
};
#ifdef CONFIG_SPI_COM_EN
#endif
#ifdef CONFIG_PWM_EN
struct pwmout_s {
uint8_t pwm_idx;
uint8_t pin_sel;
uint32_t period;
uint32_t pulse;
HAL_PWM_ADAPTER pwm_hal_adp;
};
#endif
#ifdef CONFIG_I2C_EN
struct i2c_s {
SAL_I2C_MNGT_ADPT SalI2CMngtAdpt;
SAL_I2C_HND_PRIV SalI2CHndPriv;
HAL_I2C_INIT_DAT HalI2CInitData;
HAL_I2C_OP HalI2COp;
IRQ_HANDLE I2CIrqHandleDat;
HAL_GDMA_ADAPTER HalI2CTxGdmaAdpt;
HAL_GDMA_ADAPTER HalI2CRxGdmaAdpt;
HAL_GDMA_OP HalI2CGdmaOp;
IRQ_HANDLE I2CTxGdmaIrqHandleDat;
IRQ_HANDLE I2CRxGdmaIrqHandleDat;
SAL_I2C_USER_CB SalI2CUserCB;
SAL_I2C_USERCB_ADPT SalI2CUserCBAdpt[SAL_USER_CB_NUM];
SAL_I2C_DMA_USER_DEF SalI2CDmaUserDef;
};
#endif
struct flash_s
{
SPIC_INIT_PARA SpicInitPara;
u32 Length;
};
#ifdef CONFIG_ADC_EN
struct analogin_s {
SAL_ADC_MNGT_ADPT SalADCMngtAdpt;
SAL_ADC_HND_PRIV SalADCHndPriv;
HAL_ADC_INIT_DAT HalADCInitData;
HAL_ADC_OP HalADCOp;
IRQ_HANDLE ADCIrqHandleDat;
HAL_GDMA_ADAPTER HalADCGdmaAdpt;
HAL_GDMA_OP HalADCGdmaOp;
IRQ_HANDLE ADCGdmaIrqHandleDat;
SAL_ADC_USER_CB SalADCUserCB;
SAL_ADC_USERCB_ADPT SalADCUserCBAdpt[SAL_ADC_USER_CB_NUM];
};
#endif
#if 0
struct i2c_s {
I2C_Type *i2c;
};
struct spi_s {
SPI_Type *spi;
};
#endif
#ifdef CONFIG_NFC_EN
struct nfctag_s {
NFC_ADAPTER NFCAdapter;
void *nfc_rd_cb; // read callback function
void *rd_cb_arg;
void *nfc_wr_cb; // write callback function
void *wr_cb_arg;
void *nfc_ev_cb; // event callback function
void *ev_cb_arg;
void *nfc_cache_rd_cb; // cache read callback function
void *cache_read_cb_arg;
unsigned int event_mask;
int pwr_status;
};
#endif
#ifdef CONFIG_TIMER_EN
struct gtimer_s {
TIMER_ADAPTER hal_gtimer_adp;
void *handler;
u32 hid;
u8 timer_id;
u8 is_periodcal;
};
#endif
#ifdef CONFIG_I2S_EN
struct i2s_s {
HAL_I2S_ADAPTER I2SAdapter;
HAL_I2S_INIT_DAT InitDat;
u8 sampling_rate;
u8 channel_num;
u8 word_length;
u8 direction;
};
#endif
#ifdef CONFIG_DAC_EN
/** \file objects.h
* \brief A Documented file.
*
* A documented file.
*/
/** \struct dac_s objects.h "rtl8195a/objects.h"
* \brief This is a dac_s structure.
*
* For analogout APIs, a pointer to dac_s is used as an input paras.
* A DAC initial data structure is the major element of dac_s.
*/
struct dac_s {
HAL_DAC_INIT_DAT DACpara;
};
#endif
#ifdef __cplusplus
}
#endif
#endif
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#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
#ifdef CONFIG_GPIO_EN
struct gpio_irq_s {
PinName pin;
uint32_t event;
HAL_GPIO_PIN hal_pin;
uint8_t hal_port_num;
uint8_t hal_pin_num;
};
typedef struct gpio_irq_s gpio_irq_t;
struct gpio_s {
PinName pin;
PinMode mode;
PinDirection direction;
HAL_GPIO_PIN hal_pin;
uint8_t hal_port_num;
uint8_t hal_pin_num;
};
typedef struct gpio_s gpio_t;
struct port_s {
PortName port;
uint32_t mask;
PinDirection direction;
uint8_t *pin_def;
};
#endif // end of "#ifdef CONFIG_GPIO_EN"
#ifdef CONFIG_UART_EN
struct serial_s {
HAL_RUART_OP hal_uart_op;
HAL_RUART_ADAPTER hal_uart_adp;
#ifdef CONFIG_GDMA_EN
UART_DMA_CONFIG uart_gdma_cfg;
HAL_GDMA_ADAPTER uart_gdma_adp_tx;
HAL_GDMA_ADAPTER uart_gdma_adp_rx;
UART_DMA_MULTIBLK gdma_multiblk_list_tx;
UART_DMA_MULTIBLK gdma_multiblk_list_rx;
#endif
uint32_t tx_len;
uint32_t rx_len;
};
#endif // end of "#ifdef CONFIG_UART_EN"
struct log_uart_s {
HAL_LOG_UART_ADAPTER log_hal_uart;
};
#ifdef CONFIG_SPI_COM_EN
#endif
#ifdef CONFIG_PWM_EN
struct pwmout_s {
uint8_t pwm_idx;
uint8_t pin_sel;
uint32_t period;
uint32_t pulse;
HAL_PWM_ADAPTER pwm_hal_adp;
};
#endif
#ifdef CONFIG_I2C_EN
struct i2c_s {
SAL_I2C_MNGT_ADPT SalI2CMngtAdpt;
SAL_I2C_HND_PRIV SalI2CHndPriv;
HAL_I2C_INIT_DAT HalI2CInitData;
HAL_I2C_OP HalI2COp;
IRQ_HANDLE I2CIrqHandleDat;
HAL_GDMA_ADAPTER HalI2CTxGdmaAdpt;
HAL_GDMA_ADAPTER HalI2CRxGdmaAdpt;
HAL_GDMA_OP HalI2CGdmaOp;
IRQ_HANDLE I2CTxGdmaIrqHandleDat;
IRQ_HANDLE I2CRxGdmaIrqHandleDat;
SAL_I2C_USER_CB SalI2CUserCB;
SAL_I2C_USERCB_ADPT SalI2CUserCBAdpt[SAL_USER_CB_NUM];
SAL_I2C_DMA_USER_DEF SalI2CDmaUserDef;
};
#endif
struct flash_s
{
SPIC_INIT_PARA SpicInitPara;
u32 Length;
};
#ifdef CONFIG_ADC_EN
struct analogin_s {
SAL_ADC_MNGT_ADPT SalADCMngtAdpt;
SAL_ADC_HND_PRIV SalADCHndPriv;
HAL_ADC_INIT_DAT HalADCInitData;
HAL_ADC_OP HalADCOp;
IRQ_HANDLE ADCIrqHandleDat;
HAL_GDMA_ADAPTER HalADCGdmaAdpt;
HAL_GDMA_OP HalADCGdmaOp;
IRQ_HANDLE ADCGdmaIrqHandleDat;
SAL_ADC_USER_CB SalADCUserCB;
SAL_ADC_USERCB_ADPT SalADCUserCBAdpt[SAL_ADC_USER_CB_NUM];
};
#endif
#if 0
struct i2c_s {
I2C_Type *i2c;
};
struct spi_s {
SPI_Type *spi;
};
#endif
#ifdef CONFIG_NFC_EN
struct nfctag_s {
NFC_ADAPTER NFCAdapter;
void *nfc_rd_cb; // read callback function
void *rd_cb_arg;
void *nfc_wr_cb; // write callback function
void *wr_cb_arg;
void *nfc_ev_cb; // event callback function
void *ev_cb_arg;
void *nfc_cache_rd_cb; // cache read callback function
void *cache_read_cb_arg;
unsigned int event_mask;
int pwr_status;
};
#endif
#ifdef CONFIG_TIMER_EN
struct gtimer_s {
TIMER_ADAPTER hal_gtimer_adp;
void *handler;
u32 hid;
u8 timer_id;
u8 is_periodcal;
};
#endif
#ifdef CONFIG_I2S_EN
struct i2s_s {
HAL_I2S_ADAPTER I2SAdapter;
HAL_I2S_INIT_DAT InitDat;
u8 sampling_rate;
u8 channel_num;
u8 word_length;
u8 direction;
};
#endif
#ifdef CONFIG_DAC_EN
/** \file objects.h
* \brief A Documented file.
*
* A documented file.
*/
/** \struct dac_s objects.h "rtl8195a/objects.h"
* \brief This is a dac_s structure.
*
* For analogout APIs, a pointer to dac_s is used as an input paras.
* A DAC initial data structure is the major element of dac_s.
*/
struct dac_s {
HAL_DAC_INIT_DAT DACpara;
};
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,34 +1,34 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
//#include "mbed_assert.h"
#include "objects.h"
#include "pinmap.h"
//#include "error.h"
/**
* Configure pin enable and function
*/
void pin_function(PinName pin, int function)
{
// MBED_ASSERT(pin != (PinName)NC);
//1 Our HAL API cannot support to configure the pin function by this way
/* the pin function (pin mux) is depends on each IP On/Off and priority, so we cannot
set the pin function directly */
}
/**
* Configure pin pull-up/pull-down
*/
void pin_mode(PinName pin, PinMode mode)
{
// MBED_ASSERT(pin != (PinName)NC);
HAL_GPIO_PullCtrl((u32)pin, (u32)mode);
}
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
//#include "mbed_assert.h"
#include "objects.h"
#include "pinmap.h"
//#include "error.h"
/**
* Configure pin enable and function
*/
void pin_function(PinName pin, int function)
{
// MBED_ASSERT(pin != (PinName)NC);
//1 Our HAL API cannot support to configure the pin function by this way
/* the pin function (pin mux) is depends on each IP On/Off and priority, so we cannot
set the pin function directly */
}
/**
* Configure pin pull-up/pull-down
*/
void pin_mode(PinName pin, PinMode mode)
{
// MBED_ASSERT(pin != (PinName)NC);
HAL_GPIO_PullCtrl((u32)pin, (u32)mode);
}

View file

@ -1,73 +1,73 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "basic_types.h"
#include "diag.h"
#include "pinmap.h"
//#include "error.h"
__weak void pinmap_pinout(PinName pin, const PinMap *map) {
#if 0
if (pin == NC)
return;
while (map->pin != NC) {
if (map->pin == pin) {
pin_function(pin, map->function);
pin_mode(pin, PullNone);
return;
}
map++;
}
DBG_GPIO_ERR("%s: could not pinout\n", __FUNCTION__);
#endif
}
__weak uint32_t pinmap_merge(uint32_t a, uint32_t b) {
// both are the same (inc both NC)
if (a == b)
return a;
// one (or both) is not connected
if (a == (uint32_t)NC)
return b;
if (b == (uint32_t)NC)
return a;
// mis-match error case
DBG_GPIO_ERR("%s: pinmap mis-match\n", __FUNCTION__);
return (uint32_t)NC;
}
__weak uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) {
while (map->pin != NC) {
if (map->pin == pin)
return map->peripheral;
map++;
}
return (uint32_t)NC;
}
__weak uint32_t pinmap_peripheral(PinName pin, const PinMap* map) {
uint32_t peripheral = (uint32_t)NC;
if (pin == (PinName)NC)
return (uint32_t)NC;
peripheral = pinmap_find_peripheral(pin, map);
if ((uint32_t)NC == peripheral) // no mapping available
DBG_GPIO_ERR("%s: pinmap not found for peripheral\n", __FUNCTION__);
return peripheral;
}
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "basic_types.h"
#include "diag.h"
#include "pinmap.h"
//#include "error.h"
__weak void pinmap_pinout(PinName pin, const PinMap *map) {
#if 0
if (pin == NC)
return;
while (map->pin != NC) {
if (map->pin == pin) {
pin_function(pin, map->function);
pin_mode(pin, PullNone);
return;
}
map++;
}
DBG_GPIO_ERR("%s: could not pinout\n", __FUNCTION__);
#endif
}
__weak uint32_t pinmap_merge(uint32_t a, uint32_t b) {
// both are the same (inc both NC)
if (a == b)
return a;
// one (or both) is not connected
if (a == (uint32_t)NC)
return b;
if (b == (uint32_t)NC)
return a;
// mis-match error case
DBG_GPIO_ERR("%s: pinmap mis-match\n", __FUNCTION__);
return (uint32_t)NC;
}
__weak uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) {
while (map->pin != NC) {
if (map->pin == pin)
return map->peripheral;
map++;
}
return (uint32_t)NC;
}
__weak uint32_t pinmap_peripheral(PinName pin, const PinMap* map) {
uint32_t peripheral = (uint32_t)NC;
if (pin == (PinName)NC)
return (uint32_t)NC;
peripheral = pinmap_find_peripheral(pin, map);
if ((uint32_t)NC == peripheral) // no mapping available
DBG_GPIO_ERR("%s: pinmap not found for peripheral\n", __FUNCTION__);
return peripheral;
}

View file

@ -1,290 +1,290 @@
/* 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 "sleep_ex_api.h"
#include "cmsis.h"
extern VOID SleepCG(u8 Option, u32 SDuration, u8 ClkSourceEn, u8 SDREn);
extern VOID DeepStandby(u8 Option, u32 SDuration, u8 GpioOption);
extern VOID DeepSleep(u8 Option, u32 SDuration);
SLEEP_WAKEUP_EVENT DStandbyWakeupEvent={0};
/**
* @brief To make the system entering the Clock Gated power saving.
* This function just make the system to enter the clock gated
* power saving mode and pending on wake up event waitting.
* The user application need to configure the peripheral to
* generate system wake up event, like GPIO interrupt
* , G-Timer timeout, etc. befor entering power saving mode.
*
* @param wakeup_event: A bit map of wake up event. Available event:
* SLEEP_WAKEUP_BY_STIMER
* SLEEP_WAKEUP_BY_GTIMER
* SLEEP_WAKEUP_BY_GPIO_INT
* SLEEP_WAKEUP_BY_WLAN
* SLEEP_WAKEUP_BY_NFC
* SLEEP_WAKEUP_BY_SDIO
* SLEEP_WAKEUP_BY_USB
* sleep_duration: the system sleep duration in ms, only valid
* for SLEEP_WAKEUP_BY_STIMER wake up event.
*
* @retval None
*/
void sleep_ex(uint32_t wakeup_event, uint32_t sleep_duration)
{
u8 wake_ev=0;
wake_ev = wakeup_event & 0xff;
if (sleep_duration == 0) {
wake_ev &= ~SLP_STIMER;
}
if (wake_ev == 0) {
// error: No wakeup event, skip the entering sleep mode
return;
}
SleepCG(wake_ev, sleep_duration, 0, 0); // same as old configuration: SCLK off & SDR no power off
}
/**
* @brief To make the system entering the Clock Gated power saving.
* This function just make the system to enter the clock gated
* power saving mode and pending on wake up event waitting.
* The user application need to configure the peripheral to
* generate system wake up event, like GPIO interrupt
* , G-Timer timeout, etc. befor entering power saving mode.
*
* @param wakeup_event: A bit map of wake up event. Available event:
* SLEEP_WAKEUP_BY_STIMER
* SLEEP_WAKEUP_BY_GTIMER
* SLEEP_WAKEUP_BY_GPIO_INT
* SLEEP_WAKEUP_BY_WLAN
* SLEEP_WAKEUP_BY_NFC
* SLEEP_WAKEUP_BY_SDIO
* SLEEP_WAKEUP_BY_USB
* sleep_duration: the system sleep duration in ms, only valid
* for SLEEP_WAKEUP_BY_STIMER wake up event.
* clk_sourec_enable: the option for SCLK on(1)/off(0)
* sdr_enable: the option for turn off the SDR controller (1:off, 0:on)
*
* @retval None
*/
void sleep_ex_selective(uint32_t wakeup_event, uint32_t sleep_duration, uint32_t clk_sourec_enable, uint32_t sdr_enable)
{
u8 wake_ev=0;
u8 sdr_en=0;
u8 clk_source_en=0;
wake_ev = wakeup_event & 0xff;
sdr_en = sdr_enable & 0xff;
clk_source_en = clk_sourec_enable & 0xff;
if (sleep_duration == 0) {
wake_ev &= ~SLP_STIMER;
}
if (wake_ev == 0) {
// error: No wakeup event, skip the entering sleep mode
return;
}
SleepCG(wake_ev, sleep_duration, clk_source_en, sdr_en);
}
/**
* @brief To add a wake up event to wake up the system from the
* deep standby power saving mode.
*
* @param wakeup_event: A bit map of wake up event. Available event:
* STANDBY_WAKEUP_BY_STIMER
* STANDBY_WAKEUP_BY_NFC
* STANDBY_WAKEUP_BY_PA5 (GPIO)
* STANDBY_WAKEUP_BY_PC7 (GPIO)
* STANDBY_WAKEUP_BY_PD5 (GPIO)
* STANDBY_WAKEUP_BY_PE3 (GPIO)
* sleep_duration_ms: the system sleep duration in ms, only valid
* for STANDBY_WAKEUP_BY_STIMER wake up event.
* gpio_active: for a GPIO pin to wake up the system by
* goes high(1) or low(0)
*
* @retval None
*/
void standby_wakeup_event_add(uint32_t wakeup_event, uint32_t sleep_duration_ms, uint32_t gpio_active)
{
u32 i;
u8 gpio_event;
u8 gpio_en;
u8 gpio_act;
if (wakeup_event & STANDBY_WAKEUP_BY_STIMER) {
DStandbyWakeupEvent.wakeup_event |= DSTBY_STIMER;
DStandbyWakeupEvent.timer_duration = sleep_duration_ms;
}
#if 0
if (wakeup_event & STANDBY_WAKEUP_BY_DS_TIMER) {
DStandbyWakeupEvent.wakeup_event |= DSTBY_TIMER33;
// TODO: Sleep Duration ?
}
#endif
if (wakeup_event & STANDBY_WAKEUP_BY_NFC) {
DStandbyWakeupEvent.wakeup_event |= DSTBY_NFC;
}
gpio_event = STANDBY_WAKEUP_BY_PA5;
gpio_en = BIT0;
gpio_act = BIT4;
// Loop 4 to check 4 GPIO wake up event
for (i=0;i<4;i++) {
if (wakeup_event & gpio_event) {
DStandbyWakeupEvent.wakeup_event |= DSTBY_GPIO;
DStandbyWakeupEvent.gpio_option |= gpio_en;
if (gpio_active) {
// Active High
DStandbyWakeupEvent.gpio_option |= gpio_act;
}
else {
// Active Low
DStandbyWakeupEvent.gpio_option &= ~gpio_act;
}
}
gpio_event = gpio_event << 1;
gpio_en = gpio_en << 1;
gpio_act = gpio_act << 1;
}
}
/**
* @brief To delete a wake up event for wakeing up the system from the
* deep standby power saving mode.
*
* @param wakeup_event: A bit map of wake up event. Available event:
* STANDBY_WAKEUP_BY_STIMER
* STANDBY_WAKEUP_BY_NFC
* STANDBY_WAKEUP_BY_PA5 (GPIO)
* STANDBY_WAKEUP_BY_PC7 (GPIO)
* STANDBY_WAKEUP_BY_PD5 (GPIO)
* STANDBY_WAKEUP_BY_PE3 (GPIO)
* @retval None
*/
void standby_wakeup_event_del(uint32_t wakeup_event)
{
if (wakeup_event & STANDBY_WAKEUP_BY_STIMER) {
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_STIMER;
}
#if 0
if (wakeup_event & STANDBY_WAKEUP_BY_DS_TIMER) {
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_TIMER33;
}
#endif
if (wakeup_event & STANDBY_WAKEUP_BY_NFC) {
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_NFC;
}
if (wakeup_event & STANDBY_WAKEUP_BY_PA5) {
DStandbyWakeupEvent.gpio_option &= ~BIT0;
}
if (wakeup_event & STANDBY_WAKEUP_BY_PC7) {
DStandbyWakeupEvent.gpio_option &= ~BIT1;
}
if (wakeup_event & STANDBY_WAKEUP_BY_PD5) {
DStandbyWakeupEvent.gpio_option &= ~BIT2;
}
if (wakeup_event & STANDBY_WAKEUP_BY_PE3) {
DStandbyWakeupEvent.gpio_option &= ~BIT3;
}
if ((DStandbyWakeupEvent.gpio_option & 0x0f) == 0) {
// All GPIO wake up pin are disabled
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_GPIO;
}
}
/**
* @brief To make the system entering the Deep Standby power saving.
* The CPU, memory and part fo peripheral power is off when
* entering deep standby power saving mode. The program needs
* to be reload from the flash at system resume.
*
* @retval None
*/
void deepstandby_ex(void)
{
if ((DStandbyWakeupEvent.wakeup_event & (DSTBY_STIMER|DSTBY_NFC|DSTBY_GPIO)) == 0) {
// error: no wakeup event was added, so skip the entering standby power saving
return;
}
DeepStandby(DStandbyWakeupEvent.wakeup_event,
DStandbyWakeupEvent.timer_duration, DStandbyWakeupEvent.gpio_option);
}
/**
* @brief To make the system entering the Deep Sleep power saving mode.
* The CPU, memory and peripheral power is off when entering
* deep sleep power saving mode. The program needs to be reload
* and all peripheral needs be re-configure when system resume.
*
* @param wakeup_event: A bit map of wake up event. Available event:
* DSLEEP_WAKEUP_BY_TIMER
* DSLEEP_WAKEUP_BY_GPIO
* sleep_duration: the system sleep duration in ms, only valid
* for DSLEEP_WAKEUP_BY_TIMER wake up event.
*
* @retval None
*/
void deepsleep_ex(uint32_t wakeup_event, uint32_t sleep_duration)
{
u8 wake_ev=0;
if ((wakeup_event & DSLEEP_WAKEUP_BY_TIMER) && (sleep_duration > 0)) {
// wake up by timeout
wake_ev |= DS_TIMER33;
}
if (wakeup_event & DSLEEP_WAKEUP_BY_GPIO) {
// wake up by GPIO pin goes high
wake_ev |= DS_GPIO;
}
if (wake_ev == 0) {
// error: No wake up event, skip entering deep sleep mode
return;
}
DeepSleep (wake_ev, sleep_duration);
}
/* 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 "sleep_ex_api.h"
#include "cmsis.h"
extern VOID SleepCG(u8 Option, u32 SDuration, u8 ClkSourceEn, u8 SDREn);
extern VOID DeepStandby(u8 Option, u32 SDuration, u8 GpioOption);
extern VOID DeepSleep(u8 Option, u32 SDuration);
SLEEP_WAKEUP_EVENT DStandbyWakeupEvent={0};
/**
* @brief To make the system entering the Clock Gated power saving.
* This function just make the system to enter the clock gated
* power saving mode and pending on wake up event waitting.
* The user application need to configure the peripheral to
* generate system wake up event, like GPIO interrupt
* , G-Timer timeout, etc. befor entering power saving mode.
*
* @param wakeup_event: A bit map of wake up event. Available event:
* SLEEP_WAKEUP_BY_STIMER
* SLEEP_WAKEUP_BY_GTIMER
* SLEEP_WAKEUP_BY_GPIO_INT
* SLEEP_WAKEUP_BY_WLAN
* SLEEP_WAKEUP_BY_NFC
* SLEEP_WAKEUP_BY_SDIO
* SLEEP_WAKEUP_BY_USB
* sleep_duration: the system sleep duration in ms, only valid
* for SLEEP_WAKEUP_BY_STIMER wake up event.
*
* @retval None
*/
void sleep_ex(uint32_t wakeup_event, uint32_t sleep_duration)
{
u8 wake_ev=0;
wake_ev = wakeup_event & 0xff;
if (sleep_duration == 0) {
wake_ev &= ~SLP_STIMER;
}
if (wake_ev == 0) {
// error: No wakeup event, skip the entering sleep mode
return;
}
SleepCG(wake_ev, sleep_duration, 0, 0); // same as old configuration: SCLK off & SDR no power off
}
/**
* @brief To make the system entering the Clock Gated power saving.
* This function just make the system to enter the clock gated
* power saving mode and pending on wake up event waitting.
* The user application need to configure the peripheral to
* generate system wake up event, like GPIO interrupt
* , G-Timer timeout, etc. befor entering power saving mode.
*
* @param wakeup_event: A bit map of wake up event. Available event:
* SLEEP_WAKEUP_BY_STIMER
* SLEEP_WAKEUP_BY_GTIMER
* SLEEP_WAKEUP_BY_GPIO_INT
* SLEEP_WAKEUP_BY_WLAN
* SLEEP_WAKEUP_BY_NFC
* SLEEP_WAKEUP_BY_SDIO
* SLEEP_WAKEUP_BY_USB
* sleep_duration: the system sleep duration in ms, only valid
* for SLEEP_WAKEUP_BY_STIMER wake up event.
* clk_sourec_enable: the option for SCLK on(1)/off(0)
* sdr_enable: the option for turn off the SDR controller (1:off, 0:on)
*
* @retval None
*/
void sleep_ex_selective(uint32_t wakeup_event, uint32_t sleep_duration, uint32_t clk_sourec_enable, uint32_t sdr_enable)
{
u8 wake_ev=0;
u8 sdr_en=0;
u8 clk_source_en=0;
wake_ev = wakeup_event & 0xff;
sdr_en = sdr_enable & 0xff;
clk_source_en = clk_sourec_enable & 0xff;
if (sleep_duration == 0) {
wake_ev &= ~SLP_STIMER;
}
if (wake_ev == 0) {
// error: No wakeup event, skip the entering sleep mode
return;
}
SleepCG(wake_ev, sleep_duration, clk_source_en, sdr_en);
}
/**
* @brief To add a wake up event to wake up the system from the
* deep standby power saving mode.
*
* @param wakeup_event: A bit map of wake up event. Available event:
* STANDBY_WAKEUP_BY_STIMER
* STANDBY_WAKEUP_BY_NFC
* STANDBY_WAKEUP_BY_PA5 (GPIO)
* STANDBY_WAKEUP_BY_PC7 (GPIO)
* STANDBY_WAKEUP_BY_PD5 (GPIO)
* STANDBY_WAKEUP_BY_PE3 (GPIO)
* sleep_duration_ms: the system sleep duration in ms, only valid
* for STANDBY_WAKEUP_BY_STIMER wake up event.
* gpio_active: for a GPIO pin to wake up the system by
* goes high(1) or low(0)
*
* @retval None
*/
void standby_wakeup_event_add(uint32_t wakeup_event, uint32_t sleep_duration_ms, uint32_t gpio_active)
{
u32 i;
u8 gpio_event;
u8 gpio_en;
u8 gpio_act;
if (wakeup_event & STANDBY_WAKEUP_BY_STIMER) {
DStandbyWakeupEvent.wakeup_event |= DSTBY_STIMER;
DStandbyWakeupEvent.timer_duration = sleep_duration_ms;
}
#if 0
if (wakeup_event & STANDBY_WAKEUP_BY_DS_TIMER) {
DStandbyWakeupEvent.wakeup_event |= DSTBY_TIMER33;
// TODO: Sleep Duration ?
}
#endif
if (wakeup_event & STANDBY_WAKEUP_BY_NFC) {
DStandbyWakeupEvent.wakeup_event |= DSTBY_NFC;
}
gpio_event = STANDBY_WAKEUP_BY_PA5;
gpio_en = BIT0;
gpio_act = BIT4;
// Loop 4 to check 4 GPIO wake up event
for (i=0;i<4;i++) {
if (wakeup_event & gpio_event) {
DStandbyWakeupEvent.wakeup_event |= DSTBY_GPIO;
DStandbyWakeupEvent.gpio_option |= gpio_en;
if (gpio_active) {
// Active High
DStandbyWakeupEvent.gpio_option |= gpio_act;
}
else {
// Active Low
DStandbyWakeupEvent.gpio_option &= ~gpio_act;
}
}
gpio_event = gpio_event << 1;
gpio_en = gpio_en << 1;
gpio_act = gpio_act << 1;
}
}
/**
* @brief To delete a wake up event for wakeing up the system from the
* deep standby power saving mode.
*
* @param wakeup_event: A bit map of wake up event. Available event:
* STANDBY_WAKEUP_BY_STIMER
* STANDBY_WAKEUP_BY_NFC
* STANDBY_WAKEUP_BY_PA5 (GPIO)
* STANDBY_WAKEUP_BY_PC7 (GPIO)
* STANDBY_WAKEUP_BY_PD5 (GPIO)
* STANDBY_WAKEUP_BY_PE3 (GPIO)
* @retval None
*/
void standby_wakeup_event_del(uint32_t wakeup_event)
{
if (wakeup_event & STANDBY_WAKEUP_BY_STIMER) {
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_STIMER;
}
#if 0
if (wakeup_event & STANDBY_WAKEUP_BY_DS_TIMER) {
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_TIMER33;
}
#endif
if (wakeup_event & STANDBY_WAKEUP_BY_NFC) {
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_NFC;
}
if (wakeup_event & STANDBY_WAKEUP_BY_PA5) {
DStandbyWakeupEvent.gpio_option &= ~BIT0;
}
if (wakeup_event & STANDBY_WAKEUP_BY_PC7) {
DStandbyWakeupEvent.gpio_option &= ~BIT1;
}
if (wakeup_event & STANDBY_WAKEUP_BY_PD5) {
DStandbyWakeupEvent.gpio_option &= ~BIT2;
}
if (wakeup_event & STANDBY_WAKEUP_BY_PE3) {
DStandbyWakeupEvent.gpio_option &= ~BIT3;
}
if ((DStandbyWakeupEvent.gpio_option & 0x0f) == 0) {
// All GPIO wake up pin are disabled
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_GPIO;
}
}
/**
* @brief To make the system entering the Deep Standby power saving.
* The CPU, memory and part fo peripheral power is off when
* entering deep standby power saving mode. The program needs
* to be reload from the flash at system resume.
*
* @retval None
*/
void deepstandby_ex(void)
{
if ((DStandbyWakeupEvent.wakeup_event & (DSTBY_STIMER|DSTBY_NFC|DSTBY_GPIO)) == 0) {
// error: no wakeup event was added, so skip the entering standby power saving
return;
}
DeepStandby(DStandbyWakeupEvent.wakeup_event,
DStandbyWakeupEvent.timer_duration, DStandbyWakeupEvent.gpio_option);
}
/**
* @brief To make the system entering the Deep Sleep power saving mode.
* The CPU, memory and peripheral power is off when entering
* deep sleep power saving mode. The program needs to be reload
* and all peripheral needs be re-configure when system resume.
*
* @param wakeup_event: A bit map of wake up event. Available event:
* DSLEEP_WAKEUP_BY_TIMER
* DSLEEP_WAKEUP_BY_GPIO
* sleep_duration: the system sleep duration in ms, only valid
* for DSLEEP_WAKEUP_BY_TIMER wake up event.
*
* @retval None
*/
void deepsleep_ex(uint32_t wakeup_event, uint32_t sleep_duration)
{
u8 wake_ev=0;
if ((wakeup_event & DSLEEP_WAKEUP_BY_TIMER) && (sleep_duration > 0)) {
// wake up by timeout
wake_ev |= DS_TIMER33;
}
if (wakeup_event & DSLEEP_WAKEUP_BY_GPIO) {
// wake up by GPIO pin goes high
wake_ev |= DS_GPIO;
}
if (wake_ev == 0) {
// error: No wake up event, skip entering deep sleep mode
return;
}
DeepSleep (wake_ev, sleep_duration);
}

File diff suppressed because it is too large Load diff

View file

@ -1,94 +1,94 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, Realtek
* All rights reserved.
*
* 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 "wdt_api.h"
#include "cmsis.h"
extern VOID WDGInitial(u32 Period);
extern VOID WDGStart(VOID);
extern VOID WDGStop(VOID);
extern VOID WDGRefresh(VOID);
extern VOID WDGIrqInitial(VOID);
extern VOID WDGIrqCallBackReg(VOID *CallBack, u32 Id);
/**
* @brief Initial the watch dog time setting
*
* @param timeout_ms: the watch-dog timer timeout value, in ms.
* default action of timeout is to reset the whole system.
* @return None
*
*/
void watchdog_init(uint32_t timeout_ms)
{
WDGInitial(timeout_ms);
}
/**
* @brief Start the watchdog counting
*
* @param None
* @return None
*
*/
void watchdog_start(void)
{
WDGStart();
}
/**
* @brief Stop the watchdog counting
*
* @param None
* @return None
*
*/
void watchdog_stop(void)
{
WDGStop();
}
/**
* @brief Refresh the watchdog counting to prevent WDT timeout
*
* @param None
* @return None
*
*/
void watchdog_refresh(void)
{
WDGRefresh();
}
/**
* @brief Switch the watchdog timer to interrupt mode and
* register a watchdog timer timeout interrupt handler.
* The interrupt handler will be called when the watch-dog
* timer is timeout.
*
* @param handler: the callback function for WDT timeout interrupt.
* id: the parameter for the callback function
* @return None
*
*/
void watchdog_irq_init(wdt_irq_handler handler, uint32_t id)
{
WDGIrqCallBackReg((VOID*)handler, (u32)id);
WDGIrqInitial();
}
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2014, Realtek
* All rights reserved.
*
* 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 "wdt_api.h"
#include "cmsis.h"
extern VOID WDGInitial(u32 Period);
extern VOID WDGStart(VOID);
extern VOID WDGStop(VOID);
extern VOID WDGRefresh(VOID);
extern VOID WDGIrqInitial(VOID);
extern VOID WDGIrqCallBackReg(VOID *CallBack, u32 Id);
/**
* @brief Initial the watch dog time setting
*
* @param timeout_ms: the watch-dog timer timeout value, in ms.
* default action of timeout is to reset the whole system.
* @return None
*
*/
void watchdog_init(uint32_t timeout_ms)
{
WDGInitial(timeout_ms);
}
/**
* @brief Start the watchdog counting
*
* @param None
* @return None
*
*/
void watchdog_start(void)
{
WDGStart();
}
/**
* @brief Stop the watchdog counting
*
* @param None
* @return None
*
*/
void watchdog_stop(void)
{
WDGStop();
}
/**
* @brief Refresh the watchdog counting to prevent WDT timeout
*
* @param None
* @return None
*
*/
void watchdog_refresh(void)
{
WDGRefresh();
}
/**
* @brief Switch the watchdog timer to interrupt mode and
* register a watchdog timer timeout interrupt handler.
* The interrupt handler will be called when the watch-dog
* timer is timeout.
*
* @param handler: the callback function for WDT timeout interrupt.
* id: the parameter for the callback function
* @return None
*
*/
void watchdog_irq_init(wdt_irq_handler handler, uint32_t id)
{
WDGIrqCallBackReg((VOID*)handler, (u32)id);
WDGIrqInitial();
}