opt: create sfrx address switch macro to avoid conflicts
This commit is contained in:
parent
5fc2372cc5
commit
1400f8fe75
@ -43,7 +43,7 @@ INTERRUPT(ADC_Routine, EXTI_VectADC)
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Uncomment these lines in high speed ADC
|
* Uncomment these lines in high speed ADC
|
||||||
GPIO_P1_SetMode(GPIO_Pin_1, GPIO_Mode_Output_OD);
|
GPIO_P1_SetMode(GPIO_Pin_1, GPIO_Mode_InOut_OD);
|
||||||
GPIO_P1_SetMode(GPIO_Pin_1, GPIO_Mode_Input_HIP);
|
GPIO_P1_SetMode(GPIO_Pin_1, GPIO_Mode_Input_HIP);
|
||||||
*/
|
*/
|
||||||
ADC_SetChannel(0x01);
|
ADC_SetChannel(0x01);
|
||||||
@ -52,7 +52,7 @@ INTERRUPT(ADC_Routine, EXTI_VectADC)
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Uncomment these lines in high speed ADC
|
* Uncomment these lines in high speed ADC
|
||||||
GPIO_P1_SetMode(GPIO_Pin_2, GPIO_Mode_Output_OD);
|
GPIO_P1_SetMode(GPIO_Pin_2, GPIO_Mode_InOut_OD);
|
||||||
GPIO_P1_SetMode(GPIO_Pin_2, GPIO_Mode_Input_HIP);
|
GPIO_P1_SetMode(GPIO_Pin_2, GPIO_Mode_Input_HIP);
|
||||||
*/
|
*/
|
||||||
ADC_SetChannel(0x02);
|
ADC_SetChannel(0x02);
|
||||||
|
@ -87,7 +87,7 @@ void SPI_init(void)
|
|||||||
// Master mode
|
// Master mode
|
||||||
SPI_SetMasterMode(HAL_State_ON);
|
SPI_SetMasterMode(HAL_State_ON);
|
||||||
// Start SPI
|
// Start SPI
|
||||||
SPI_SetEnableState(HAL_State_ON);
|
SPI_SetEnabled(HAL_State_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
@ -154,7 +154,7 @@ void SPI_init(void)
|
|||||||
// Master mode
|
// Master mode
|
||||||
SPI_SetMasterMode(HAL_State_ON);
|
SPI_SetMasterMode(HAL_State_ON);
|
||||||
// Start SPI
|
// Start SPI
|
||||||
SPI_SetEnableState(HAL_State_ON);
|
SPI_SetEnabled(HAL_State_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
@ -154,7 +154,7 @@ void SPI_init(void)
|
|||||||
// Master mode
|
// Master mode
|
||||||
SPI_SetMasterMode(HAL_State_ON);
|
SPI_SetMasterMode(HAL_State_ON);
|
||||||
// Start SPI
|
// Start SPI
|
||||||
SPI_SetEnableState(HAL_State_ON);
|
SPI_SetEnabled(HAL_State_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
@ -113,7 +113,7 @@ void SPI_init(void)
|
|||||||
// Master mode
|
// Master mode
|
||||||
SPI_SetMasterMode(HAL_State_ON);
|
SPI_SetMasterMode(HAL_State_ON);
|
||||||
// Start SPI
|
// Start SPI
|
||||||
SPI_SetEnableState(HAL_State_ON);
|
SPI_SetEnabled(HAL_State_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
@ -49,7 +49,7 @@ void SPI_Init(void)
|
|||||||
// Master mode
|
// Master mode
|
||||||
SPI_SetMasterMode(HAL_State_ON);
|
SPI_SetMasterMode(HAL_State_ON);
|
||||||
// Start SPI
|
// Start SPI
|
||||||
SPI_SetEnableState(HAL_State_ON);
|
SPI_SetEnabled(HAL_State_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPIO_Init(void)
|
void GPIO_Init(void)
|
||||||
|
@ -47,7 +47,7 @@ void SPI_Init(void)
|
|||||||
// Master mode
|
// Master mode
|
||||||
SPI_SetMasterMode(HAL_State_ON);
|
SPI_SetMasterMode(HAL_State_ON);
|
||||||
// Start SPI
|
// Start SPI
|
||||||
SPI_SetEnableState(HAL_State_ON);
|
SPI_SetEnabled(HAL_State_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPIO_Init(void)
|
void GPIO_Init(void)
|
||||||
|
@ -131,16 +131,11 @@ typedef enum
|
|||||||
#define EXTI_INT_CompFall_ON SFR_SET(CMPCR1, 4)
|
#define EXTI_INT_CompFall_ON SFR_SET(CMPCR1, 4)
|
||||||
#define EXTI_INT_CompFall_OFF SFR_RESET(CMPCR1, 4)
|
#define EXTI_INT_CompFall_OFF SFR_RESET(CMPCR1, 4)
|
||||||
|
|
||||||
#define EXTI_INT_I2cMaster_ON SFRX_SET(I2CMSCR, 7)
|
#define EXTI_I2C_SetMstIntState(__STATE__) SFR_ASSIGN(I2CMSCR, 7, __STATE__)
|
||||||
#define EXTI_INT_I2cMaster_OFF SFRX_RESET(I2CMSCR, 7)
|
#define EXTI_I2C_SetSlvStartIntState(__STATE__) SFRX_SET(I2CSLCR, 6, __STATE__)
|
||||||
#define EXTI_INT_I2cSlvRxStart_ON SFRX_SET(I2CSLCR, 6)
|
#define EXTI_I2C_SetSlvRecvIntState(__STATE__) SFRX_SET(I2CSLCR, 5, __STATE__)
|
||||||
#define EXTI_INT_I2cSlvRxStart_OFF SFRX_RESET(I2CSLCR, 6)
|
#define EXTI_I2C_SetSlvSendIntState(__STATE__) SFRX_SET(I2CSLCR, 4, __STATE__)
|
||||||
#define EXTI_INT_I2cSlvRxEnd_ON SFRX_SET(I2CSLCR, 5)
|
#define EXTI_I2C_SetSlvStopIntState(__STATE__) SFRX_SET(I2CSLCR, 3, __STATE__)
|
||||||
#define EXTI_INT_I2cSlvRxEnd_OFF SFRX_RESET(I2CSLCR, 5)
|
|
||||||
#define EXTI_INT_I2cSlvTxEnd_ON SFRX_SET(I2CSLCR, 4)
|
|
||||||
#define EXTI_INT_I2cSlvTxEnd_OFF SFRX_RESET(I2CSLCR, 4)
|
|
||||||
#define EXTI_INT_I2cSlvRxStop_ON SFRX_SET(I2CSLCR, 3)
|
|
||||||
#define EXTI_INT_I2cSlvRxStop_OFF SFRX_RESET(I2CSLCR, 3)
|
|
||||||
|
|
||||||
#define EXTI_INT_PWMA_Break_ON SFRX_SET(PWMA_IER, 7)
|
#define EXTI_INT_PWMA_Break_ON SFRX_SET(PWMA_IER, 7)
|
||||||
#define EXTI_INT_PWMA_Break_OFF SFRX_RESET(PWMA_IER, 7)
|
#define EXTI_INT_PWMA_Break_OFF SFRX_RESET(PWMA_IER, 7)
|
||||||
@ -179,8 +174,8 @@ typedef enum
|
|||||||
#define EXTI_INT_LCM_ON SFRX_SET(LCMIFCFG, 7)
|
#define EXTI_INT_LCM_ON SFRX_SET(LCMIFCFG, 7)
|
||||||
#define EXTI_INT_LCM_OFF SFRX_RESET(LCMIFCFG, 7)
|
#define EXTI_INT_LCM_OFF SFRX_RESET(LCMIFCFG, 7)
|
||||||
|
|
||||||
#define EXTI_Port_SetInterrupt_ON(__PORT__, __PINS__) do {P_SW2 = 0x80; SFRX(PxINTE + (__PORT__)) |= (__PINS__); P_SW2 = 0x00;} while(0)
|
#define EXTI_Port_SetInterrupt_ON(__PORT__, __PINS__) do {SFRX_ON(); SFRX(PxINTE + (__PORT__)) |= (__PINS__); SFRX_OFF();} while(0)
|
||||||
#define EXTI_Port_SetInterrupt_OFF(__PORT__, __PINS__) do {P_SW2 = 0x80; SFRX(PxINTE + (__PORT__)) &= ~(__PINS__); P_SW2 = 0x00;} while(0)
|
#define EXTI_Port_SetInterrupt_OFF(__PORT__, __PINS__) do {SFRX_ON(); SFRX(PxINTE + (__PORT__)) &= ~(__PINS__); SFRX_OFF();} while(0)
|
||||||
|
|
||||||
#define EXTI_Int0_SetIntPriority(__PRIORITY__) SFR_DUAL_SET(IP, IPH, 0, __PRIORITY__)
|
#define EXTI_Int0_SetIntPriority(__PRIORITY__) SFR_DUAL_SET(IP, IPH, 0, __PRIORITY__)
|
||||||
#define EXTI_Timer0_SetIntPriority(__PRIORITY__) SFR_DUAL_SET(IP, IPH, 1, __PRIORITY__)
|
#define EXTI_Timer0_SetIntPriority(__PRIORITY__) SFR_DUAL_SET(IP, IPH, 1, __PRIORITY__)
|
||||||
@ -205,9 +200,9 @@ typedef enum
|
|||||||
|
|
||||||
#define EXTI_Port_SetIntPriority(__PORT__, __PRIORITY__) SFRX_DUAL_SET(PIN_IP, PIN_IPH, __PORT__, __PRIORITY__)
|
#define EXTI_Port_SetIntPriority(__PORT__, __PRIORITY__) SFRX_DUAL_SET(PIN_IP, PIN_IPH, __PORT__, __PRIORITY__)
|
||||||
|
|
||||||
#define EXTI_Port_SetIntMode(__PORT__, __PINS__, __PORT_INT_MODE__) do { P_SW2 = 0x80; \
|
#define EXTI_Port_SetIntMode(__PORT__, __PINS__, __PORT_INT_MODE__) do { SFRX_ON(); \
|
||||||
SFRX(PxIM0 + (__PORT__)) = SFRX(PxIM0 + (__PORT__)) & ~(__PINS__) | (((__PORT_INT_MODE__) & 0x01)? (__PINS__) : 0x00); \
|
SFRX(PxIM0 + (__PORT__)) = SFRX(PxIM0 + (__PORT__)) & ~(__PINS__) | (((__PORT_INT_MODE__) & 0x01)? (__PINS__) : 0x00); \
|
||||||
SFRX(PxIM1 + (__PORT__)) = SFRX(PxIM1 + (__PORT__)) & ~(__PINS__) | (((__PORT_INT_MODE__) & 0x02)? (__PINS__) : 0x00); \
|
SFRX(PxIM1 + (__PORT__)) = SFRX(PxIM1 + (__PORT__)) & ~(__PINS__) | (((__PORT_INT_MODE__) & 0x02)? (__PINS__) : 0x00); \
|
||||||
P_SW2 = 0x00; } while(0)
|
SFRX_OFF(); } while(0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,7 +23,7 @@ typedef enum
|
|||||||
GPIO_Mode_InOut_QBD = 0x00, /* quasi-bidirectional(be compatible with classical 8051 MCUs) */
|
GPIO_Mode_InOut_QBD = 0x00, /* quasi-bidirectional(be compatible with classical 8051 MCUs) */
|
||||||
GPIO_Mode_Output_PP = 0x01, /* push-pull output */
|
GPIO_Mode_Output_PP = 0x01, /* push-pull output */
|
||||||
GPIO_Mode_Input_HIP = 0x02, /* high-impedance input */
|
GPIO_Mode_Input_HIP = 0x02, /* high-impedance input */
|
||||||
GPIO_Mode_Output_OD = 0x03, /* open drain output */
|
GPIO_Mode_InOut_OD = 0x03, /* open drain output */
|
||||||
} GPIO_Mode_t;
|
} GPIO_Mode_t;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
@ -114,38 +114,38 @@ typedef enum
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GPIO_SetPullUp(__PORT__, __PINS__, __STATE__) do { \
|
#define GPIO_SetPullUp(__PORT__, __PINS__, __STATE__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
SFRX(PxPU + (__PORT__)) = SFRX(PxPU + (__PORT__)) \
|
SFRX(PxPU + (__PORT__)) = SFRX(PxPU + (__PORT__)) \
|
||||||
& ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
& ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define GPIO_SetSchmittTrigger(__PORT__, __PINS__, __STATE__) do { \
|
#define GPIO_SetSchmittTrigger(__PORT__, __PINS__, __STATE__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
SFRX(PxNCS + (__PORT__)) = SFRX(PxNCS + (__PORT__)) \
|
SFRX(PxNCS + (__PORT__)) = SFRX(PxNCS + (__PORT__)) \
|
||||||
& ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
& ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define GPIO_SetSwitchSpeed(__PORT__, __PINS__, __STATE__) do { \
|
#define GPIO_SetSwitchSpeed(__PORT__, __PINS__, __STATE__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
SFRX(PxSR + (__PORT__)) = SFRX(PxSR + (__PORT__)) \
|
SFRX(PxSR + (__PORT__)) = SFRX(PxSR + (__PORT__)) \
|
||||||
& ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
& ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define GPIO_SetDriveCapability(__PORT__, __PINS__, __STATE__) do { \
|
#define GPIO_SetDriveCapability(__PORT__, __PINS__, __STATE__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
SFRX(PxDR + (__PORT__)) = SFRX(PxDR + (__PORT__)) \
|
SFRX(PxDR + (__PORT__)) = SFRX(PxDR + (__PORT__)) \
|
||||||
& ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
& ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define GPIO_SetDigitalInput(__PORT__, __PINS__, __STATE__) do { \
|
#define GPIO_SetDigitalInput(__PORT__, __PINS__, __STATE__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
SFRX(PxIE + (__PORT__)) = SFRX(PxIE + (__PORT__)) \
|
SFRX(PxIE + (__PORT__)) = SFRX(PxIE + (__PORT__)) \
|
||||||
& ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
& ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "fw_types.h"
|
#include "fw_types.h"
|
||||||
|
|
||||||
#define MEM_ReadCODE(__ADDR__) (*(unsigned char volatile __CODE *)(__ADDR__))
|
#define MEM_ReadCODE(__ADDR__) (*(unsigned char volatile __CODE *)(__ADDR__))
|
||||||
// Set P_SW2 = 0x80 before using this macro
|
// Set SFRX_ON() before using this macro
|
||||||
#define MEM_ReadXDATA(__ADDR__) (*(unsigned char volatile __XDATA *)(__ADDR__))
|
#define MEM_ReadXDATA(__ADDR__) (*(unsigned char volatile __XDATA *)(__ADDR__))
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
116
include/fw_pwm.h
116
include/fw_pwm.h
@ -85,17 +85,17 @@ typedef enum
|
|||||||
* Fpwm = SYSCLK / (PWMx_PSCR + 1) / PWMx_ARR / 2
|
* Fpwm = SYSCLK / (PWMx_PSCR + 1) / PWMx_ARR / 2
|
||||||
*/
|
*/
|
||||||
#define PWMA_SetPrescaler(__16BIT_VAL__) do { \
|
#define PWMA_SetPrescaler(__16BIT_VAL__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(PWMA_PSCRH = ((__16BIT_VAL__) >> 8)); \
|
(PWMA_PSCRH = ((__16BIT_VAL__) >> 8)); \
|
||||||
(PWMA_PSCRL = ((__16BIT_VAL__) & 0xFF)); \
|
(PWMA_PSCRL = ((__16BIT_VAL__) & 0xFF)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
#define PWMA_SetPeriod(__16BIT_VAL__) do { \
|
#define PWMA_SetPeriod(__16BIT_VAL__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(PWMA_ARRH = ((__16BIT_VAL__) >> 8)); \
|
(PWMA_ARRH = ((__16BIT_VAL__) >> 8)); \
|
||||||
(PWMA_ARRL = ((__16BIT_VAL__) & 0xFF)); \
|
(PWMA_ARRL = ((__16BIT_VAL__) & 0xFF)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
// PWMA all pins input/output OFF/ON
|
// PWMA all pins input/output OFF/ON
|
||||||
@ -103,16 +103,16 @@ typedef enum
|
|||||||
|
|
||||||
// PWMA Pins Output OFF/ON
|
// PWMA Pins Output OFF/ON
|
||||||
#define PWMA_SetPinOutputState(__PINS__, __STATE__) do { \
|
#define PWMA_SetPinOutputState(__PINS__, __STATE__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
PWMA_ENO = PWMA_ENO & ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
PWMA_ENO = PWMA_ENO & ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
// Enable/Disable PWMB_BKR Control on Pins
|
// Enable/Disable PWMB_BKR Control on Pins
|
||||||
#define PWMA_SetPinBrakeControl(__PINS__, __STATE__) do { \
|
#define PWMA_SetPinBrakeControl(__PINS__, __STATE__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
PWMA_IOAUX = PWMA_IOAUX & ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
PWMA_IOAUX = PWMA_IOAUX & ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,7 +125,7 @@ typedef enum
|
|||||||
* Turn off counter (call PWMA_SetCounterState()) before changing to different alignment
|
* Turn off counter (call PWMA_SetCounterState()) before changing to different alignment
|
||||||
*/
|
*/
|
||||||
#define PWMA_SetEdgeAlignment(__ALIGN__) do{ \
|
#define PWMA_SetEdgeAlignment(__ALIGN__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_CR1 = PWMA_CR1 & ~(0x03 << 5) | ((__ALIGN__) << 5));P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_CR1 = PWMA_CR1 & ~(0x03 << 5) | ((__ALIGN__) << 5));SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -188,16 +188,16 @@ typedef enum
|
|||||||
} PWMA_PortDirection_t;
|
} PWMA_PortDirection_t;
|
||||||
|
|
||||||
#define PWMA_PWM1_SetPortDirection(__PORT_DIR__) do{ \
|
#define PWMA_PWM1_SetPortDirection(__PORT_DIR__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_CCMR1 = PWMA_CCMR1 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_CCMR1 = PWMA_CCMR1 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMA_PWM2_SetPortDirection(__PORT_DIR__) do{ \
|
#define PWMA_PWM2_SetPortDirection(__PORT_DIR__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_CCMR2 = PWMA_CCMR2 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_CCMR2 = PWMA_CCMR2 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMA_PWM3_SetPortDirection(__PORT_DIR__) do{ \
|
#define PWMA_PWM3_SetPortDirection(__PORT_DIR__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_CCMR3 = PWMA_CCMR3 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_CCMR3 = PWMA_CCMR3 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMA_PWM4_SetPortDirection(__PORT_DIR__) do{ \
|
#define PWMA_PWM4_SetPortDirection(__PORT_DIR__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_CCMR4 = PWMA_CCMR4 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_CCMR4 = PWMA_CCMR4 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -214,44 +214,44 @@ typedef enum
|
|||||||
* Configurate PWMA.1 - PWMA.4 out mode
|
* Configurate PWMA.1 - PWMA.4 out mode
|
||||||
*/
|
*/
|
||||||
#define PWMA_PWM1_ConfigOutputMode(__MODE__) do{ \
|
#define PWMA_PWM1_ConfigOutputMode(__MODE__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_CCMR1 = PWMA_CCMR1 & ~(0x07 << 4) | ((__MODE__) << 4)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_CCMR1 = PWMA_CCMR1 & ~(0x07 << 4) | ((__MODE__) << 4)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMA_PWM2_ConfigOutputMode(__MODE__) do{ \
|
#define PWMA_PWM2_ConfigOutputMode(__MODE__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_CCMR2 = PWMA_CCMR2 & ~(0x07 << 4) | ((__MODE__) << 4)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_CCMR2 = PWMA_CCMR2 & ~(0x07 << 4) | ((__MODE__) << 4)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMA_PWM3_ConfigOutputMode(__MODE__) do{ \
|
#define PWMA_PWM3_ConfigOutputMode(__MODE__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_CCMR3 = PWMA_CCMR3 & ~(0x07 << 4) | ((__MODE__) << 4)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_CCMR3 = PWMA_CCMR3 & ~(0x07 << 4) | ((__MODE__) << 4)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMA_PWM4_ConfigOutputMode(__MODE__) do{ \
|
#define PWMA_PWM4_ConfigOutputMode(__MODE__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_CCMR4 = PWMA_CCMR4 & ~(0x07 << 4) | ((__MODE__) << 4)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_CCMR4 = PWMA_CCMR4 & ~(0x07 << 4) | ((__MODE__) << 4)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configurate PWMA.1 - PWMA.4 capture/comparison value, this will affect duty cycle
|
* Configurate PWMA.1 - PWMA.4 capture/comparison value, this will affect duty cycle
|
||||||
*/
|
*/
|
||||||
#define PWMA_PWM1_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
#define PWMA_PWM1_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(PWMA_CCR1H = ((__16BIT_VAL__) >> 8)); \
|
(PWMA_CCR1H = ((__16BIT_VAL__) >> 8)); \
|
||||||
(PWMA_CCR1L = ((__16BIT_VAL__) & 0xFF)); \
|
(PWMA_CCR1L = ((__16BIT_VAL__) & 0xFF)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMA_PWM2_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
#define PWMA_PWM2_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(PWMA_CCR2H = ((__16BIT_VAL__) >> 8)); \
|
(PWMA_CCR2H = ((__16BIT_VAL__) >> 8)); \
|
||||||
(PWMA_CCR2L = ((__16BIT_VAL__) & 0xFF)); \
|
(PWMA_CCR2L = ((__16BIT_VAL__) & 0xFF)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMA_PWM3_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
#define PWMA_PWM3_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(PWMA_CCR3H = ((__16BIT_VAL__) >> 8)); \
|
(PWMA_CCR3H = ((__16BIT_VAL__) >> 8)); \
|
||||||
(PWMA_CCR3L = ((__16BIT_VAL__) & 0xFF)); \
|
(PWMA_CCR3L = ((__16BIT_VAL__) & 0xFF)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMA_PWM4_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
#define PWMA_PWM4_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(PWMA_CCR4H = ((__16BIT_VAL__) >> 8)); \
|
(PWMA_CCR4H = ((__16BIT_VAL__) >> 8)); \
|
||||||
(PWMA_CCR4L = ((__16BIT_VAL__) & 0xFF)); \
|
(PWMA_CCR4L = ((__16BIT_VAL__) & 0xFF)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -289,16 +289,16 @@ typedef enum
|
|||||||
|
|
||||||
// Alternative port selection
|
// Alternative port selection
|
||||||
#define PWMA_PWM1_SetPort(__ALTER_PORT__) do{ \
|
#define PWMA_PWM1_SetPort(__ALTER_PORT__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_PS = PWMA_PS & ~(0x03 << 0) | ((__ALTER_PORT__) << 0)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_PS = PWMA_PS & ~(0x03 << 0) | ((__ALTER_PORT__) << 0)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMA_PWM2_SetPort(__ALTER_PORT__) do{ \
|
#define PWMA_PWM2_SetPort(__ALTER_PORT__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_PS = PWMA_PS & ~(0x03 << 2) | ((__ALTER_PORT__) << 2)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_PS = PWMA_PS & ~(0x03 << 2) | ((__ALTER_PORT__) << 2)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMA_PWM3_SetPort(__ALTER_PORT__) do{ \
|
#define PWMA_PWM3_SetPort(__ALTER_PORT__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_PS = PWMA_PS & ~(0x03 << 4) | ((__ALTER_PORT__) << 4)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_PS = PWMA_PS & ~(0x03 << 4) | ((__ALTER_PORT__) << 4)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMA_PWM4_SetPort(__ALTER_PORT__) do{ \
|
#define PWMA_PWM4_SetPort(__ALTER_PORT__) do{ \
|
||||||
P_SW2 = 0x80;(PWMA_PS = PWMA_PS & ~(0x03 << 6) | ((__ALTER_PORT__) << 6)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMA_PS = PWMA_PS & ~(0x03 << 6) | ((__ALTER_PORT__) << 6)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
|
|
||||||
@ -316,17 +316,17 @@ typedef enum
|
|||||||
* Fpwm = SYSCLK / (PWMx_PSCR + 1) / PWMx_ARR / 2
|
* Fpwm = SYSCLK / (PWMx_PSCR + 1) / PWMx_ARR / 2
|
||||||
*/
|
*/
|
||||||
#define PWMB_SetPrescaler(__16BIT_VAL__) do { \
|
#define PWMB_SetPrescaler(__16BIT_VAL__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(PWMB_PSCRH = ((__16BIT_VAL__) >> 8)); \
|
(PWMB_PSCRH = ((__16BIT_VAL__) >> 8)); \
|
||||||
(PWMB_PSCRL = ((__16BIT_VAL__) & 0xFF)); \
|
(PWMB_PSCRL = ((__16BIT_VAL__) & 0xFF)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
#define PWMB_SetPeriod(__16BIT_VAL__) do { \
|
#define PWMB_SetPeriod(__16BIT_VAL__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(PWMB_ARRH = ((__16BIT_VAL__) >> 8)); \
|
(PWMB_ARRH = ((__16BIT_VAL__) >> 8)); \
|
||||||
(PWMB_ARRL = ((__16BIT_VAL__) & 0xFF)); \
|
(PWMB_ARRL = ((__16BIT_VAL__) & 0xFF)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
// PWMA all pins input/output OFF/ON
|
// PWMA all pins input/output OFF/ON
|
||||||
@ -334,16 +334,16 @@ typedef enum
|
|||||||
|
|
||||||
// PWMB Pins Output OFF/ON
|
// PWMB Pins Output OFF/ON
|
||||||
#define PWMB_SetPinOutputState(__PINS__, __STATE__) do { \
|
#define PWMB_SetPinOutputState(__PINS__, __STATE__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
PWMB_ENO = PWMB_ENO & ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
PWMB_ENO = PWMB_ENO & ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
// Enable/Disable PWMB_BKR Control on Pins
|
// Enable/Disable PWMB_BKR Control on Pins
|
||||||
#define PWMB_SetPinBrakeControl(__PINS__, __STATE__) do { \
|
#define PWMB_SetPinBrakeControl(__PINS__, __STATE__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
PWMB_IOAUX = PWMB_IOAUX & ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
PWMB_IOAUX = PWMB_IOAUX & ~(__PINS__) | (((__STATE__) & 0x01)? (__PINS__) : 0x00); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -356,7 +356,7 @@ typedef enum
|
|||||||
* Turn off counter (call PWMB_SetCounterState()) before changing to different alignment
|
* Turn off counter (call PWMB_SetCounterState()) before changing to different alignment
|
||||||
*/
|
*/
|
||||||
#define PWMB_SetEdgeAlignment(__ALIGN__) do{ \
|
#define PWMB_SetEdgeAlignment(__ALIGN__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_CR1 = PWMB_CR1 & ~(0x03 << 5) | ((__ALIGN__) << 5));P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_CR1 = PWMB_CR1 & ~(0x03 << 5) | ((__ALIGN__) << 5));SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -411,16 +411,16 @@ typedef enum
|
|||||||
} PWMB_PortDirection_t;
|
} PWMB_PortDirection_t;
|
||||||
|
|
||||||
#define PWMB_PWM1_SetPortDirection(__PORT_DIR__) do{ \
|
#define PWMB_PWM1_SetPortDirection(__PORT_DIR__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_CCMR1 = PWMB_CCMR1 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_CCMR1 = PWMB_CCMR1 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMB_PWM2_SetPortDirection(__PORT_DIR__) do{ \
|
#define PWMB_PWM2_SetPortDirection(__PORT_DIR__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_CCMR2 = PWMB_CCMR2 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_CCMR2 = PWMB_CCMR2 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMB_PWM3_SetPortDirection(__PORT_DIR__) do{ \
|
#define PWMB_PWM3_SetPortDirection(__PORT_DIR__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_CCMR3 = PWMB_CCMR3 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_CCMR3 = PWMB_CCMR3 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMB_PWM4_SetPortDirection(__PORT_DIR__) do{ \
|
#define PWMB_PWM4_SetPortDirection(__PORT_DIR__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_CCMR4 = PWMB_CCMR4 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_CCMR4 = PWMB_CCMR4 & ~(0x03 << 0) | ((__PORT_DIR__) << 0)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -437,44 +437,44 @@ typedef enum
|
|||||||
* Configurate PWMB.1(PWM5) - PWMB.4(PWM8) output mode
|
* Configurate PWMB.1(PWM5) - PWMB.4(PWM8) output mode
|
||||||
*/
|
*/
|
||||||
#define PWMB_PWM1_ConfigOutputMode(__MODE__) do{ \
|
#define PWMB_PWM1_ConfigOutputMode(__MODE__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_CCMR1 = PWMB_CCMR1 & ~(0x07 << 4) | ((__MODE__) << 4)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_CCMR1 = PWMB_CCMR1 & ~(0x07 << 4) | ((__MODE__) << 4)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMB_PWM2_ConfigOutputMode(__MODE__) do{ \
|
#define PWMB_PWM2_ConfigOutputMode(__MODE__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_CCMR2 = PWMB_CCMR2 & ~(0x07 << 4) | ((__MODE__) << 4)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_CCMR2 = PWMB_CCMR2 & ~(0x07 << 4) | ((__MODE__) << 4)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMB_PWM3_ConfigOutputMode(__MODE__) do{ \
|
#define PWMB_PWM3_ConfigOutputMode(__MODE__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_CCMR3 = PWMB_CCMR3 & ~(0x07 << 4) | ((__MODE__) << 4)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_CCMR3 = PWMB_CCMR3 & ~(0x07 << 4) | ((__MODE__) << 4)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMB_PWM4_ConfigOutputMode(__MODE__) do{ \
|
#define PWMB_PWM4_ConfigOutputMode(__MODE__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_CCMR4 = PWMB_CCMR4 & ~(0x07 << 4) | ((__MODE__) << 4)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_CCMR4 = PWMB_CCMR4 & ~(0x07 << 4) | ((__MODE__) << 4)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configurate PWMB.1(PWM5) - PWMB.4(PWM8) capture/comparison value, this will affect duty cycle
|
* Configurate PWMB.1(PWM5) - PWMB.4(PWM8) capture/comparison value, this will affect duty cycle
|
||||||
*/
|
*/
|
||||||
#define PWMB_PWM1_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
#define PWMB_PWM1_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(PWMB_CCR1H = ((__16BIT_VAL__) >> 8)); \
|
(PWMB_CCR1H = ((__16BIT_VAL__) >> 8)); \
|
||||||
(PWMB_CCR1L = ((__16BIT_VAL__) & 0xFF)); \
|
(PWMB_CCR1L = ((__16BIT_VAL__) & 0xFF)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMB_PWM2_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
#define PWMB_PWM2_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(PWMB_CCR2H = ((__16BIT_VAL__) >> 8)); \
|
(PWMB_CCR2H = ((__16BIT_VAL__) >> 8)); \
|
||||||
(PWMB_CCR2L = ((__16BIT_VAL__) & 0xFF)); \
|
(PWMB_CCR2L = ((__16BIT_VAL__) & 0xFF)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMB_PWM3_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
#define PWMB_PWM3_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(PWMB_CCR3H = ((__16BIT_VAL__) >> 8)); \
|
(PWMB_CCR3H = ((__16BIT_VAL__) >> 8)); \
|
||||||
(PWMB_CCR3L = ((__16BIT_VAL__) & 0xFF)); \
|
(PWMB_CCR3L = ((__16BIT_VAL__) & 0xFF)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMB_PWM4_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
#define PWMB_PWM4_SetCaptureCompareValue(__16BIT_VAL__) do{ \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(PWMB_CCR4H = ((__16BIT_VAL__) >> 8)); \
|
(PWMB_CCR4H = ((__16BIT_VAL__) >> 8)); \
|
||||||
(PWMB_CCR4L = ((__16BIT_VAL__) & 0xFF)); \
|
(PWMB_CCR4L = ((__16BIT_VAL__) & 0xFF)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
@ -511,16 +511,16 @@ typedef enum
|
|||||||
|
|
||||||
// Alternative port selection
|
// Alternative port selection
|
||||||
#define PWMB_PWM1_SetPort(__ALTER_PORT__) do{ \
|
#define PWMB_PWM1_SetPort(__ALTER_PORT__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_PS = PWMB_PS & ~(0x03 << 0) | ((__ALTER_PORT__) << 0)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_PS = PWMB_PS & ~(0x03 << 0) | ((__ALTER_PORT__) << 0)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMB_PWM2_SetPort(__ALTER_PORT__) do{ \
|
#define PWMB_PWM2_SetPort(__ALTER_PORT__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_PS = PWMB_PS & ~(0x03 << 2) | ((__ALTER_PORT__) << 2)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_PS = PWMB_PS & ~(0x03 << 2) | ((__ALTER_PORT__) << 2)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMB_PWM3_SetPort(__ALTER_PORT__) do{ \
|
#define PWMB_PWM3_SetPort(__ALTER_PORT__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_PS = PWMB_PS & ~(0x03 << 4) | ((__ALTER_PORT__) << 4)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_PS = PWMB_PS & ~(0x03 << 4) | ((__ALTER_PORT__) << 4)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
#define PWMB_PWM4_SetPort(__ALTER_PORT__) do{ \
|
#define PWMB_PWM4_SetPort(__ALTER_PORT__) do{ \
|
||||||
P_SW2 = 0x80;(PWMB_PS = PWMB_PS & ~(0x03 << 6) | ((__ALTER_PORT__) << 6)); P_SW2 = 0x00; \
|
SFRX_ON();(PWMB_PS = PWMB_PS & ~(0x03 << 6) | ((__ALTER_PORT__) << 6)); SFRX_OFF(); \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,10 +66,10 @@ typedef enum
|
|||||||
#define SPI_ClearInterrupts() (SPSTAT |= 0xC0)
|
#define SPI_ClearInterrupts() (SPSTAT |= 0xC0)
|
||||||
|
|
||||||
#define SPI_IgnoreSlaveSelect(__STATE__) SFR_ASSIGN(SPCTL, 7, __STATE__)
|
#define SPI_IgnoreSlaveSelect(__STATE__) SFR_ASSIGN(SPCTL, 7, __STATE__)
|
||||||
#define SPI_SetEnableState(__STATE__) SFR_ASSIGN(SPCTL, 6, __STATE__)
|
#define SPI_SetEnabled(__STATE__) SFR_ASSIGN(SPCTL, 6, __STATE__)
|
||||||
#define SPI_SetDataOrder(__ORDER__) SFR_ASSIGN(SPCTL, 5, __ORDER__)
|
#define SPI_SetDataOrder(__ORDER__) SFR_ASSIGN(SPCTL, 5, __ORDER__)
|
||||||
#define SPI_SetMasterMode(__STATE__) SFR_ASSIGN(SPCTL, 4, __STATE__)
|
#define SPI_SetMasterMode(__STATE__) SFR_ASSIGN(SPCTL, 4, __STATE__)
|
||||||
//
|
|
||||||
/**
|
/**
|
||||||
* Clock Polarity, CPOL
|
* Clock Polarity, CPOL
|
||||||
* 0: clock line idles low
|
* 0: clock line idles low
|
||||||
|
@ -81,7 +81,7 @@ void TIM_Timer1_Config(HAL_State_t freq1t, TIM_TimerMode_t mode, uint16_t freque
|
|||||||
#define TIM_Timer2_SetOutput(__STATE__) SFR_ASSIGN(INTCLKO, 2, __STATE__)
|
#define TIM_Timer2_SetOutput(__STATE__) SFR_ASSIGN(INTCLKO, 2, __STATE__)
|
||||||
#define TIM_Timer2_SetInitValue(__TH__, __TL__) do{ T2H = (__TH__); T2L = (__TL__); }while(0)
|
#define TIM_Timer2_SetInitValue(__TH__, __TL__) do{ T2H = (__TH__); T2L = (__TL__); }while(0)
|
||||||
// Timer2 Prescaler: [0, 255]
|
// Timer2 Prescaler: [0, 255]
|
||||||
#define TIM_Timer2_SetPreScaler(__PRE__) do{P_SW2 = 0x80; TM2PS = (__PRE__); P_SW2 = 0x00;}while(0)
|
#define TIM_Timer2_SetPreScaler(__PRE__) do{SFRX_ON(); TM2PS = (__PRE__); SFRX_OFF();}while(0)
|
||||||
|
|
||||||
void TIM_Timer2_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency);
|
void TIM_Timer2_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency);
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ void TIM_Timer2_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency
|
|||||||
#define TIM_Timer3_SetOutput(__STATE__) SFR_ASSIGN(T4T3M, 0, __STATE__)
|
#define TIM_Timer3_SetOutput(__STATE__) SFR_ASSIGN(T4T3M, 0, __STATE__)
|
||||||
#define TIM_Timer3_SetInitValue(__TH__, __TL__) do{ T3H = (__TH__); T3L = (__TL__); }while(0)
|
#define TIM_Timer3_SetInitValue(__TH__, __TL__) do{ T3H = (__TH__); T3L = (__TL__); }while(0)
|
||||||
// Timer3 Prescaler: [0, 255]
|
// Timer3 Prescaler: [0, 255]
|
||||||
#define TIM_Timer3_SetPreScaler(__PRE__) do{P_SW2 = 0x80; TM3PS = (__PRE__); P_SW2 = 0x00;}while(0)
|
#define TIM_Timer3_SetPreScaler(__PRE__) do{SFRX_ON(); TM3PS = (__PRE__); SFRX_OFF();}while(0)
|
||||||
|
|
||||||
void TIM_Timer3_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency, HAL_State_t intState);
|
void TIM_Timer3_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency, HAL_State_t intState);
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ void TIM_Timer3_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency
|
|||||||
#define TIM_Timer4_SetOutput(__STATE__) SFR_ASSIGN(T4T3M, 4, __STATE__)
|
#define TIM_Timer4_SetOutput(__STATE__) SFR_ASSIGN(T4T3M, 4, __STATE__)
|
||||||
#define TIM_Timer4_SetInitValue(__TH__, __TL__) do{ T4H = (__TH__); T4L = (__TL__); }while(0)
|
#define TIM_Timer4_SetInitValue(__TH__, __TL__) do{ T4H = (__TH__); T4L = (__TL__); }while(0)
|
||||||
// Timer4 Prescaler: [0, 255]
|
// Timer4 Prescaler: [0, 255]
|
||||||
#define TIM_Timer4_SetPreScaler(__PRE__) do{P_SW2 = 0x80; TM4PS = (__PRE__); P_SW2 = 0x00;}while(0)
|
#define TIM_Timer4_SetPreScaler(__PRE__) do{SFRX_ON(); TM4PS = (__PRE__); SFRX_OFF();}while(0)
|
||||||
|
|
||||||
void TIM_Timer4_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency, HAL_State_t intState);
|
void TIM_Timer4_Config(HAL_State_t freq1t, uint8_t prescaler, uint16_t frequency, HAL_State_t intState);
|
||||||
|
|
||||||
|
@ -104,22 +104,28 @@ typedef enum
|
|||||||
(__SFR1__) = (__SFR1__) & ~(0x01 << (__POS__)) | (((__VAL__) & 0x02)? (0x01 << (__POS__)) : 0x00); \
|
(__SFR1__) = (__SFR1__) & ~(0x01 << (__POS__)) | (((__VAL__) & 0x02)? (0x01 << (__POS__)) : 0x00); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xdata sfr address switch
|
||||||
|
*/
|
||||||
|
#define SFRX_ON() (P_SW2 |= 0x80)
|
||||||
|
#define SFRX_OFF() (P_SW2 &= ~0x80)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xdata sfr operations
|
* xdata sfr operations
|
||||||
*/
|
*/
|
||||||
#define SFRX_SET(__SFR__, __POS__) do {P_SW2 = 0x80; (__SFR__) |= (0x01 << (__POS__)); P_SW2 = 0x00;} while(0)
|
#define SFRX_SET(__SFR__, __POS__) do {SFRX_ON(); (__SFR__) |= (0x01 << (__POS__)); SFRX_OFF();} while(0)
|
||||||
#define SFRX_RESET(__SFR__, __POS__) do {P_SW2 = 0x80; (__SFR__) &= ~(0x01 << (__POS__)); P_SW2 = 0x00;} while(0)
|
#define SFRX_RESET(__SFR__, __POS__) do {SFRX_ON(); (__SFR__) &= ~(0x01 << (__POS__)); SFRX_OFF();} while(0)
|
||||||
#define SFRX_ASSIGN(__SFR__, __POS__, __VAL__) do { \
|
#define SFRX_ASSIGN(__SFR__, __POS__, __VAL__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(__SFR__) = (__SFR__) & ~(0x01 << (__POS__)) | ((__VAL__) << (__POS__)); \
|
(__SFR__) = (__SFR__) & ~(0x01 << (__POS__)) | ((__VAL__) << (__POS__)); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
// For dual xdata sfr bit (one for each) operation
|
// For dual xdata sfr bit (one for each) operation
|
||||||
#define SFRX_DUAL_SET(__SFR0__, __SFR1__, __POS__, __VAL__) do { \
|
#define SFRX_DUAL_SET(__SFR0__, __SFR1__, __POS__, __VAL__) do { \
|
||||||
P_SW2 = 0x80; \
|
SFRX_ON(); \
|
||||||
(__SFR0__) = (__SFR0__) & ~(0x01 << (__POS__)) | (((__VAL__) & 0x01)? (0x01 << (__POS__)) : 0x00); \
|
(__SFR0__) = (__SFR0__) & ~(0x01 << (__POS__)) | (((__VAL__) & 0x01)? (0x01 << (__POS__)) : 0x00); \
|
||||||
(__SFR1__) = (__SFR1__) & ~(0x01 << (__POS__)) | (((__VAL__) & 0x02)? (0x01 << (__POS__)) : 0x00); \
|
(__SFR1__) = (__SFR1__) & ~(0x01 << (__POS__)) | (((__VAL__) & 0x02)? (0x01 << (__POS__)) : 0x00); \
|
||||||
P_SW2 = 0x00; \
|
SFRX_OFF(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user