ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
eeprom_iap.c
Go to the documentation of this file.
1// Copyright 2021 IOsetting <iosetting(at)outlook.com>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15/***
16 * Demo: EEPROM IAP read, write, erase and software reset
17 */
18
19#include "fw_hal.h"
20
21#define TEST_ADDR 0x0400
22#define TEST_SIZE 32
23
25{
26 uint8_t pos = 0;
27 UART1_TxString("IAP_CmdRead: ");
28 for (pos = 0; pos < size; pos++)
29 {
31 if (IAP_IsCmdFailed())
32 {
33 UART1_TxString("__ ");
35 }
36 else
37 {
39 UART1_TxChar(' ');
40 }
41 }
42 UART1_TxString("\r\n");
43}
44
46{
47 uint8_t pos = 0;
48 UART1_TxString("IAP_CmdWrite: ");
49 for (pos = 0; pos < size; pos++)
50 {
53 if (IAP_IsCmdFailed())
54 {
55 UART1_TxString("__ ");
57 }
58 else
59 {
61 UART1_TxChar(' ');
62 }
63 }
64 UART1_TxString("\r\n");
65}
66
68{
69 uint8_t pos = 0;
70 UART1_TxString("IAP_CmdErase: ");
72 if (IAP_IsCmdFailed())
73 {
74 UART1_TxString("failed.\r\n");
76 }
77 else
78 {
79 UART1_TxString("succeeded.\r\n");
80 }
81}
82
83int main(void)
84{
87 UART1_TxString("Test restarted\r\n");
90
92 SYS_Delay(500);
94 SYS_Delay(500);
96 SYS_Delay(500);
98 SYS_Delay(500);
101 SYS_Delay(2000);
102
103 UART1_TxString("Software reset\r\n");
104 SYS_Delay(1000);
106
107 return 0;
108}
uint8_t pos
#define TEST_ADDR
Definition: eeprom_iap.c:21
void TestIAPErase(uint16_t addr)
Definition: eeprom_iap.c:67
void TestIAPWrite(uint16_t addr, uint8_t size)
Definition: eeprom_iap.c:45
int main(void)
Definition: eeprom_iap.c:83
#define TEST_SIZE
Definition: eeprom_iap.c:22
void TestIAPRead(uint16_t addr, uint8_t size)
Definition: eeprom_iap.c:24
#define IAP_SetEnabled(__STATE__)
Definition: fw_iap.h:110
#define IAP_SoftReset()
Definition: fw_iap.h:112
#define IAP_CmdWrite(__16BIT_ADDR__)
Definition: fw_iap.h:84
#define IAP_WriteData(__BYTE__)
Definition: fw_iap.h:60
#define IAP_ClearCmdFailFlag()
Definition: fw_iap.h:114
#define IAP_IsCmdFailed()
Definition: fw_iap.h:113
#define IAP_CmdRead(__16BIT_ADDR__)
Definition: fw_iap.h:70
#define IAP_SetWaitTime()
Definition: fw_iap.h:58
#define IAP_CmdErase(__16BIT_ADDR__)
Definition: fw_iap.h:98
#define IAP_ReadData()
Definition: fw_iap.h:59
void SYS_SetClock(void)
Definition: fw_sys.c:40
void SYS_Delay(uint16_t t)
Definition: fw_sys.c:65
unsigned short uint16_t
Definition: fw_types.h:19
@ HAL_State_OFF
Definition: fw_types.h:70
@ HAL_State_ON
Definition: fw_types.h:71
unsigned char uint8_t
Definition: fw_types.h:18
void UART1_TxChar(char dat)
Definition: fw_uart.c:72
void UART1_TxString(uint8_t *str)
Definition: fw_uart.c:85
@ UART1_BaudSource_Timer2
Definition: fw_uart.h:34
void UART1_TxHex(uint8_t hex)
Definition: fw_uart.c:79
void UART1_Config8bitUart(UART1_BaudSource_t baudSource, HAL_State_t _1TMode, uint32_t baudrate)
Definition: fw_uart.c:56
uint8_t addr[8]
Definition: main.c:28