This commit is contained in:
pvvx 2017-02-01 14:37:57 +03:00
parent 929dc6d329
commit 0557a41f1a
13 changed files with 99 additions and 69 deletions

View file

@ -51,3 +51,5 @@ readfullflash:
prerequirement: prerequirement:
# @$(file >DEPENDENCY_LIST.txt,$(DEPENDENCY_LIST)) # @$(file >DEPENDENCY_LIST.txt,$(DEPENDENCY_LIST))
TARGETTYPE := APP
TARGETNAME := build\obj\build.axf

View file

@ -79,12 +79,12 @@ typedef struct
#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ #define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */
#endif #endif
void wait(float s) { void wait(float s) { // До 1073741 секунд? 298 часов
// wait_us((int)(s * 1000000.0f)); // wait_us((int)(s * 1000000.0f));
vTaskDelay((int)(s * 1000.0f)); vTaskDelay((int)(s * 1000.0f));
} }
void wait_ms(int ms) { void wait_ms(int ms) { // До 1073741 секунд? 298 часов
if(ms > 0) vTaskDelay(ms); if(ms > 0) vTaskDelay(ms);
// wait_us(ms * 1000); // wait_us(ms * 1000);
} }

View file

@ -21,6 +21,7 @@
#include "spi_api.h" #include "spi_api.h"
#include "dma_api.h" #include "dma_api.h"
#include "flash_api.h" #include "flash_api.h"
#include "flash_eep.h"
#include "gpio_ex_api.h" #include "gpio_ex_api.h"
#include "gpio_irq_ex_api.h" #include "gpio_irq_ex_api.h"
#include "i2c_ex_api.h" #include "i2c_ex_api.h"

View file

@ -7,8 +7,7 @@
* possession or use of this module requires written permission of RealTek. * possession or use of this module requires written permission of RealTek.
******************************************************************************* *******************************************************************************
*/ */
#ifndef MBED_EXT_FLASH_API_EXT_H
#ifndef MBED_EXT_FLASH_API_EXT_H
#define MBED_EXT_FLASH_API_EXT_H #define MBED_EXT_FLASH_API_EXT_H
#include "device.h" #include "device.h"
@ -22,8 +21,7 @@ typedef struct flash_s flash_t;
/** /**
* global data structure * global data structure
*/ */
//extern flash_t flash; extern flash_t flashobj;
extern flash_t flashobj;
extern bool fspic_isinit; extern bool fspic_isinit;
enum { enum {
@ -47,10 +45,11 @@ int flash_burst_write (flash_t * obj, uint32_t address, uint32_t Length, uint8
int flash_burst_read (flash_t * obj, uint32_t address, uint32_t Length, uint8_t * data); int flash_burst_read (flash_t * obj, uint32_t address, uint32_t Length, uint8_t * data);
int flash_set_extend_addr (flash_t * obj, uint32_t data); int flash_set_extend_addr (flash_t * obj, uint32_t data);
int flash_get_extend_addr (flash_t * obj); int flash_get_extend_addr (flash_t * obj);
unsigned int flash_get_size (flash_t *obj);
int flash_otp_read (flash_t *obj, uint32_t address, uint32_t Length, uint8_t * data);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif

View file

@ -8,9 +8,14 @@
#ifndef __FLASH_EEP_H_ #ifndef __FLASH_EEP_H_
#define __FLASH_EEP_H_ #define __FLASH_EEP_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <basic_types.h> #include <basic_types.h>
#include <FreeRTOS.h> #include <FreeRTOS.h>
#include <queue.h> #include <queue.h>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef FLASH_SECTOR_SIZE #ifndef FLASH_SECTOR_SIZE
#define FLASH_SECTOR_SIZE 4096 #define FLASH_SECTOR_SIZE 4096
@ -19,7 +24,7 @@
#define FLASH_CHIP_SIZE (FLASH_SECTORS * FLASH_SECTOR_SIZE) #define FLASH_CHIP_SIZE (FLASH_SECTORS * FLASH_SECTOR_SIZE)
#define FMEMORY_SCFG_BANK_SIZE FLASH_SECTOR_SIZE // размер сектора, 4096 bytes #define FMEMORY_SCFG_BANK_SIZE FLASH_SECTOR_SIZE // размер сектора, 4096 bytes
#define FMEMORY_SCFG_BANKS 2 // кол-во секторов для работы 2... #define FMEMORY_SCFG_BANKS 2 // кол-во секторов для работы 2...
#define FMEMORY_SCFG_BASE_ADDR (FLASH_CHIP_SIZE - (FMEMORY_SCFG_BANKS*FMEMORY_SCFG_BANK_SIZE)) #define FMEMORY_SCFG_BASE_ADDR (FLASH_CHIP_SIZE - (FMEMORY_SCFG_BANKS*FMEMORY_SCFG_BANK_SIZE)) // = 0xFE000
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#define FLASH_EEP_ATTR #define FLASH_EEP_ATTR
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -32,11 +37,16 @@ enum eFMEMORY_ERRORS {
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// extern QueueHandle_t flash_mutex; // extern QueueHandle_t flash_mutex;
sint16 flash_read_cfg(void *ptr, uint16 id, uint16 maxsize) FLASH_EEP_ATTR; // возврат: размер объекта последнего сохранения, -1 - не найден, -2 - error signed short flash_read_cfg(void *ptr, unsigned short id, unsigned short maxsize) FLASH_EEP_ATTR; // возврат: размер объекта последнего сохранения, -1 - не найден, -2 - error
bool flash_write_cfg(void *ptr, uint16 id, uint16 size) FLASH_EEP_ATTR; bool flash_write_cfg(void *ptr, unsigned short id, unsigned short size) FLASH_EEP_ATTR;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef USE_FLASH_EEP #ifndef USE_FLASH_EEP
#define USE_FLASH_EEP 1 #define USE_FLASH_EEP 1
#endif #endif
#ifdef __cplusplus
}
#endif
#endif /* __FLASH_EEP_H_ */ #endif /* __FLASH_EEP_H_ */

View file

@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef MBED_WATCHDOG_API_H #ifndef MBED_SYS_API_H
#define MBED_WATCHDOG_API_H #define MBED_SYS_API_H
#include "device.h" #include "device.h"
@ -49,4 +49,4 @@ void sys_reset(void);
} }
#endif #endif
#endif #endif // MBED_SYS_API_H

View file

@ -235,10 +235,7 @@ inline int i2c_stop(i2c_t *obj) {
return 0; return 0;
} }
extern u32 // extern u32 HalDelayUs(IN u32 us);
HalDelayUs(
IN u32 us
);
int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) { int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) {

View file

@ -23,41 +23,41 @@ static const PinMap PinMap_UART_TX[] = {
{PC_3, RTL_PIN_PERI(UART0, 0, S0), RTL_PIN_FUNC(UART0, S0)}, {PC_3, RTL_PIN_PERI(UART0, 0, S0), RTL_PIN_FUNC(UART0, S0)},
{PE_0, RTL_PIN_PERI(UART0, 0, S1), RTL_PIN_FUNC(UART0, S1)}, {PE_0, RTL_PIN_PERI(UART0, 0, S1), RTL_PIN_FUNC(UART0, S1)},
{PA_7, RTL_PIN_PERI(UART0, 0, S2), RTL_PIN_FUNC(UART0, S2)}, // None RTL8710AF {PA_7, RTL_PIN_PERI(UART0, 0, S2), RTL_PIN_FUNC(UART0, S2)}, // None RTL8710AF
{PD_3, RTL_PIN_PERI(UART1, 1, S0), RTL_PIN_FUNC(UART1, S0)}, // None RTL8710AF {PD_3, RTL_PIN_PERI(UART1, 1, S0), RTL_PIN_FUNC(UART1, S0)}, // None RTL8710AF, RTL8711AM
{PE_4, RTL_PIN_PERI(UART1, 1, S1), RTL_PIN_FUNC(UART1, S1)}, {PE_4, RTL_PIN_PERI(UART1, 1, S1), RTL_PIN_FUNC(UART1, S1)},
{PB_5, RTL_PIN_PERI(UART1, 1, S2), RTL_PIN_FUNC(UART1, S2)}, // None RTL8710AF {PB_5, RTL_PIN_PERI(UART1, 1, S2), RTL_PIN_FUNC(UART1, S2)}, // None RTL8710AF, RTL8711AM
{PA_4, RTL_PIN_PERI(UART2, 2, S0), RTL_PIN_FUNC(UART2, S0)}, {PA_4, RTL_PIN_PERI(UART2, 2, S0), RTL_PIN_FUNC(UART2, S0)}, // None RTL8711AM
{PC_9, RTL_PIN_PERI(UART2, 2, S1), RTL_PIN_FUNC(UART2, S1)}, // None RTL8710AF {PC_9, RTL_PIN_PERI(UART2, 2, S1), RTL_PIN_FUNC(UART2, S1)}, // None RTL8710AF, RTL8711AM
{PD_7, RTL_PIN_PERI(UART2, 2, S2), RTL_PIN_FUNC(UART2, S2)}, // None RTL8710AF {PD_7, RTL_PIN_PERI(UART2, 2, S2), RTL_PIN_FUNC(UART2, S2)}, // None RTL8710AF, RTL8711AM
{NC, NC, 0} {NC, NC, 0}
}; };
static const PinMap PinMap_UART_RX[] = { static const PinMap PinMap_UART_RX[] = {
{PC_0, RTL_PIN_PERI(UART0, 0, S0), RTL_PIN_FUNC(UART0, S0)}, {PC_0, RTL_PIN_PERI(UART0, 0, S0), RTL_PIN_FUNC(UART0, S0)}, // No Interrupt Source?
{PE_3, RTL_PIN_PERI(UART0, 0, S1), RTL_PIN_FUNC(UART0, S1)}, {PE_3, RTL_PIN_PERI(UART0, 0, S1), RTL_PIN_FUNC(UART0, S1)},
{PA_6, RTL_PIN_PERI(UART0, 0, S2), RTL_PIN_FUNC(UART0, S2)}, // None RTL8710AF {PA_6, RTL_PIN_PERI(UART0, 0, S2), RTL_PIN_FUNC(UART0, S2)}, // None RTL8710AF, // No Interrupt Source?
{PD_0, RTL_PIN_PERI(UART1, 1, S0), RTL_PIN_FUNC(UART1, S0)}, // None RTL8710AF {PD_0, RTL_PIN_PERI(UART1, 1, S0), RTL_PIN_FUNC(UART1, S0)}, // None RTL8710AF, RTL8711AM
{PE_7, RTL_PIN_PERI(UART1, 1, S1), RTL_PIN_FUNC(UART1, S1)}, // None RTL8710AF {PE_7, RTL_PIN_PERI(UART1, 1, S1), RTL_PIN_FUNC(UART1, S1)}, // None RTL8710AF, RTL8711AM
{PB_4, RTL_PIN_PERI(UART1, 1, S2), RTL_PIN_FUNC(UART1, S2)}, // None RTL8710AF {PB_4, RTL_PIN_PERI(UART1, 1, S2), RTL_PIN_FUNC(UART1, S2)}, // None RTL8710AF, RTL8711AM
{PA_0, RTL_PIN_PERI(UART2, 2, S0), RTL_PIN_FUNC(UART2, S0)}, {PA_0, RTL_PIN_PERI(UART2, 2, S0), RTL_PIN_FUNC(UART2, S0)}, // None RTL8711AM
{PC_6, RTL_PIN_PERI(UART2, 2, S1), RTL_PIN_FUNC(UART2, S1)}, // None RTL8710AF {PC_6, RTL_PIN_PERI(UART2, 2, S1), RTL_PIN_FUNC(UART2, S1)}, // None RTL8710AF, RTL8711AM
{PD_4, RTL_PIN_PERI(UART2, 2, S2), RTL_PIN_FUNC(UART2, S2)}, // None RTL8710AF {PD_4, RTL_PIN_PERI(UART2, 2, S2), RTL_PIN_FUNC(UART2, S2)}, // None RTL8710AF, RTL8711AM
{NC, NC, 0} {NC, NC, 0}
}; };
#define UART_NUM (2) //pvvx! RTL8710 ! #define UART_NUM (3)
#define SERIAL_TX_IRQ_EN 0x01 #define SERIAL_TX_IRQ_EN 0x01
#define SERIAL_RX_IRQ_EN 0x02 #define SERIAL_RX_IRQ_EN 0x02
#define SERIAL_TX_DMA_EN 0x01 #define SERIAL_TX_DMA_EN 0x01
#define SERIAL_RX_DMA_EN 0x02 #define SERIAL_RX_DMA_EN 0x02
static uint32_t serial_irq_ids[UART_NUM] = {0, 0}; // , 0 static uint32_t serial_irq_ids[UART_NUM] = {0, 0, 0}; // , 0
static uart_irq_handler irq_handler[UART_NUM]; static uart_irq_handler irq_handler[UART_NUM];
static uint32_t serial_irq_en[UART_NUM] = {0, 0}; // , 0 static uint32_t serial_irq_en[UART_NUM] = {0, 0, 0}; // , 0
#ifdef CONFIG_GDMA_EN #ifdef CONFIG_GDMA_EN
static uint32_t serial_dma_en[UART_NUM] = {0, 0}; // , 0 static uint32_t serial_dma_en[UART_NUM] = {0, 0, 0}; // , 0
static HAL_GDMA_OP UartGdmaOp; static HAL_GDMA_OP UartGdmaOp;
#endif #endif

View file

@ -42,6 +42,20 @@ void spdio_structinit(struct spdio_t *obj){
obj->tx_done_cb = NULL; obj->tx_done_cb = NULL;
} }
///////// Add pvvx, no ...
void HalSdioRegisterRxCallback(char (*rx_done_cb)(void *priv, void* pbuf, u8 *pdata, u16 size, u8 type), void *obj)
{
struct spdio_t * sp = (struct spdio_t *) obj;
sp->rx_done_cb = rx_done_cb;
}
void HalSdioRegisterTxDoneCallback(char (*tx_done_cb)(void *priv, void* pbuf), void *obj)
{
struct spdio_t * sp = (struct spdio_t *) obj;
sp->tx_done_cb = tx_done_cb;
}
///////
void spdio_init(struct spdio_t *obj) void spdio_init(struct spdio_t *obj)
{ {
if(obj == NULL){ if(obj == NULL){
@ -56,8 +70,8 @@ void spdio_init(struct spdio_t *obj)
} }
g_spdio_priv = obj; g_spdio_priv = obj;
HalSdioInit(); HalSdioInit();
HalSdioRegisterTxCallback(spdio_rx_done_cb, (void *)obj); // ?????????? HalSdioRegisterRxCallback(spdio_rx_done_cb, (void *)obj); // ??????????
HalSdioRegisterRxDoneCallback(spdio_tx_done_cb, (void *)obj); // ????????? HalSdioRegisterTxDoneCallback(spdio_tx_done_cb, (void *)obj); // ?????????
} }
void spdio_deinit(struct spdio_t *obj) void spdio_deinit(struct spdio_t *obj)

View file

@ -360,7 +360,7 @@ void spi_slave_select_bypin(spi_t *obj, PinName pinname)
} }
} }
else else
DBG_SSI_ERR("Wrong Chip Seleect Pin.\n"); DBG_SSI_ERR("Wrong Chip Select Pin.\n");
} }
else{ else{

View file

@ -39,10 +39,11 @@ extern VOID HalJtagPinOff(VOID);
extern void HalInitLogUart(void); extern void HalInitLogUart(void);
extern void HalDeinitLogUart(void); extern void HalDeinitLogUart(void);
#if defined ( __ICCARM__ ) #ifdef CONFIG_SDR_EN
//#if defined ( __ICCARM__ )
extern u8 IsSdrPowerOn(); extern u8 IsSdrPowerOn();
//#endif
#endif #endif
/** /**
* @brief Turn off the JTAG function * @brief Turn off the JTAG function
* *
@ -206,20 +207,26 @@ void sys_reset(void)
u8 sys_is_sdram_power_on(void) u8 sys_is_sdram_power_on(void)
{ {
u8 ison = 0; #ifdef CONFIG_SDR_EN
// u8 ison = 0;
#if defined ( __ICCARM__ ) //#if defined ( __ICCARM__ )
ison = IsSdrPowerOn(); return IsSdrPowerOn();
//#endif
// return ison;
#else
return 0;
#endif #endif
return ison;
} }
void sys_sdram_off(void) void sys_sdram_off(void)
{ {
#if defined ( __ICCARM__ ) #ifdef CONFIG_SDR_EN
if (sys_is_sdram_power_on()) { //#if defined ( __ICCARM__ )
if (IsSdrPowerOn()) {
SdrPowerOff(); SdrPowerOff();
} }
//#endif
#endif #endif
} }

View file

@ -17,15 +17,15 @@
#define APP_TIM_ID 6 // the G-Timer ID for Application #define APP_TIM_ID 6 // the G-Timer ID for Application
static int us_ticker_inited = 0; static int us_ticker_inited = 0;
static TIMER_ADAPTER TimerAdapter; static TIMER_ADAPTER Timer6Adapter;
extern HAL_TIMER_OP HalTimerOp; extern HAL_TIMER_OP HalTimerOp;
/*
VOID _us_ticker_irq_handler(IN VOID *Data) VOID _us_ticker_irq_handler(IN VOID *Data)
{ {
us_ticker_irq_handler(); us_ticker_irq_handler();
} }
*/
void us_ticker_init(void) void us_ticker_init(void)
{ {
@ -33,17 +33,17 @@ void us_ticker_init(void)
us_ticker_inited = 1; us_ticker_inited = 1;
// Initial a G-Timer // Initial a G-Timer
TimerAdapter.IrqDis = 1; // Disable Irq Timer6Adapter.IrqDis = 1; // Disable Irq
TimerAdapter.IrqHandle.IrqFun = (IRQ_FUN) _us_ticker_irq_handler; Timer6Adapter.IrqHandle.IrqFun = (IRQ_FUN) us_ticker_irq_handler;
TimerAdapter.IrqHandle.IrqNum = TIMER2_7_IRQ; Timer6Adapter.IrqHandle.IrqNum = TIMER2_7_IRQ;
TimerAdapter.IrqHandle.Priority = 10; Timer6Adapter.IrqHandle.Priority = 10;
TimerAdapter.IrqHandle.Data = (u32)NULL; Timer6Adapter.IrqHandle.Data = (u32)NULL;
TimerAdapter.TimerId = APP_TIM_ID; Timer6Adapter.TimerId = APP_TIM_ID;
TimerAdapter.TimerIrqPriority = 0; Timer6Adapter.TimerIrqPriority = 0;
TimerAdapter.TimerLoadValueUs = 1; Timer6Adapter.TimerLoadValueUs = 1;
TimerAdapter.TimerMode = FREE_RUN_MODE; // Countdown Free Run Timer6Adapter.TimerMode = FREE_RUN_MODE; // Countdown Free Run
HalTimerOp.HalTimerInit((VOID*) &TimerAdapter); HalTimerOp.HalTimerInit((VOID*) &Timer6Adapter);
DBG_TIMER_INFO("%s: Timer_Id=%d\n", __FUNCTION__, APP_TIM_ID); DBG_TIMER_INFO("%s: Timer_Id=%d\n", __FUNCTION__, APP_TIM_ID);
} }
@ -119,19 +119,19 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
time_def = TIMER_TICK_US; // at least 1 tick time_def = TIMER_TICK_US; // at least 1 tick
} }
TimerAdapter.IrqDis = 0; // Enable Irq Timer6Adapter.IrqDis = 0; // Enable Irq
TimerAdapter.TimerLoadValueUs = time_def; Timer6Adapter.TimerLoadValueUs = time_def;
TimerAdapter.TimerMode = USER_DEFINED; // Countdown Free Run Timer6Adapter.TimerMode = USER_DEFINED; // Countdown Free Run
HalTimerOp.HalTimerInit((VOID*) &TimerAdapter); HalTimerOp.HalTimerInit((VOID*) &Timer6Adapter);
} }
void us_ticker_disable_interrupt(void) void us_ticker_disable_interrupt(void)
{ {
HalTimerOp.HalTimerDis((u32)TimerAdapter.TimerId); HalTimerOp.HalTimerDis((u32)Timer6Adapter.TimerId);
} }
void us_ticker_clear_interrupt(void) void us_ticker_clear_interrupt(void)
{ {
HalTimerOp.HalTimerIrqClear((u32)TimerAdapter.TimerId); HalTimerOp.HalTimerIrqClear((u32)Timer6Adapter.TimerId);
} }

View file

@ -15,8 +15,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************* *******************************************************************************
*/ */
#include "wdt_api.h"
#include "cmsis.h" #include "cmsis.h"
#include "wdt_api.h"
extern VOID WDGInitial(u32 Period); extern VOID WDGInitial(u32 Period);
extern VOID WDGStart(VOID); extern VOID WDGStart(VOID);