修改了一些细节,添加了tft屏hmi设计资源的记录

This commit is contained in:
forbelief 2016-04-22 22:42:34 +08:00
parent 07f28f3331
commit 69b9efac27
13 changed files with 2075 additions and 2560 deletions

File diff suppressed because it is too large Load diff

View file

@ -1949,9 +1949,6 @@
<file>
<name>$PROJ_DIR$\..\src\app\display.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\app\flash.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\app\input.c</name>
</file>
@ -1979,6 +1976,9 @@
<file>
<name>$PROJ_DIR$\..\src\app\plan_handle.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\app\pm_flash.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\app\pm_init.c</name>
</file>

View file

@ -225,9 +225,6 @@
<file>
<name>$PROJ_DIR$\..\src\app\display.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\app\flash.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\app\input.c</name>
</file>
@ -252,6 +249,9 @@
<file>
<name>$PROJ_DIR$\..\src\app\plan_handle.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\app\pm_flash.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\src\app\pm_init.c</name>
</file>

File diff suppressed because one or more lines are too long

View file

@ -9,7 +9,7 @@ TriggerName=main
LimitSize=0
ByteLimit=50
[DebugChecksum]
Checksum=130347300
Checksum=-2094893241
[CodeCoverage]
Enabled=_ 0
[Exceptions]
@ -54,8 +54,9 @@ ShowSource=1
[Disassemble mode]
mode=0
[Breakpoints2]
Bp0=_ 0 "EMUL_CODE" "{$PROJ_DIR$\..\src\app\flash.c}.156.9" 0 0 1 "" 0 "" 0
Count=1
Bp0=_ 1 "EMUL_CODE" "{$PROJ_DIR$\..\src\app\tft.c}.878.9" 0 0 1 "" 0 "" 0
Bp1=_ 0 "EMUL_CODE" "{$PROJ_DIR$\..\src\app\tft.c}.897.14" 0 0 1 "" 0 "" 0
Count=2
[Log file]
LoggingEnabled=_ 0
LogFile=_ ""

Binary file not shown.

View file

@ -1,533 +0,0 @@
/****************************************************************************
(c) Copyright 2013-2014 Freescale Semiconductor, Inc.
ALL RIGHTS RESERVED.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the <organization> 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 <COPYRIGHT HOLDER> 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.
*****************************************************************************
*************************************************************************
* *
* Standard Software Flash Driver For FTFx *
* *
* FILE NAME : NormalDemo_Flash.c *
* DATE : April 08, 2014 *
* *
* AUTHOR : FPT Team *
* E-mail : r56611@freescale.com *
* *
*************************************************************************/
/************************** CHANGES *************************************
0.1.0 04.23.2013 FPT Team Initial Version
1.0.0 11.25.2013 FPT Team Optimize Version
1.0.2 08.04.2014 FPT Team Update to follow SDK convention(MISRA-C)
*************************************************************************/
/* include the header files */
#include "SSD_FTFx.h"
#include "demo_cfg.h"
FLASH_SSD_CONFIG flashSSDConfig =
{
FTFx_REG_BASE, /* FTFx control register base */
PFLASH_BLOCK_BASE, /* base address of PFlash block */
PBLOCK_SIZE, /* size of PFlash block */
DEFLASH_BLOCK_BASE, /* base address of DFlash block */
0x0U, /* size of DFlash block */
EERAM_BLOCK_BASE, /* base address of EERAM block */
0x0U, /* size of EEE block */
DEBUGENABLE, /* background debug mode enable bit */
NULL_CALLBACK /* pointer to callback function */
};
#define CALLBACK_SIZE 0x30U
#define LAUNCH_CMD_SIZE 0x80U
uint8_t DataArray[PGM_SIZE_BYTE];
uint8_t buffer[BUFFER_SIZE_BYTE];
uint32_t gCallBackCnt; /* global counter in callback(). */
pFLASHCOMMANDSEQUENCE g_FlashLaunchCommand = (pFLASHCOMMANDSEQUENCE)0xFFFFFFFF;
uint16_t __ram_func[LAUNCH_CMD_SIZE/2]; /* array to copy __Launch_Command func to RAM */
uint16_t __ram_for_callback[CALLBACK_SIZE/2]; /* length of this array depends on total size of the functions need to be copied to RAM*/
void callback(void);
/*********************************************************************
*
* Function Name : main
* Description : Main function
*
* Arguments : void
* Return Value : UNIT32
*
**********************************************************************/
void main(void)
{
uint32_t ret; /* Return code from each SSD function */
uint32_t dest; /* Address of the target location */
uint32_t size;
uint8_t securityStatus; /* Return protection status */
uint32_t protectStatus; /* Store Protection Status Value of PFLSH or DFLASH or EEPROM */
uint32_t FailAddr;
uint16_t number; /* Number of longword or phrase to be program or verify*/
uint32_t sum;
uint32_t temp;
uint32_t i;
uint32_t j;
gCallBackCnt = 0x0U;
#if ((defined(X_TWR_KV10Z32)) || defined(KM34Z50M_BACES) || (defined(TWR_KL46Z48M)))
CACHE_DISABLE
#else
//CACHE_DISABLE
#endif
/* Set CallBack to callback function */
flashSSDConfig.CallBack = (PCALLBACK)RelocateFunction((uint32_t)__ram_for_callback , CALLBACK_SIZE , (uint32_t)callback);
g_FlashLaunchCommand = (pFLASHCOMMANDSEQUENCE)RelocateFunction((uint32_t)__ram_func , LAUNCH_CMD_SIZE ,(uint32_t)FlashCommandSequence);
/**************************************************************************
* FlashInit() *
***************************************************************************/
ret = FlashInit(&flashSSDConfig);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
#ifdef twr_mc56f82748
PE_low_level_init();
#endif
#if ((!(defined(FTFA_M))) || (defined(BLOCK_COMMANDS)))
/**************************************************************************
* FlashEraseBlock() and FlashVerifyBlock() *
***************************************************************************/
/* Erase for each individual Pflash block */
for (i = 0x1U; i < PBLOCK_NUM; i++)
{
dest = flashSSDConfig.PFlashBlockBase + BYTE2WORD(i*flashSSDConfig.PFlashBlockSize/PBLOCK_NUM);
ret = FlashEraseBlock(&flashSSDConfig, dest, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* verification for normal and user margin levels */
for (j = 0x0U; j < 0x2U; j++)
{
ret = FlashVerifyBlock(&flashSSDConfig, dest, j, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
}
}
#endif
/**************************************************************************
* FlashEraseSector() and FlashVerifySection() *
***************************************************************************/
/* Erase several sectors on Pflash*/
dest = flashSSDConfig.PFlashBlockBase + BYTE2WORD(flashSSDConfig.PFlashBlockSize - 0x4U * FTFx_PSECTOR_SIZE);
while ((dest + BYTE2WORD(FTFx_PSECTOR_SIZE)) < (flashSSDConfig.PFlashBlockBase + BYTE2WORD(flashSSDConfig.PFlashBlockSize)))
{
size = FTFx_PSECTOR_SIZE;
ret = FlashEraseSector(&flashSSDConfig, dest, size, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* Verify section for several sector of PFLASH */
number = FTFx_PSECTOR_SIZE / PRD1SEC_ALIGN_SIZE;
for(i = 0x0U; i < 0x2U; i++)
{
ret = FlashVerifySection(&flashSSDConfig, dest, number, i, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
}
dest += BYTE2WORD(size);
}
#if (0x0U != DEBLOCK_SIZE)
/* Erase several sectors on Dflash*/
dest = flashSSDConfig.DFlashBlockBase;
while ((dest + BYTE2WORD(FTFx_DSECTOR_SIZE)) < (flashSSDConfig.DFlashBlockBase + BYTE2WORD(4*FTFx_DSECTOR_SIZE)))
{
size = FTFx_DSECTOR_SIZE;
ret = FlashEraseSector(&flashSSDConfig, dest, size, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* Verify section for several sector of DFLASH */
number = FTFx_DSECTOR_SIZE/DRD1SEC_ALIGN_SIZE;
for(i = 0x0U; i < 0x2U; i ++)
{
ret = FlashVerifySection(&flashSSDConfig, dest, number, i, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
}
dest += BYTE2WORD(FTFx_DSECTOR_SIZE);
}
#endif /* DEBLOCK_SIZE */
/**************************************************************************
* FlashProgram() FlashCheckSum and FlashProgramCheck() *
***************************************************************************/
/* Initialize source buffer */
for (i = 0x0U; i < BUFFER_SIZE_BYTE; i++)
{
/* Set source buffer */
buffer[i] = i;
}
/* Program to the end location of PFLASH */
size = BUFFER_SIZE_BYTE;
dest = flashSSDConfig.PFlashBlockBase + BYTE2WORD(flashSSDConfig.PFlashBlockSize - (uint32_t)(0x3U * FTFx_PSECTOR_SIZE));
while ((dest + BYTE2WORD(size)) < (flashSSDConfig.PFlashBlockBase + BYTE2WORD(flashSSDConfig.PFlashBlockSize)))
{
ret = FlashProgram(&flashSSDConfig, dest, size, \
buffer, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* Flash CheckSum */
sum = temp = 0x0U;
for (i = 0x0U; i < size; i++)
{
temp += buffer[i];
}
ret = FlashCheckSum(&flashSSDConfig, dest, size, &sum);
if ((FTFx_OK != ret) || (temp != sum))
{
ErrorTrap(ret);
}
/* Program Check for normal and user margin levels*/
for (i = 0x1U; i < 0x3U; i ++)
{
ret = FlashProgramCheck(&flashSSDConfig, dest, size, buffer, \
&FailAddr, i, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
}
dest += BYTE2WORD(BUFFER_SIZE_BYTE);
}
#if (0x0 != DEBLOCK_SIZE)
/* Program to the DFLASH block*/
size = BUFFER_SIZE_BYTE;
dest = flashSSDConfig.DFlashBlockBase;
while ((dest + BYTE2WORD(size)) < (flashSSDConfig.DFlashBlockBase + BYTE2WORD(0x4U * FTFx_DSECTOR_SIZE)))
{
ret = FlashProgram(&flashSSDConfig, dest, size, \
buffer, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* Flash CheckSum */
sum = 0x0U;
ret = FlashCheckSum(&flashSSDConfig, dest, size, &sum);
if ((FTFx_OK != ret) || (temp != sum))
{
ErrorTrap(ret);
}
/* Program Check for normal and user margin levels*/
for (i = 0x1U; i < 0x3U; i++)
{
ret = FlashProgramCheck(&flashSSDConfig, dest, size, buffer, \
&FailAddr, i, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
}
dest += BYTE2WORD(BUFFER_SIZE_BYTE);
}
/**************************************************************************
* SetEEEEnable() *
***************************************************************************/
ret = SetEEEEnable(&flashSSDConfig, RAM_ENABLE ,g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
#endif /* DEBLOCK_SIZE */
#ifndef FTFA_M
/**************************************************************************
* FlashProgramSection() *
***************************************************************************/
/* Write some values to EERAM */
for (i = 0x0U; i < 0x100U; i += 0x4U)
{
WRITE32(flashSSDConfig.EERAMBlockBase + i,0x11223344U);
}
/* Erase sector for program section */
dest = flashSSDConfig.PFlashBlockBase + BYTE2WORD(flashSSDConfig.PFlashBlockSize/PBLOCK_NUM - 0x4U * FTFx_PSECTOR_SIZE);
ret = FlashEraseSector(&flashSSDConfig, dest, FTFx_PSECTOR_SIZE, \
g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* Program section to the flash block*/
number = 0x2U;
ret = FlashProgramSection(&flashSSDConfig, dest, number, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
#endif
#if (0x0U != DEBLOCK_SIZE)
/* Erase the first sector of DFlash */
dest = flashSSDConfig.DFlashBlockBase;
ret = FlashEraseSector(&flashSSDConfig, dest, FTFx_PSECTOR_SIZE, \
g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* Program the 1st sector of DFLASH */
number = FTFx_DSECTOR_SIZE / (DPGMSEC_ALIGN_SIZE * 0x4U);
dest = flashSSDConfig.DFlashBlockBase;
ret = FlashProgramSection(&flashSSDConfig, dest, number, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
#endif /* DEBLOCK_SIZE */
/**************************************************************************
* FlashGetSecurityState() *
***************************************************************************/
securityStatus = 0x0U;
ret = FlashGetSecurityState(&flashSSDConfig, &securityStatus);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/**************************************************************************
* FlashReadResource() *
***************************************************************************/
/* Read on P-Flash */
dest = flashSSDConfig.PFlashBlockBase + PFLASH_IFR; /* Start address of Program Once Field */
ret = FlashReadResource(&flashSSDConfig, dest, DataArray, 0x0U, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
#if (DEBLOCK_SIZE != 0)
/* Read on D-Flash */
dest = flashSSDConfig.DFlashBlockBase + DFLASH_IFR;
ret = FlashReadResource(&flashSSDConfig, dest, DataArray, 0x0U, g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/**************************************************************************
* DEFlashPartition() *
***************************************************************************/
if (0x0U == flashSSDConfig.EEEBlockSize)
{
ret = DEFlashPartition(&flashSSDConfig, \
EEE_DATA_SIZE_CODE, \
DE_PARTITION_CODE, \
g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* Call FlashInit again to get the new Flash configuration */
ret = FlashInit(&flashSSDConfig);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
}
/**************************************************************************
* EEEWrite() *
***************************************************************************/
dest = flashSSDConfig.EERAMBlockBase;
size = FTFx_WORD_SIZE;
ret = EEEWrite(&flashSSDConfig, dest, size, buffer);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/**************************************************************************
* EEEWrite() *
***************************************************************************/
ret = SetEEEEnable(&flashSSDConfig, EE_ENABLE ,g_FlashLaunchCommand);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
dest = flashSSDConfig.EERAMBlockBase;
size = FTFx_WORD_SIZE;
ret = EEEWrite(&flashSSDConfig, dest, size, buffer);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/**************************************************************************
* EERAMGetProtection() *
***************************************************************************/
ret = EERAMGetProtection(&flashSSDConfig, (uint8_t *)&protectStatus);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/**************************************************************************
* EERAMSetProtection() *
***************************************************************************/
protectStatus = 0xABU;
ret = EERAMSetProtection(&flashSSDConfig, (uint8_t)protectStatus);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* Call EERAMGetProtection to verify the set step */
ret = EERAMGetProtection(&flashSSDConfig, (uint8_t *)&protectStatus);
if ((FTFx_OK != ret) || (0xABU != (uint8_t)protectStatus))
{
ErrorTrap(ret);
}
/**************************************************************************
* DFlashGetProtection() *
***************************************************************************/
ret = DFlashGetProtection(&flashSSDConfig, (uint8_t *)&protectStatus);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/**************************************************************************
* DFlashSetProtection() *
***************************************************************************/
protectStatus = 0xAAU;
ret = DFlashSetProtection(&flashSSDConfig, (uint8_t)protectStatus);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* Call DFlashGetProtection to verify the set step */
ret = DFlashGetProtection(&flashSSDConfig, (uint8_t *)&protectStatus);
if ((FTFx_OK != ret) || (0xAAU != (uint8_t)protectStatus))
{
ErrorTrap(ret);
}
#endif /* DEBLOCK_SIZE */
/**************************************************************************
* PFlashGetProtection() *
***************************************************************************/
ret = PFlashGetProtection(&flashSSDConfig, &protectStatus);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/**************************************************************************
* PFlashSetProtection() *
***************************************************************************/
protectStatus = 0x12ABCDEFU;
ret = PFlashSetProtection(&flashSSDConfig, protectStatus);
if (FTFx_OK != ret)
{
ErrorTrap(ret);
}
/* Call PFlashGetProtection to verify the set step */
ret = PFlashGetProtection(&flashSSDConfig, &protectStatus);
if ((FTFx_OK != ret) || (0x12ABCDEFU != protectStatus))
{
ErrorTrap(ret);
}
/**************************************************************************/
while(1);
}
/*********************************************************************
*
* Function Name : ErrorTrap
* Description : Gets called when an error occurs.
* Arguments : uint32_t
* Return Value :
*
*********************************************************************/
void ErrorTrap(uint32_t ret)
{
while (1)
{
;
}
}
void callback(void)
{
/* just increase this variable to observer that this callback() func has been involked */
gCallBackCnt++;
}
/* end of file */

View file

@ -27,11 +27,6 @@ void main(void)
st_init(2, COMPARE, 1);
st_init(3, COMPARE, 500);
calendar_info sys_cal = {
0, 1, 2, 3, 4, 2012, 0, 1
};
ds1302_set_time(&sys_cal);
knob_enable();
while (1)

View file

@ -24,21 +24,15 @@
typedef struct plan_output_
{
uint8_t is_lgreach;
uint8_t is_wtreach;
uint8_t lg_cnt;
uint8_t wt_cnt;
uint8_t is_reach;
uint8_t cnt;
} plan_output;
typedef struct plan_input_
{
calendar_info lgbg_t;
calendar_info lged_t;
calendar_info lgpd_t;
calendar_info wtbg_t;
calendar_info wted_t;
calendar_info wtpd_t;
calendar_info bg_t;
calendar_info ed_t;
calendar_info pd_t;
uint8_t x_orient;
uint8_t y_orient;
@ -75,39 +69,23 @@ static void indata_to_outdata(plan_input *ind, plan_output *outd)
calendar_info st = get_system_time();
uint32_t sys_sec = calendar_to_sec(&st);
uint32_t lgpd_sec = calendar_to_sec(&ind->lgpd_t);
uint32_t crt_lgbg_sec = calendar_to_sec(&ind->lgbg_t) + lgpd_sec * outd->lg_cnt;
uint32_t crt_lged_sec = calendar_to_sec(&ind->lged_t) + lgpd_sec * outd->lg_cnt;
uint32_t pd_sec = calendar_to_sec(&ind->pd_t);
uint32_t crt_bg_sec = calendar_to_sec(&ind->bg_t) + pd_sec * outd->cnt;
uint32_t crt_ed_sec = calendar_to_sec(&ind->ed_t) + pd_sec * outd->cnt;
uint32_t wtpd_sec = calendar_to_sec(&ind->wtpd_t);
uint32_t crt_wtbg_sec = calendar_to_sec(&ind->wtbg_t) + wtpd_sec * outd->wt_cnt;
uint32_t crt_wted_sec = calendar_to_sec(&ind->wted_t) + wtpd_sec * outd->wt_cnt;
if (crt_lgbg_sec < sys_sec && crt_lged_sec > sys_sec)
if (crt_bg_sec < sys_sec && crt_ed_sec > sys_sec)
{
outd->is_lgreach = 1;
outd->is_reach = 1;
}
else
{
if (outd->is_lgreach == 1)
if (outd->is_reach == 1)
{
outd->lg_cnt++;
outd->cnt++;
}
outd->is_lgreach = 0;
outd->is_reach = 0;
}
if (crt_wtbg_sec < sys_sec && crt_wted_sec > sys_sec)
{
outd->is_wtreach = 1;
}
else
{
if (outd->is_wtreach== 1)
{
outd->wt_cnt++;
}
outd->is_wtreach = 0;
}
return;
}
@ -141,7 +119,7 @@ void plan_handle(void)
indata_to_outdata(&plan_in[i], &plan_out[i]);
if (plan_in[i].sw == 1)
{
if (plan_out[i].is_lgreach == 1 || plan_out[i].is_wtreach == 1)
if (plan_out[i].is_reach == 1)
{
activity = i;
break;

View file

@ -1,4 +1,6 @@
/*
* pm_flash.c - flash读写模块
*/
#include "SSD_FTFx.h"
@ -49,6 +51,7 @@ void pm_flash_init(void)
* flash的最后一个扇区
* 1KBcodemap文件
*
* flash读取函数的起始地址等于flash写入函数的写入起始地址
*/
void flash_write(uint8_t *saddr, uint16_t nbyte)
{
@ -129,6 +132,13 @@ void flash_write(uint8_t *saddr, uint16_t nbyte)
return;
}
/*
* flash_read() - flash中写入的数据
* @daddr:
* @nbyte:
*
* flash读取函数的起始地址等于flash写入函数的写入起始地址
*/
void flash_read(uint8_t *daddr, uint8_t nbyte)
{
uint8_t *saddr = (uint8_t *)(flashSSDConfig.PFlashBlockBase + BYTE2WORD(flashSSDConfig.PFlashBlockSize
@ -141,14 +151,9 @@ void flash_read(uint8_t *daddr, uint8_t nbyte)
return;
}
/*********************************************************************
*
* Function Name : ErrorTrap
* Description : Gets called when an error occurs.
* Arguments : uint32_t
* Return Value :
*
*********************************************************************/
/*
* ErrorTrap() - flash操作错误处理
*/
void ErrorTrap(uint32_t ret)
{
while (1)

View file

@ -201,6 +201,11 @@ void ds1302_init(void)
gpio_init(DS1302_CLK_PINX, 1, 0);
gpio_Interrupt_init(DS1302_IO_PINX, GPI_UP_PF, GPI_DISAB);
ds1302_single_write(7, 0x00);
if ((ds1302_single_read(0) & 0x80) == 1)
{
calendar_info sys_cal = { 0, 1, 2, 3, 4, 2012, 0, 1 };
ds1302_set_time(&sys_cal);
}
return;
}

View file

@ -19,13 +19,9 @@
typedef struct plan_input_
{
calendar_info lgbg_t;
calendar_info lged_t;
calendar_info lgpd_t;
calendar_info wtbg_t;
calendar_info wted_t;
calendar_info wtpd_t;
calendar_info bg_t;
calendar_info ed_t;
calendar_info pd_t;
uint8_t x_orient;
uint8_t y_orient;
@ -62,7 +58,7 @@ typedef enum page_name_
typedef enum entry_attr_
{
R_NUM = 0, RW_NUM, RW_PIC, SW_PAGE
R_NUM = 0, RW_NUM, RW_PIC, SW_PAGE, R_TXT
} entry_attr;
typedef enum tft_colour_
@ -78,7 +74,7 @@ static tft_state tft_stt = { 0, 0, 0, 0 };
static uint8_t original_lyt[] = { 0, 1 };
static uint8_t menu_lyt[] = { 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
static uint8_t obj_set_lyt[] = { 0, 4, 7, 11, 13};
static uint8_t obj_set_lyt[] = { 0, 2, 5, 9, 13, 16, 18, 19};
static kv_pair kvp_original[] = { {"ori_0", 0, R_NUM} };
@ -92,66 +88,82 @@ static kv_pair kvp_menu[] = {
{ "obj5", 5, SW_PAGE },
{ "obj6", 6, SW_PAGE },
{ "obj7", 7, SW_PAGE },
{ "note", 0, RW_NUM }
{ "note", 0, R_TXT }
};
static kv_pair kvp_obj_set[][PLAN_DATA_NUM] =
{
{
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC },
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM },
{ "bg_h", 14, RW_NUM }, { "bg_mi", 0, RW_NUM },
{ "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM },
{ "lg_pd", 3, RW_NUM }, { "lg_cnt", 0, RW_NUM },
{ "ob", 1, R_NUM}, { "sw", 1, RW_PIC },// 0~1
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, // 2~4
{ "bg_h", 14, RW_NUM }, { "bg_mi", 0, RW_NUM }, { "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM }, // 5~8
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC }, // 9~12
{ "pd_d", 3, RW_NUM }, { "pd_h", 3, RW_NUM }, { "pd_mi", 3, RW_NUM }, // 13~15
{ "x", 0, RW_NUM }, { "y", 0, RW_NUM }, // 16~17
{ "cnt", 0, R_NUM } //18
}, // 0
{
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC },
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM },
{ "bg_h", 14, RW_NUM }, { "bg_mi", 0, RW_NUM },
{ "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM },
{ "lg_pd", 3, RW_NUM }, { "lg_cnt", 0, RW_NUM },
{ "ob", 2, R_NUM}, { "sw", 1, RW_PIC },// 0~1
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, // 2~4
{ "bg_h", 14, RW_NUM }, { "bg_mi", 0, RW_NUM }, { "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM }, // 5~8
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC }, // 9~12
{ "pd_d", 3, RW_NUM }, { "pd_h", 3, RW_NUM }, { "pd_mi", 3, RW_NUM }, // 13~15
{ "x", 0, RW_NUM }, { "y", 0, RW_NUM }, // 16~17
{ "cnt", 0, R_NUM } //18
}, // 1
{
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC },
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM },
{ "bg_h", 14, RW_NUM }, { "bg_mi", 0, RW_NUM },
{ "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM },
{ "lg_pd", 3, RW_NUM }, { "lg_cnt", 0, RW_NUM },
{ "ob", 3, R_NUM}, { "sw", 1, RW_PIC },// 0~1
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, // 2~4
{ "bg_h", 14, RW_NUM }, { "bg_mi", 0, RW_NUM }, { "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM }, // 5~8
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC }, // 9~12
{ "pd_d", 3, RW_NUM }, { "pd_h", 3, RW_NUM }, { "pd_mi", 3, RW_NUM }, // 13~15
{ "x", 0, RW_NUM }, { "y", 0, RW_NUM }, // 16~17
{ "cnt", 0, R_NUM } //18
}, // 2
{
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC },
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, { "bg_h", 14, RW_NUM },
{ "bg_mi", 0, RW_NUM },
{ "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM },
{ "lg_pd", 3, RW_NUM }, { "lg_cnt", 0, RW_NUM },
{ "ob", 4, R_NUM}, { "sw", 1, RW_PIC },// 0~1
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, // 2~4
{ "bg_h", 14, RW_NUM }, { "bg_mi", 0, RW_NUM }, { "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM }, // 5~8
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC }, // 9~12
{ "pd_d", 3, RW_NUM }, { "pd_h", 3, RW_NUM }, { "pd_mi", 3, RW_NUM }, // 13~15
{ "x", 0, RW_NUM }, { "y", 0, RW_NUM }, // 16~17
{ "cnt", 0, R_NUM } //18
}, // 3
{
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC },
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, { "bg_h", 14, RW_NUM },
{ "bg_mi", 0, RW_NUM },
{ "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM },
{ "lg_pd", 3, RW_NUM }, { "lg_cnt", 0, RW_NUM },
{ "ob", 5, R_NUM}, { "sw", 1, RW_PIC },// 0~1
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, // 2~4
{ "bg_h", 14, RW_NUM }, { "bg_mi", 0, RW_NUM }, { "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM }, // 5~8
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC }, // 9~12
{ "pd_d", 3, RW_NUM }, { "pd_h", 3, RW_NUM }, { "pd_mi", 3, RW_NUM }, // 13~15
{ "x", 0, RW_NUM }, { "y", 0, RW_NUM }, // 16~17
{ "cnt", 0, R_NUM } //18
}, // 4
{
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC },
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, { "bg_h", 14, RW_NUM },
{ "bg_mi", 0, RW_NUM },
{ "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM },
{ "lg_pd", 3, RW_NUM }, { "lg_cnt", 0, RW_NUM },
{ "ob", 6, R_NUM}, { "sw", 1, RW_PIC },// 0~1
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, // 2~4
{ "bg_h", 14, RW_NUM }, { "bg_mi", 0, RW_NUM }, { "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM }, // 5~8
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC }, // 9~12
{ "pd_d", 3, RW_NUM }, { "pd_h", 3, RW_NUM }, { "pd_mi", 3, RW_NUM }, // 13~15
{ "x", 0, RW_NUM }, { "y", 0, RW_NUM }, // 16~17
{ "cnt", 0, R_NUM } //18
}, // 5
{
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC },
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, { "bg_h", 14, RW_NUM },
{ "bg_mi", 0, RW_NUM },
{ "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM },
{ "lg_pd", 3, RW_NUM }, { "lg_cnt", 0, RW_NUM },
{ "ob", 7, R_NUM}, { "sw", 1, RW_PIC },// 0~1
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, // 2~4
{ "bg_h", 14, RW_NUM }, { "bg_mi", 0, RW_NUM }, { "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM }, // 5~8
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC }, // 9~12
{ "pd_d", 3, RW_NUM }, { "pd_h", 3, RW_NUM }, { "pd_mi", 3, RW_NUM }, // 13~15
{ "x", 0, RW_NUM }, { "y", 0, RW_NUM }, // 16~17
{ "cnt", 0, R_NUM } //18
}, // 6
{
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC },
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, { "bg_h", 14, RW_NUM },
{ "bg_mi", 0, RW_NUM },
{ "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM },
{ "lg_pd", 3, RW_NUM }, { "lg_cnt", 0, RW_NUM },
{ "ob", 8, R_NUM}, { "sw", 1, RW_PIC },// 0~1
{ "bg_y", 2016, RW_NUM }, { "bg_mo", 4, RW_NUM }, { "bg_d", 14, RW_NUM }, // 2~4
{ "bg_h", 14, RW_NUM }, { "bg_mi", 0, RW_NUM }, { "ed_h", 14, RW_NUM }, { "ed_mi", 0, RW_NUM }, // 5~8
{ "lg_r", 0, RW_PIC}, { "lg_b", 0, RW_PIC }, { "lg_uvb", 0, RW_PIC }, { "water", 0, RW_PIC }, // 9~12
{ "pd_d", 3, RW_NUM }, { "pd_h", 3, RW_NUM }, { "pd_mi", 3, RW_NUM }, // 13~15
{ "x", 0, RW_NUM }, { "y", 0, RW_NUM }, // 16~17
{ "cnt", 0, R_NUM } //18
}, // 7
};
@ -160,7 +172,7 @@ static char tft_cmd_str[20];
static void tft_send_cmd(const char *cmd);
static void tft_set_color(uint8_t etn, tft_colour tft_col);
static void tft_input(void);
static void sw_to_obj(void);
@ -553,6 +565,7 @@ void tft_ret(void)
tft_stt.etn = 0;
tft_send_cmd("page menu");
tft_page_refresh();
sw_to_obj();
// refrush_menu();
tft_set_color(tft_stt.etn, TFT_PURPLE);
break;
@ -725,6 +738,7 @@ void tft_ok(void)
tft_stt.etn = 0;
tft_send_cmd("page menu");
tft_page_refresh();
sw_to_obj();
tft_set_color(tft_stt.etn, TFT_PURPLE);
break;
default:
@ -806,7 +820,6 @@ void tft_page_refresh(void)
switch (kvp_menu[etn].attr)
{
case R_NUM:
break;
case RW_NUM:
sprintf(tft_cmd_str, "%s.val=%d", kvp_menu[etn].key,
kvp_menu[etn].value);
@ -832,7 +845,6 @@ void tft_page_refresh(void)
switch (kvp_obj_set[tft_stt.objn][etn].attr)
{
case R_NUM:
break;
case RW_NUM:
sprintf(tft_cmd_str, "%s.val=%d", kvp_obj_set[tft_stt.objn][etn].key,
kvp_obj_set[tft_stt.objn][etn].value);
@ -859,6 +871,18 @@ void tft_page_refresh(void)
return;
}
static void sw_to_obj(void)
{
for(uint8_t i = 0; i < 8; i++)
{
sprintf(tft_cmd_str, "vis obj%d,%d", i,
*get_value_of_kvp("sw", i));
tft_send_cmd(tft_cmd_str);
}
return;
}
int16_t *get_value_of_kvp(char *name, uint8_t objn)
@ -872,7 +896,7 @@ int16_t *get_value_of_kvp(char *name, uint8_t objn)
}
for (int i = 0; i < sizeof(kvp_obj_set[objn]) / sizeof(kv_pair); i++)
{
if (strcmp(name, kvp_obj_set[objn][i].key) == 0);
if (strcmp(name, kvp_obj_set[objn][i].key) == 0)
{
return &kvp_obj_set[objn][i].value;
}
@ -938,11 +962,6 @@ input_limit tft_input_limit(char *name)
in_lmt.min = 0;
in_lmt.max = 59;
}
else if (strcmp(name, "bg_mi") == 0)
{
in_lmt.min = 0;
in_lmt.max = 59;
}
else if (strcmp(name, "ed_h") == 0)
{
in_lmt.min = 0;
@ -953,6 +972,31 @@ input_limit tft_input_limit(char *name)
in_lmt.min = 0;
in_lmt.max = 59;
}
else if (strcmp(name, "pd_d") == 0)
{
in_lmt.min = 1;
in_lmt.max = 30;
}
else if (strcmp(name, "pd_h") == 0)
{
in_lmt.min = 0;
in_lmt.max = 23;
}
else if (strcmp(name, "pd_mi") == 0)
{
in_lmt.min = 0;
in_lmt.max = 59;
}
else if (strcmp(name, "x") == 0)
{
in_lmt.min = 0;
in_lmt.max = 359;
}
else if (strcmp(name, "y") == 0)
{
in_lmt.min = 0;
in_lmt.max = 359;
}
else
{
in_lmt.min = 0;
@ -979,29 +1023,30 @@ uint8_t get_obj_num(void)
*/
void tft_to_plan_input(uint8_t objn)
{
plan_in[objn].lgbg_t.year = *get_value_of_kvp("bg_y", objn);
plan_in[objn].lgbg_t.month = *get_value_of_kvp("bg_mo", objn);
plan_in[objn].lgbg_t.mday = *get_value_of_kvp("bg_d", objn);
plan_in[objn].lgbg_t.hour = *get_value_of_kvp("bg_h", objn);
plan_in[objn].lgbg_t.min = *get_value_of_kvp("bg_mi", objn);
plan_in[objn].bg_t.year = *get_value_of_kvp("bg_y", objn);
plan_in[objn].bg_t.month = *get_value_of_kvp("bg_mo", objn);
plan_in[objn].bg_t.mday = *get_value_of_kvp("bg_d", objn);
plan_in[objn].bg_t.hour = *get_value_of_kvp("bg_h", objn);
plan_in[objn].bg_t.min = *get_value_of_kvp("bg_mi", objn);
//plan_in[objn].bg_t.sec = *get_value_kvp("bg_s", objn);
plan_in[objn].lged_t.year = *get_value_of_kvp("ed_y", objn);
plan_in[objn].lged_t.month = *get_value_of_kvp("ed_mo", objn);
plan_in[objn].lged_t.mday = *get_value_of_kvp("ed_d", objn);
plan_in[objn].lged_t.hour = *get_value_of_kvp("ed_h", objn);
plan_in[objn].lged_t.min = *get_value_of_kvp("ed_mi", objn);
plan_in[objn].ed_t.year = *get_value_of_kvp("ed_y", objn);
plan_in[objn].ed_t.month = *get_value_of_kvp("ed_mo", objn);
plan_in[objn].ed_t.mday = *get_value_of_kvp("ed_d", objn);
plan_in[objn].ed_t.hour = *get_value_of_kvp("ed_h", objn);
plan_in[objn].ed_t.min = *get_value_of_kvp("ed_mi", objn);
//plan_in[objn].ed_t.sec = *get_value_of_kvp("ed_s", objn);
plan_in[objn].lgpd_t.hour = *get_value_of_kvp("pd_h", objn);
plan_in[objn].lgpd_t.min = *get_value_of_kvp("pd_mi", objn);
plan_in[objn].pd_t.mday = *get_value_of_kvp("pd_d", objn);
plan_in[objn].pd_t.hour = *get_value_of_kvp("pd_h", objn);
plan_in[objn].pd_t.min = *get_value_of_kvp("pd_mi", objn);
plan_in[objn].lg_r = *get_value_of_kvp("lg_r", objn);
plan_in[objn].lg_b = *get_value_of_kvp("lg_b)", objn);
plan_in[objn].lg_uvb = *get_value_of_kvp("lg_uvb", objn);
plan_in[objn].water = *get_value_of_kvp("water", objn);
plan_in[objn].sw = *get_value_of_kvp("obj_sw", objn);
plan_in[objn].sw = *get_value_of_kvp("sw", objn);
return;
}