ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
fw_iap.h
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#ifndef ___FW_IAP_H___
16#define ___FW_IAP_H___
17
18#include "fw_conf.h"
19#include "fw_types.h"
20
52typedef enum
53{
57
58#define IAP_SetWaitTime() (IAP_TPS = (uint8_t)(__CONF_FOSC / 1000000UL))
59#define IAP_ReadData() (IAP_DATA)
60#define IAP_WriteData(__BYTE__) (IAP_DATA = (__BYTE__))
61
65#define IAP_SetIdle() (IAP_CMD = IAP_CMD & ~(0x03))
66
70#define IAP_CmdRead(__16BIT_ADDR__) do{ \
71 EA = 0; \
72 IAP_ADDRH = ((__16BIT_ADDR__) >> 8); \
73 IAP_ADDRL = ((__16BIT_ADDR__) & 0xFF); \
74 IAP_CMD = IAP_CMD & ~(0x03) | 0x01; \
75 IAP_TRIG = 0x5A; \
76 IAP_TRIG = 0xA5; \
77 NOP();NOP(); \
78 IAP_SetIdle(); \
79 EA = 1; \
80 }while(0)
84#define IAP_CmdWrite(__16BIT_ADDR__) do{ \
85 EA = 0; \
86 IAP_ADDRH = ((__16BIT_ADDR__) >> 8); \
87 IAP_ADDRL = ((__16BIT_ADDR__) & 0xFF); \
88 IAP_CMD = IAP_CMD & ~(0x03) | 0x02; \
89 IAP_TRIG = 0x5A; \
90 IAP_TRIG = 0xA5; \
91 NOP();NOP(); \
92 IAP_SetIdle(); \
93 EA = 1; \
94 }while(0)
98#define IAP_CmdErase(__16BIT_ADDR__) do{ \
99 EA = 0; \
100 IAP_ADDRH = ((__16BIT_ADDR__) >> 8); \
101 IAP_ADDRL = ((__16BIT_ADDR__) & 0xFF); \
102 IAP_CMD = IAP_CMD & ~(0x03) | 0x03; \
103 IAP_TRIG = 0x5A; \
104 IAP_TRIG = 0xA5; \
105 NOP();NOP(); \
106 IAP_SetIdle(); \
107 EA = 1; \
108 }while(0)
109
110#define IAP_SetEnabled(__STATE__) SFR_ASSIGN(IAP_CONTR, 7, __STATE__)
111#define IAP_SetRestartFrom(__FROM__) SFR_ASSIGN(IAP_CONTR, 6, __FROM__)
112#define IAP_SoftReset() SFR_SET(IAP_CONTR, 5)
113#define IAP_IsCmdFailed() (IAP_CONTR & (0x01 << 4))
114#define IAP_ClearCmdFailFlag() SFR_RESET(IAP_CONTR, 4)
115
116
117#endif
IAP_RestartFrom_t
Definition: fw_iap.h:53
@ IAP_RestartFrom_UserCode
Definition: fw_iap.h:54
@ IAP_RestartFrom_ISPCode
Definition: fw_iap.h:55