mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 01:05:10 +03:00
Constants renamed (so that Taranis hal is now nice)
This commit is contained in:
parent
bab4168ac4
commit
8365a8dbaf
39 changed files with 999 additions and 1006 deletions
|
@ -73,14 +73,14 @@ void getTrims(int16_t values[4])
|
|||
values[i] = g_model.trim[i];
|
||||
}
|
||||
|
||||
#define GPIO_TRIM_LH_L pind
|
||||
#define GPIO_TRIM_LV_DN pind
|
||||
#define GPIO_TRIM_RV_UP pind
|
||||
#define GPIO_TRIM_RH_L pind
|
||||
#define GPIO_TRIM_LH_R pind
|
||||
#define GPIO_TRIM_LV_UP pind
|
||||
#define GPIO_TRIM_RV_DN pind
|
||||
#define GPIO_TRIM_RH_R pind
|
||||
#define TRIMS_GPIO_REG_LHL pind
|
||||
#define TRIMS_GPIO_REG_LVD pind
|
||||
#define TRIMS_GPIO_REG_RVU pind
|
||||
#define TRIMS_GPIO_REG_RHL pind
|
||||
#define TRIMS_GPIO_REG_LHR pind
|
||||
#define TRIMS_GPIO_REG_LVU pind
|
||||
#define TRIMS_GPIO_REG_RVD pind
|
||||
#define TRIMS_GPIO_REG_RHR pind
|
||||
#define PIN_TRIM_LH_L (1<<INP_D_TRM_LH_DWN)
|
||||
#define PIN_TRIM_LV_DN (1<<INP_D_TRM_LV_DWN)
|
||||
#define PIN_TRIM_RV_UP (1<<INP_D_TRM_RV_UP)
|
||||
|
@ -98,14 +98,14 @@ void getTrims(int16_t values[4])
|
|||
void simuSetTrim(uint8_t trim, bool state)
|
||||
{
|
||||
switch (trim) {
|
||||
TRIM_CASE(0, GPIO_TRIM_LH_L, PIN_TRIM_LH_L)
|
||||
TRIM_CASE(1, GPIO_TRIM_LH_R, PIN_TRIM_LH_R)
|
||||
TRIM_CASE(2, GPIO_TRIM_LV_DN, PIN_TRIM_LV_DN)
|
||||
TRIM_CASE(3, GPIO_TRIM_LV_UP, PIN_TRIM_LV_UP)
|
||||
TRIM_CASE(4, GPIO_TRIM_RV_DN, PIN_TRIM_RV_DN)
|
||||
TRIM_CASE(5, GPIO_TRIM_RV_UP, PIN_TRIM_RV_UP)
|
||||
TRIM_CASE(6, GPIO_TRIM_RH_L, PIN_TRIM_RH_L)
|
||||
TRIM_CASE(7, GPIO_TRIM_RH_R, PIN_TRIM_RH_R)
|
||||
TRIM_CASE(0, TRIMS_GPIO_REG_LHL, PIN_TRIM_LH_L)
|
||||
TRIM_CASE(1, TRIMS_GPIO_REG_LHR, PIN_TRIM_LH_R)
|
||||
TRIM_CASE(2, TRIMS_GPIO_REG_LVD, PIN_TRIM_LV_DN)
|
||||
TRIM_CASE(3, TRIMS_GPIO_REG_LVU, PIN_TRIM_LV_UP)
|
||||
TRIM_CASE(4, TRIMS_GPIO_REG_RVD, PIN_TRIM_RV_DN)
|
||||
TRIM_CASE(5, TRIMS_GPIO_REG_RVU, PIN_TRIM_RV_UP)
|
||||
TRIM_CASE(6, TRIMS_GPIO_REG_RHL, PIN_TRIM_RH_L)
|
||||
TRIM_CASE(7, TRIMS_GPIO_REG_RHR, PIN_TRIM_RH_R)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,18 +114,18 @@ void simuSetSwitch(uint8_t swtch, int8_t state)
|
|||
}
|
||||
}
|
||||
|
||||
#define GPIO_BUTTON_MENU PIOB->PIO_PDSR
|
||||
#define GPIO_BUTTON_EXIT PIOC->PIO_PDSR
|
||||
#define GPIO_BUTTON_UP PIOC->PIO_PDSR
|
||||
#define GPIO_BUTTON_DOWN PIOC->PIO_PDSR
|
||||
#define GPIO_BUTTON_RIGHT PIOC->PIO_PDSR
|
||||
#define GPIO_BUTTON_LEFT PIOC->PIO_PDSR
|
||||
#define PIN_BUTTON_MENU 0x00000020
|
||||
#define PIN_BUTTON_EXIT 0x01000000
|
||||
#define PIN_BUTTON_UP 0x00000002
|
||||
#define PIN_BUTTON_DOWN 0x00000020
|
||||
#define PIN_BUTTON_RIGHT 0x00000010
|
||||
#define PIN_BUTTON_LEFT 0x00000008
|
||||
#define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_EXIT PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_UP PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_DOWN PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_RIGHT PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_LEFT PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_PIN_MENU 0x00000020
|
||||
#define KEYS_GPIO_PIN_EXIT 0x01000000
|
||||
#define KEYS_GPIO_PIN_UP 0x00000002
|
||||
#define KEYS_GPIO_PIN_DOWN 0x00000020
|
||||
#define KEYS_GPIO_PIN_RIGHT 0x00000010
|
||||
#define KEYS_GPIO_PIN_LEFT 0x00000008
|
||||
|
||||
#define KEY_CASE(key, pin, mask) \
|
||||
case key: \
|
||||
|
@ -135,23 +135,23 @@ void simuSetSwitch(uint8_t swtch, int8_t state)
|
|||
void simuSetKey(uint8_t key, bool state)
|
||||
{
|
||||
switch (key) {
|
||||
KEY_CASE(KEY_MENU, GPIO_BUTTON_MENU, PIN_BUTTON_MENU)
|
||||
KEY_CASE(KEY_EXIT, GPIO_BUTTON_EXIT, PIN_BUTTON_EXIT)
|
||||
KEY_CASE(KEY_RIGHT, GPIO_BUTTON_RIGHT, PIN_BUTTON_RIGHT)
|
||||
KEY_CASE(KEY_LEFT, GPIO_BUTTON_LEFT, PIN_BUTTON_LEFT)
|
||||
KEY_CASE(KEY_UP, GPIO_BUTTON_UP, PIN_BUTTON_UP)
|
||||
KEY_CASE(KEY_DOWN, GPIO_BUTTON_DOWN, PIN_BUTTON_DOWN)
|
||||
KEY_CASE(KEY_MENU, KEYS_GPIO_REG_MENU, KEYS_GPIO_PIN_MENU)
|
||||
KEY_CASE(KEY_EXIT, KEYS_GPIO_REG_EXIT, KEYS_GPIO_PIN_EXIT)
|
||||
KEY_CASE(KEY_RIGHT, KEYS_GPIO_REG_RIGHT, KEYS_GPIO_PIN_RIGHT)
|
||||
KEY_CASE(KEY_LEFT, KEYS_GPIO_REG_LEFT, KEYS_GPIO_PIN_LEFT)
|
||||
KEY_CASE(KEY_UP, KEYS_GPIO_REG_UP, KEYS_GPIO_PIN_UP)
|
||||
KEY_CASE(KEY_DOWN, KEYS_GPIO_REG_DOWN, KEYS_GPIO_PIN_DOWN)
|
||||
}
|
||||
}
|
||||
|
||||
#define GPIO_TRIM_LH_L PIOA->PIO_PDSR
|
||||
#define GPIO_TRIM_LV_DN PIOA->PIO_PDSR
|
||||
#define GPIO_TRIM_RV_UP PIOA->PIO_PDSR
|
||||
#define GPIO_TRIM_RH_L PIOA->PIO_PDSR
|
||||
#define GPIO_TRIM_LH_R PIOB->PIO_PDSR
|
||||
#define GPIO_TRIM_LV_UP PIOC->PIO_PDSR
|
||||
#define GPIO_TRIM_RV_DN PIOC->PIO_PDSR
|
||||
#define GPIO_TRIM_RH_R PIOC->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_LHL PIOA->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_LVD PIOA->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_RVU PIOA->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_RHL PIOA->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_LHR PIOB->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_LVU PIOC->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_RVD PIOC->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_RHR PIOC->PIO_PDSR
|
||||
#define PIN_TRIM_LH_L 0x00800000
|
||||
#define PIN_TRIM_LV_DN 0x01000000
|
||||
#define PIN_TRIM_RV_UP 0x00000002
|
||||
|
@ -166,14 +166,14 @@ void simuSetKey(uint8_t key, bool state)
|
|||
void simuSetTrim(uint8_t trim, bool state)
|
||||
{
|
||||
switch (trim) {
|
||||
TRIM_CASE(0, GPIO_TRIM_LH_L, PIN_TRIM_LH_L)
|
||||
TRIM_CASE(1, GPIO_TRIM_LH_R, PIN_TRIM_LH_R)
|
||||
TRIM_CASE(2, GPIO_TRIM_LV_DN, PIN_TRIM_LV_DN)
|
||||
TRIM_CASE(3, GPIO_TRIM_LV_UP, PIN_TRIM_LV_UP)
|
||||
TRIM_CASE(4, GPIO_TRIM_RV_DN, PIN_TRIM_RV_DN)
|
||||
TRIM_CASE(5, GPIO_TRIM_RV_UP, PIN_TRIM_RV_UP)
|
||||
TRIM_CASE(6, GPIO_TRIM_RH_L, PIN_TRIM_RH_L)
|
||||
TRIM_CASE(7, GPIO_TRIM_RH_R, PIN_TRIM_RH_R)
|
||||
TRIM_CASE(0, TRIMS_GPIO_REG_LHL, PIN_TRIM_LH_L)
|
||||
TRIM_CASE(1, TRIMS_GPIO_REG_LHR, PIN_TRIM_LH_R)
|
||||
TRIM_CASE(2, TRIMS_GPIO_REG_LVD, PIN_TRIM_LV_DN)
|
||||
TRIM_CASE(3, TRIMS_GPIO_REG_LVU, PIN_TRIM_LV_UP)
|
||||
TRIM_CASE(4, TRIMS_GPIO_REG_RVD, PIN_TRIM_RV_DN)
|
||||
TRIM_CASE(5, TRIMS_GPIO_REG_RVU, PIN_TRIM_RV_UP)
|
||||
TRIM_CASE(6, TRIMS_GPIO_REG_RHL, PIN_TRIM_RH_L)
|
||||
TRIM_CASE(7, TRIMS_GPIO_REG_RHR, PIN_TRIM_RH_R)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,32 +105,32 @@ set(OPENTX_LIBRARIES
|
|||
|
||||
# 9X with ATmega64
|
||||
target_include_directories(opentx-9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/stock)
|
||||
target_compile_definitions(opentx-9x${SUFFIX}-simulator PRIVATE PCBSTD PCB9X CPUM64 ${COMMON_DEFINITIONS})
|
||||
target_compile_definitions(opentx-9x${SUFFIX}-simulator PRIVATE PCBSTD PCB9X CPUM64 EEPROM_RLC ${COMMON_DEFINITIONS})
|
||||
target_link_libraries(opentx-9x${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES})
|
||||
|
||||
# 9XR with ATmega64
|
||||
target_include_directories(opentx-9xr${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/stock)
|
||||
target_compile_definitions(opentx-9xr${SUFFIX}-simulator PRIVATE PCBSTD PCB9XR CPUM64 ${COMMON_DEFINITIONS})
|
||||
target_compile_definitions(opentx-9xr${SUFFIX}-simulator PRIVATE PCBSTD PCB9XR CPUM64 EEPROM_RLC ${COMMON_DEFINITIONS})
|
||||
target_link_libraries(opentx-9xr${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES})
|
||||
|
||||
# 9X with ATmega128
|
||||
target_include_directories(opentx-9x128${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/stock)
|
||||
target_compile_definitions(opentx-9x128${SUFFIX}-simulator PRIVATE PCBSTD PCB9X CPUM128 ${COMMON_DEFINITIONS})
|
||||
target_compile_definitions(opentx-9x128${SUFFIX}-simulator PRIVATE PCBSTD PCB9X CPUM128 EEPROM_RLC ${COMMON_DEFINITIONS})
|
||||
target_link_libraries(opentx-9x128${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES})
|
||||
|
||||
# 9XR with ATmega128
|
||||
target_include_directories(opentx-9xr128${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/stock)
|
||||
target_compile_definitions(opentx-9xr128${SUFFIX}-simulator PRIVATE PCBSTD PCB9XR CPUM128 ${COMMON_DEFINITIONS})
|
||||
target_compile_definitions(opentx-9xr128${SUFFIX}-simulator PRIVATE PCBSTD PCB9XR CPUM128 EEPROM_RLC ${COMMON_DEFINITIONS})
|
||||
target_link_libraries(opentx-9xr128${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES})
|
||||
|
||||
# Gruvin9x
|
||||
target_include_directories(opentx-gruvin9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/gruvin9x)
|
||||
target_compile_definitions(opentx-gruvin9x${SUFFIX}-simulator PRIVATE PCBGRUVIN9X CPUM2560 VOICE SDCARD ${COMMON_DEFINITIONS})
|
||||
target_compile_definitions(opentx-gruvin9x${SUFFIX}-simulator PRIVATE PCBGRUVIN9X CPUM2560 EEPROM_RLC VOICE SDCARD ${COMMON_DEFINITIONS})
|
||||
target_link_libraries(opentx-gruvin9x${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES})
|
||||
|
||||
# Mega2560
|
||||
target_include_directories(opentx-mega2560${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/mega2560)
|
||||
target_compile_definitions(opentx-mega2560${SUFFIX}-simulator PRIVATE PCBMEGA2560 CPUM2560 SDCARD ROTARY_ENCODERS=2 ${COMMON_DEFINITIONS})
|
||||
target_compile_definitions(opentx-mega2560${SUFFIX}-simulator PRIVATE PCBMEGA2560 CPUM2560 EEPROM_RLC SDCARD ROTARY_ENCODERS=2 ${COMMON_DEFINITIONS})
|
||||
target_link_libraries(opentx-mega2560${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES})
|
||||
|
||||
# Sky9x
|
||||
|
@ -145,17 +145,17 @@ target_link_libraries(opentx-9xrpro${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIE
|
|||
|
||||
# Taranis standard
|
||||
target_include_directories(opentx-taranis${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/taranis)
|
||||
target_compile_definitions(opentx-taranis${SUFFIX}-simulator PRIVATE PCBTARANIS CPUARM CPUSTM32 VOICE SDCARD ${COMMON_DEFINITIONS})
|
||||
target_compile_definitions(opentx-taranis${SUFFIX}-simulator PRIVATE PCBTARANIS CPUARM CPUSTM32 EEPROM_RLC VOICE SDCARD ${COMMON_DEFINITIONS})
|
||||
target_link_libraries(opentx-taranis${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES})
|
||||
|
||||
# Taranis Plus
|
||||
target_include_directories(opentx-taranisplus${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/taranis)
|
||||
target_compile_definitions(opentx-taranisplus${SUFFIX}-simulator PRIVATE PCBTARANIS REVPLUS CPUARM CPUSTM32 VOICE SDCARD ${COMMON_DEFINITIONS})
|
||||
target_compile_definitions(opentx-taranisplus${SUFFIX}-simulator PRIVATE PCBTARANIS REVPLUS CPUARM CPUSTM32 EEPROM_RLC VOICE SDCARD ${COMMON_DEFINITIONS})
|
||||
target_link_libraries(opentx-taranisplus${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES})
|
||||
|
||||
# Taranis X9E
|
||||
target_include_directories(opentx-taranisx9e${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/taranis)
|
||||
target_compile_definitions(opentx-taranisx9e${SUFFIX}-simulator PRIVATE PCBTARANIS REVPLUS REV9E CPUARM CPUSTM32 STM32F40_41xxx VOICE SDCARD ${COMMON_DEFINITIONS})
|
||||
target_compile_definitions(opentx-taranisx9e${SUFFIX}-simulator PRIVATE PCBTARANIS REVPLUS REV9E CPUARM CPUSTM32 STM32F40_41xxx EEPROM_RLC VOICE SDCARD ${COMMON_DEFINITIONS})
|
||||
target_link_libraries(opentx-taranisx9e${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES})
|
||||
|
||||
ADD_CUSTOM_TARGET(opentx-simulators
|
||||
|
|
|
@ -83,7 +83,6 @@ namespace NAMESPACE {
|
|||
#include "radio/src/pulses/ppm_arm.cpp"
|
||||
#include "radio/src/pulses/pxx_arm.cpp"
|
||||
#include "radio/src/pulses/dsm2_arm.cpp"
|
||||
#include "radio/src/eeprom_conversions.cpp"
|
||||
#include "radio/src/main_arm.cpp"
|
||||
#include "radio/src/pulses/pulses_arm.cpp"
|
||||
#include "radio/src/tasks_arm.cpp"
|
||||
|
@ -98,10 +97,14 @@ namespace NAMESPACE {
|
|||
#endif
|
||||
|
||||
#include "radio/src/eeprom_common.cpp"
|
||||
#if defined(PCBSKY9X)
|
||||
#include "radio/src/eeprom_raw.cpp"
|
||||
#else
|
||||
#if defined(EEPROM_RLC)
|
||||
#include "radio/src/eeprom_rlc.cpp"
|
||||
#else
|
||||
#include "radio/src/eeprom_raw.cpp"
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS) || defined(PCBSKY9X)
|
||||
#include "radio/src/eeprom_conversions.cpp"
|
||||
#endif
|
||||
|
||||
#include "radio/src/opentx.cpp"
|
||||
|
@ -326,8 +329,14 @@ uint8_t getStickMode()
|
|||
#if defined(PCBTARANIS)
|
||||
void resetTrims()
|
||||
{
|
||||
GPIOE->IDR |= PIN_TRIM_LH_L | PIN_TRIM_LH_R | PIN_TRIM_LV_DN | PIN_TRIM_LV_UP;
|
||||
GPIOC->IDR |= PIN_TRIM_RV_DN | PIN_TRIM_RV_UP | PIN_TRIM_RH_L | PIN_TRIM_RH_R;
|
||||
TRIMS_GPIO_REG_RVD |= TRIMS_GPIO_PIN_RVD;
|
||||
TRIMS_GPIO_REG_RVU |= TRIMS_GPIO_PIN_RVU;
|
||||
TRIMS_GPIO_REG_RHL |= TRIMS_GPIO_PIN_RHL;
|
||||
TRIMS_GPIO_REG_RHR |= TRIMS_GPIO_PIN_RHR;
|
||||
TRIMS_GPIO_REG_LVD |= TRIMS_GPIO_PIN_LVD;
|
||||
TRIMS_GPIO_REG_LVU |= TRIMS_GPIO_PIN_LVU;
|
||||
TRIMS_GPIO_REG_LHL |= TRIMS_GPIO_PIN_LHL;
|
||||
TRIMS_GPIO_REG_LHR |= TRIMS_GPIO_PIN_LHR;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -78,14 +78,14 @@ void eeprom_RESV_mismatch(void)
|
|||
assert(!"Should never been called. Only needed by VC++ (debug mode)");
|
||||
}
|
||||
|
||||
#define GPIO_TRIM_LH_L pind
|
||||
#define GPIO_TRIM_LV_DN pind
|
||||
#define GPIO_TRIM_RV_UP pind
|
||||
#define GPIO_TRIM_RH_L pind
|
||||
#define GPIO_TRIM_LH_R pind
|
||||
#define GPIO_TRIM_LV_UP pind
|
||||
#define GPIO_TRIM_RV_DN pind
|
||||
#define GPIO_TRIM_RH_R pind
|
||||
#define TRIMS_GPIO_REG_LHL pind
|
||||
#define TRIMS_GPIO_REG_LVD pind
|
||||
#define TRIMS_GPIO_REG_RVU pind
|
||||
#define TRIMS_GPIO_REG_RHL pind
|
||||
#define TRIMS_GPIO_REG_LHR pind
|
||||
#define TRIMS_GPIO_REG_LVU pind
|
||||
#define TRIMS_GPIO_REG_RVD pind
|
||||
#define TRIMS_GPIO_REG_RHR pind
|
||||
#define PIN_TRIM_LH_L (1<<INP_D_TRM_LH_DWN)
|
||||
#define PIN_TRIM_LV_DN (1<<INP_D_TRM_LV_DWN)
|
||||
#define PIN_TRIM_RV_UP (1<<INP_D_TRM_RV_UP)
|
||||
|
@ -103,14 +103,14 @@ void eeprom_RESV_mismatch(void)
|
|||
void simuSetTrim(uint8_t trim, bool state)
|
||||
{
|
||||
switch (trim) {
|
||||
TRIM_CASE(0, GPIO_TRIM_LH_L, PIN_TRIM_LH_L)
|
||||
TRIM_CASE(1, GPIO_TRIM_LH_R, PIN_TRIM_LH_R)
|
||||
TRIM_CASE(2, GPIO_TRIM_LV_DN, PIN_TRIM_LV_DN)
|
||||
TRIM_CASE(3, GPIO_TRIM_LV_UP, PIN_TRIM_LV_UP)
|
||||
TRIM_CASE(4, GPIO_TRIM_RV_DN, PIN_TRIM_RV_DN)
|
||||
TRIM_CASE(5, GPIO_TRIM_RV_UP, PIN_TRIM_RV_UP)
|
||||
TRIM_CASE(6, GPIO_TRIM_RH_L, PIN_TRIM_RH_L)
|
||||
TRIM_CASE(7, GPIO_TRIM_RH_R, PIN_TRIM_RH_R)
|
||||
TRIM_CASE(0, TRIMS_GPIO_REG_LHL, PIN_TRIM_LH_L)
|
||||
TRIM_CASE(1, TRIMS_GPIO_REG_LHR, PIN_TRIM_LH_R)
|
||||
TRIM_CASE(2, TRIMS_GPIO_REG_LVD, PIN_TRIM_LV_DN)
|
||||
TRIM_CASE(3, TRIMS_GPIO_REG_LVU, PIN_TRIM_LV_UP)
|
||||
TRIM_CASE(4, TRIMS_GPIO_REG_RVD, PIN_TRIM_RV_DN)
|
||||
TRIM_CASE(5, TRIMS_GPIO_REG_RVU, PIN_TRIM_RV_UP)
|
||||
TRIM_CASE(6, TRIMS_GPIO_REG_RHL, PIN_TRIM_RH_L)
|
||||
TRIM_CASE(7, TRIMS_GPIO_REG_RHR, PIN_TRIM_RH_R)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,10 @@ class lcdWidget : public QWidget {
|
|||
lcdWidth = width;
|
||||
lcdHeight = height;
|
||||
lcdDepth = depth;
|
||||
lcdSize = (width * ((height+7)/8)) * depth;
|
||||
if (depth >= 8)
|
||||
lcdSize = (width * height) * (depth / 8);
|
||||
else
|
||||
lcdSize = (width * ((height+7)/8)) * depth;
|
||||
previousBuf = (unsigned char *)malloc(lcdSize);
|
||||
memset(previousBuf, 0, lcdSize);
|
||||
}
|
||||
|
@ -106,45 +109,57 @@ class lcdWidget : public QWidget {
|
|||
{
|
||||
QRgb rgb;
|
||||
|
||||
if (lightEnable)
|
||||
rgb = qRgb(_r, _g, _b);
|
||||
else
|
||||
rgb = qRgb(161, 161, 161);
|
||||
|
||||
p.setBackground(QBrush(rgb));
|
||||
p.eraseRect(0, 0, 2*lcdWidth, 2*lcdHeight);
|
||||
|
||||
if (lcdBuf) {
|
||||
if (lcdDepth == 1) {
|
||||
rgb = qRgb(0, 0, 0);
|
||||
p.setPen(rgb);
|
||||
p.setBrush(QBrush(rgb));
|
||||
if (lcdDepth >= 8) {
|
||||
for (int x=0; x<lcdWidth; x++) {
|
||||
for (int y=0; y<lcdHeight; y++) {
|
||||
uint16_t z = ((uint16_t *)lcdBuf)[y * lcdWidth + x];
|
||||
rgb = qRgb(255*((z&0xF00)>>8)/0x0f, 255*((z&0x0F0)>>4)/0x0f, 255*(z&0x00F)/0x0f);
|
||||
p.setPen(rgb);
|
||||
p.drawPoint(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (lightEnable)
|
||||
rgb = qRgb(_r, _g, _b);
|
||||
else
|
||||
rgb = qRgb(161, 161, 161);
|
||||
|
||||
unsigned int previousDepth = 0xFF;
|
||||
p.setBackground(QBrush(rgb));
|
||||
p.eraseRect(0, 0, 2*lcdWidth, 2*lcdHeight);
|
||||
|
||||
for (int y=0; y<lcdHeight; y++) {
|
||||
unsigned int idx = (y*lcdDepth/8)*lcdWidth;
|
||||
unsigned int mask = (1 << (y%8));
|
||||
for (int x=0; x<lcdWidth; x++, idx++) {
|
||||
if (lcdDepth == 1) {
|
||||
if (lcdBuf[idx] & mask) {
|
||||
p.drawRect(2*x, 2*y, 1, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
unsigned int z = (y & 1) ? (lcdBuf[idx] >> 4) : (lcdBuf[idx] & 0x0F);
|
||||
if (z) {
|
||||
if (z != previousDepth) {
|
||||
previousDepth = z;
|
||||
if (lightEnable)
|
||||
rgb = qRgb(_r-(z*_r)/15, _g-(z*_g)/15, _b-(z*_b)/15);
|
||||
else
|
||||
rgb = qRgb(161-(z*161)/15, 161-(z*161)/15, 161-(z*161)/15);
|
||||
p.setPen(rgb);
|
||||
p.setBrush(QBrush(rgb));
|
||||
if (lcdBuf) {
|
||||
if (lcdDepth == 1) {
|
||||
rgb = qRgb(0, 0, 0);
|
||||
p.setPen(rgb);
|
||||
p.setBrush(QBrush(rgb));
|
||||
}
|
||||
|
||||
unsigned int previousDepth = 0xFF;
|
||||
|
||||
for (int y=0; y<lcdHeight; y++) {
|
||||
unsigned int idx = (y*lcdDepth/8)*lcdWidth;
|
||||
unsigned int mask = (1 << (y%8));
|
||||
for (int x=0; x<lcdWidth; x++, idx++) {
|
||||
if (lcdDepth == 1) {
|
||||
if (lcdBuf[idx] & mask) {
|
||||
p.drawRect(2*x, 2*y, 1, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
unsigned int z = (y & 1) ? (lcdBuf[idx] >> 4) : (lcdBuf[idx] & 0x0F);
|
||||
if (z) {
|
||||
if (z != previousDepth) {
|
||||
previousDepth = z;
|
||||
if (lightEnable)
|
||||
rgb = qRgb(_r-(z*_r)/15, _g-(z*_g)/15, _b-(z*_b)/15);
|
||||
else
|
||||
rgb = qRgb(161-(z*161)/15, 161-(z*161)/15, 161-(z*161)/15);
|
||||
p.setPen(rgb);
|
||||
p.setBrush(QBrush(rgb));
|
||||
}
|
||||
p.drawRect(2*x, 2*y, 1, 1);
|
||||
}
|
||||
p.drawRect(2*x, 2*y, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, SimulatorInterface *simul
|
|||
beepShow(0)
|
||||
{
|
||||
lcdWidth = 128;
|
||||
lcdHeight = 64;
|
||||
lcdDepth = 1;
|
||||
|
||||
initUi<Ui::SimulatorDialog9X>(ui);
|
||||
|
@ -154,6 +155,7 @@ SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, SimulatorInterf
|
|||
ui(new Ui::SimulatorDialogTaranis)
|
||||
{
|
||||
lcdWidth = 212;
|
||||
lcdHeight = 64;
|
||||
lcdDepth = 4;
|
||||
|
||||
initUi<Ui::SimulatorDialogTaranis>(ui);
|
||||
|
@ -449,7 +451,7 @@ void SimulatorDialog::initUi(T * ui)
|
|||
|
||||
simulator->setSdPath(g.profile[g.id()].sdPath());
|
||||
simulator->setVolumeGain(g.profile[g.id()].volumeGain());
|
||||
lcd->setData(simulator->getLcd(), lcdWidth, 64, lcdDepth);
|
||||
lcd->setData(simulator->getLcd(), lcdWidth, lcdHeight, lcdDepth);
|
||||
|
||||
if (flags & SIMULATOR_FLAGS_STICK_MODE_LEFT) {
|
||||
nodeLeft->setCenteringY(false);
|
||||
|
|
|
@ -107,6 +107,7 @@ class SimulatorDialog : public QDialog
|
|||
int beepVal;
|
||||
|
||||
int lcdWidth;
|
||||
int lcdHeight;
|
||||
int lcdDepth;
|
||||
TelemetrySimulator * TelemetrySimu;
|
||||
TrainerSimulator * TrainerSimu;
|
||||
|
|
|
@ -46,7 +46,7 @@ pind = 0;
|
|||
if (inputs.rotenc) pind |= 0x20;
|
||||
#endif
|
||||
|
||||
#ifdef PCBSKY9X
|
||||
#if defined(PCBSKY9X)
|
||||
if (inputs.rotenc) PIOB->PIO_PDSR &= ~0x40; else PIOB->PIO_PDSR |= 0x40;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -414,7 +414,7 @@ ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR))
|
|||
SDCARD = NO
|
||||
THR_TRACE = NO
|
||||
INCDIRS += targets/stock
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM64 -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc)
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM64 -DEEPROM_RLC -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc)
|
||||
BOARDSRC = main_avr.cpp targets/stock/board_stock.cpp
|
||||
EXTRABOARDSRC = targets/common_avr/adc_driver.cpp targets/common_avr/telemetry_driver.cpp
|
||||
ifeq ($(GUI), YES)
|
||||
|
@ -495,7 +495,7 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128))
|
|||
SDCARD = NO
|
||||
THR_TRACE = NO
|
||||
EEPROM_VARIANT += ${M128_VARIANT}
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM128 -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc)
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM128 -DEEPROM_RLC -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc)
|
||||
INCDIRS += targets/stock
|
||||
BOARDSRC = main_avr.cpp targets/stock/board_stock.cpp
|
||||
EXTRABOARDSRC = targets/common_avr/adc_driver.cpp targets/stock/lcd_driver.cpp targets/common_avr/telemetry_driver.cpp
|
||||
|
@ -570,7 +570,7 @@ ifeq ($(PCB), $(filter $(PCB), 9X2561))
|
|||
SDCARD = NO
|
||||
THR_TRACE = YES
|
||||
EEPROM_VARIANT += ${M2561_VARIANT}
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM2561 -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc)
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM2561 -DEEPROM_RLC -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc)
|
||||
INCDIRS += targets/stock
|
||||
BOARDSRC = main_avr.cpp targets/stock/board_stock.cpp
|
||||
EXTRABOARDSRC = targets/common_avr/adc_driver.cpp targets/stock/lcd_driver.cpp targets/common_avr/telemetry_driver.cpp
|
||||
|
@ -640,7 +640,7 @@ ifeq ($(PCB), GRUVIN9X)
|
|||
TRGT = avr-
|
||||
MCU = atmega2560
|
||||
OPT = s
|
||||
CPPDEFS += -DF_CPU=$(F_CPU)UL -DPCBGRUVIN9X -DCPUM2560 -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC
|
||||
CPPDEFS += -DF_CPU=$(F_CPU)UL -DPCBGRUVIN9X -DCPUM2560 -DEEPROM_RLC -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC
|
||||
SDCARD = NO
|
||||
BUZZER = NO
|
||||
THR_TRACE = YES
|
||||
|
@ -685,7 +685,7 @@ ifeq ($(PCB), MEGA2560)
|
|||
TRGT = avr-
|
||||
MCU = atmega2560
|
||||
OPT = s
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBMEGA2560 -DCPUM2560 -DEEPROM_VARIANT=0 -DAUDIO
|
||||
CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBMEGA2560 -DCPUM2560 -DEEPROM_RLC -DEEPROM_VARIANT=0 -DAUDIO
|
||||
SDCARD = NO
|
||||
BUZZER = YES
|
||||
THR_TRACE = YES
|
||||
|
@ -884,19 +884,20 @@ ifeq ($(PCB), TARANIS)
|
|||
AUTOSWITCH = YES
|
||||
AUTOSOURCE = YES
|
||||
DBLKEYS = YES
|
||||
TIMERS = 2
|
||||
CPPDEFS += -DTIMERS=$(TIMERS)
|
||||
PPM_LIMITS_SYMETRICAL = YES
|
||||
PPM_CENTER_ADJUSTABLE = YES
|
||||
DSM2 = PPM
|
||||
CPPDEFS += -DPCBTARANIS -DCPUARM -DCPUSTM32 -DVIRTUALINPUTS -DLUAINPUTS -DXCURVES -DEEPROM_VARIANT=0 -DAUDIO -DPXX
|
||||
CPPDEFS += -DPCBTARANIS -DCPUARM -DCPUSTM32 -DVIRTUALINPUTS -DLUAINPUTS -DXCURVES -DEEPROM_RLC -DEEPROM_VARIANT=0 -DAUDIO -DPXX
|
||||
INCDIRS += targets/taranis $(THIRDPARTY) $(COOSDIR) $(COOSDIR)/kernel $(COOSDIR)/portable
|
||||
CPPDEFS += -DHSE_VALUE=12000000
|
||||
ifeq ($(PCBREV), REV9E)
|
||||
STM32LIBPATH = $(THIRDPARTY)/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries
|
||||
CPPDEFS += -DHSE_VALUE=12000000
|
||||
CPPDEFS += -DSTM32F40_41xxx
|
||||
INCDIRS += $(STM32LIBPATH)/CMSIS/Device/ST/STM32F4xx/Include $(STM32LIBPATH)/CMSIS/Include $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/inc
|
||||
else
|
||||
STM32LIBPATH= $(THIRDPARTY)/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries
|
||||
CPPDEFS += -DHSE_VALUE=12000000
|
||||
INCDIRS += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/inc $(STM32LIBPATH)/CMSIS/Device/ST/STM32F2xx/Include $(STM32LIBPATH)/CMSIS/include
|
||||
endif
|
||||
STM32USBPATH = $(THIRDPARTY)/STM32_USB-Host-Device_Lib_V2.1.0/Libraries
|
||||
|
@ -911,7 +912,8 @@ ifeq ($(PCB), TARANIS)
|
|||
PULSESSRC = pulses/pulses_arm.cpp pulses/ppm_arm.cpp pulses/pxx_arm.cpp
|
||||
CPPSRC += tasks_arm.cpp audio_arm.cpp sbus.cpp telemetry/telemetry.cpp
|
||||
CPPSRC += targets/taranis/pulses_driver.cpp targets/taranis/keys_driver.cpp targets/taranis/adc_driver.cpp targets/taranis/trainer_driver.cpp targets/taranis/audio_driver.cpp targets/taranis/uart3_driver.cpp targets/taranis/telemetry_driver.cpp
|
||||
CPPSRC += bmp.cpp gui/$(GUIDIRECTORY)/view_channels.cpp gui/$(GUIDIRECTORY)/view_about.cpp gui/$(GUIDIRECTORY)/view_text.cpp loadboot.cpp debug.cpp
|
||||
CPPSRC += bmp.cpp gui/$(GUIDIRECTORY)/view_channels.cpp gui/$(GUIDIRECTORY)/view_about.cpp gui/$(GUIDIRECTORY)/view_text.cpp debug.cpp
|
||||
CPPSRC += loadboot.cpp
|
||||
ifeq ($(PCBREV), REV9E)
|
||||
EXTRABOARDSRC += targets/taranis/top_lcd_driver.cpp
|
||||
SRC += targets/taranis/system_stm32f4xx.c
|
||||
|
@ -1678,7 +1680,7 @@ remallsrc:
|
|||
|
||||
# Link: create ELF output file from object files.
|
||||
ifeq ($(ARCH), AVR)
|
||||
%.elf: allsrc.cpp
|
||||
opentx.elf: allsrc.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $@
|
||||
$(CC) $(AVRCPPFLAGS) $< --output $@ $(LDFLAGS)
|
||||
|
@ -1689,7 +1691,7 @@ else
|
|||
$(AS) $< -o $@
|
||||
TMP = $(SRC:.c=.o)
|
||||
OBJS = $(TMP:.s=.o)
|
||||
%.elf: allsrc.cpp $(OBJS)
|
||||
opentx.elf: allsrc.cpp $(OBJS)
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $@
|
||||
$(CC) $(ARMCPPFLAGS) $< -o allsrc.o
|
||||
|
|
|
@ -1047,7 +1047,7 @@ void checkFailsafe()
|
|||
#if defined(GUI)
|
||||
void checkAll()
|
||||
{
|
||||
#if !defined(PCBSKY9X)
|
||||
#if defined(EEPROM_RLC)
|
||||
checkLowEEPROM();
|
||||
#endif
|
||||
|
||||
|
@ -1098,7 +1098,7 @@ void checkStartupWarnings()
|
|||
}
|
||||
#endif
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if defined(EEPROM_RLC)
|
||||
void checkLowEEPROM()
|
||||
{
|
||||
if (g_eeGeneral.disableMemoryWarning) return;
|
||||
|
@ -1391,7 +1391,7 @@ void getADC()
|
|||
|
||||
for (uint32_t x=0; x<NUMBER_ANALOG; x++) {
|
||||
uint16_t v = temp[x] >> 3;
|
||||
#if defined(PCBTARANIS)
|
||||
#if defined(VIRTUALINPUTS)
|
||||
if (calibrationState) v = temp[x] >> 1;
|
||||
StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[x];
|
||||
if (!calibrationState && IS_POT_MULTIPOS(x) && calib->count>0 && calib->count<XPOTS_MULTIPOS_COUNT) {
|
||||
|
@ -1964,7 +1964,6 @@ void checkBattery()
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int16_t g_ppmIns[NUM_TRAINER];
|
||||
|
|
|
@ -312,37 +312,37 @@ extern void boardInit();
|
|||
|
||||
#if defined(PCBTARANIS)
|
||||
#if defined(REV9E)
|
||||
#define NUM_SWITCHES 18 // yes, it's a lot!
|
||||
#define NUM_SWITCHES 18 // yes, it's a lot!
|
||||
#else
|
||||
#define NUM_SWITCHES 8
|
||||
#define NUM_SWITCHES 8
|
||||
#endif
|
||||
#define NUM_SW_SRCRAW 8
|
||||
#define SWSRC_THR SWSRC_SF2
|
||||
#define SWSRC_GEA SWSRC_SG2
|
||||
#define SWSRC_ID0 SWSRC_SA0
|
||||
#define SWSRC_ID1 SWSRC_SA1
|
||||
#define SWSRC_ID2 SWSRC_SA2
|
||||
#define SW_DSM2_BIND SW_SH2
|
||||
#define NUM_SW_SRCRAW 8
|
||||
#define SWSRC_THR SWSRC_SF2
|
||||
#define SWSRC_GEA SWSRC_SG2
|
||||
#define SWSRC_ID0 SWSRC_SA0
|
||||
#define SWSRC_ID1 SWSRC_SA1
|
||||
#define SWSRC_ID2 SWSRC_SA2
|
||||
#define SW_DSM2_BIND SW_SH2
|
||||
#else
|
||||
#define NUM_SWITCHES 7
|
||||
#define IS_3POS(sw) ((sw) == 0)
|
||||
#define NUM_SWITCHES 7
|
||||
#define IS_3POS(sw) ((sw) == 0)
|
||||
#define IS_MOMENTARY(sw) (sw == SWSRC_TRN)
|
||||
#define NUM_SW_SRCRAW 1
|
||||
#define SW_DSM2_BIND SW_TRN
|
||||
#define NUM_SW_SRCRAW 1
|
||||
#define SW_DSM2_BIND SW_TRN
|
||||
#endif
|
||||
|
||||
#define NUM_PSWITCH (SWSRC_LAST_SWITCH-SWSRC_FIRST_SWITCH+1)
|
||||
#define NUM_POTSSW (NUM_XPOTS*6)
|
||||
#define NUM_PSWITCH (SWSRC_LAST_SWITCH-SWSRC_FIRST_SWITCH+1)
|
||||
#define NUM_POTSSW (NUM_XPOTS*6)
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#define KEY_RIGHT KEY_PLUS
|
||||
#define KEY_LEFT KEY_MINUS
|
||||
#define KEY_UP KEY_PLUS
|
||||
#define KEY_DOWN KEY_MINUS
|
||||
#define KEY_RIGHT KEY_PLUS
|
||||
#define KEY_LEFT KEY_MINUS
|
||||
#define KEY_UP KEY_PLUS
|
||||
#define KEY_DOWN KEY_MINUS
|
||||
#else
|
||||
#define KEY_ENTER KEY_MENU
|
||||
#define KEY_PLUS KEY_RIGHT
|
||||
#define KEY_MINUS KEY_LEFT
|
||||
#define KEY_ENTER KEY_MENU
|
||||
#define KEY_PLUS KEY_RIGHT
|
||||
#define KEY_MINUS KEY_LEFT
|
||||
#endif
|
||||
|
||||
#include "myeeprom.h"
|
||||
|
@ -427,10 +427,10 @@ extern void boardInit();
|
|||
|
||||
#include "eeprom_common.h"
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#include "eeprom_raw.h"
|
||||
#else
|
||||
#if defined(EEPROM_RLC)
|
||||
#include "eeprom_rlc.h"
|
||||
#else
|
||||
#include "eeprom_raw.h"
|
||||
#endif
|
||||
|
||||
#include "pulses/pulses.h"
|
||||
|
|
|
@ -39,35 +39,35 @@
|
|||
|
||||
#include "../common_avr/board_avr.h"
|
||||
|
||||
#define GPIO_BUTTON_MENU pinl
|
||||
#define GPIO_BUTTON_EXIT pinl
|
||||
#define GPIO_BUTTON_RIGHT pinl
|
||||
#define GPIO_BUTTON_LEFT pinl
|
||||
#define GPIO_BUTTON_UP pinl
|
||||
#define GPIO_BUTTON_DOWN pinl
|
||||
#define PIN_BUTTON_MENU (1<<INP_L_KEY_MEN)
|
||||
#define PIN_BUTTON_EXIT (1<<INP_L_KEY_EXT)
|
||||
#define PIN_BUTTON_UP (1<<INP_L_KEY_UP)
|
||||
#define PIN_BUTTON_DOWN (1<<INP_L_KEY_DWN)
|
||||
#define PIN_BUTTON_RIGHT (1<<INP_L_KEY_RGT)
|
||||
#define PIN_BUTTON_LEFT (1<<INP_L_KEY_LFT)
|
||||
#define KEYS_GPIO_REG_MENU pinl
|
||||
#define KEYS_GPIO_REG_EXIT pinl
|
||||
#define KEYS_GPIO_REG_RIGHT pinl
|
||||
#define KEYS_GPIO_REG_LEFT pinl
|
||||
#define KEYS_GPIO_REG_UP pinl
|
||||
#define KEYS_GPIO_REG_DOWN pinl
|
||||
#define KEYS_GPIO_PIN_MENU (1<<INP_L_KEY_MEN)
|
||||
#define KEYS_GPIO_PIN_EXIT (1<<INP_L_KEY_EXT)
|
||||
#define KEYS_GPIO_PIN_UP (1<<INP_L_KEY_UP)
|
||||
#define KEYS_GPIO_PIN_DOWN (1<<INP_L_KEY_DWN)
|
||||
#define KEYS_GPIO_PIN_RIGHT (1<<INP_L_KEY_RGT)
|
||||
#define KEYS_GPIO_PIN_LEFT (1<<INP_L_KEY_LFT)
|
||||
|
||||
#define GPIO_TRIM_LH_L pinj
|
||||
#define GPIO_TRIM_LV_DN pinj
|
||||
#define GPIO_TRIM_RV_UP pinj
|
||||
#define GPIO_TRIM_RH_L pinj
|
||||
#define GPIO_TRIM_LH_R pinj
|
||||
#define GPIO_TRIM_LV_UP pinj
|
||||
#define GPIO_TRIM_RV_DN pinj
|
||||
#define GPIO_TRIM_RH_R pinj
|
||||
#define PIN_TRIM_LH_L (1<<INP_J_TRM_LH_DWN)
|
||||
#define PIN_TRIM_LV_DN (1<<INP_J_TRM_LV_DWN)
|
||||
#define PIN_TRIM_RV_UP (1<<INP_J_TRM_RV_UP)
|
||||
#define PIN_TRIM_RH_L (1<<INP_J_TRM_RH_DWN)
|
||||
#define PIN_TRIM_LH_R (1<<INP_J_TRM_LH_UP)
|
||||
#define PIN_TRIM_LV_UP (1<<INP_J_TRM_LV_UP)
|
||||
#define PIN_TRIM_RV_DN (1<<INP_J_TRM_RV_DWN)
|
||||
#define PIN_TRIM_RH_R (1<<INP_J_TRM_RH_UP)
|
||||
#define TRIMS_GPIO_REG_LHL pinj
|
||||
#define TRIMS_GPIO_REG_LVD pinj
|
||||
#define TRIMS_GPIO_REG_RVU pinj
|
||||
#define TRIMS_GPIO_REG_RHL pinj
|
||||
#define TRIMS_GPIO_REG_LHR pinj
|
||||
#define TRIMS_GPIO_REG_LVU pinj
|
||||
#define TRIMS_GPIO_REG_RVD pinj
|
||||
#define TRIMS_GPIO_REG_RHR pinj
|
||||
#define TRIMS_GPIO_PIN_LHL (1<<INP_J_TRM_LH_DWN)
|
||||
#define TRIMS_GPIO_PIN_LVD (1<<INP_J_TRM_LV_DWN)
|
||||
#define TRIMS_GPIO_PIN_RVU (1<<INP_J_TRM_RV_UP)
|
||||
#define TRIMS_GPIO_PIN_RHL (1<<INP_J_TRM_RH_DWN)
|
||||
#define TRIMS_GPIO_PIN_LHR (1<<INP_J_TRM_LH_UP)
|
||||
#define TRIMS_GPIO_PIN_LVU (1<<INP_J_TRM_LV_UP)
|
||||
#define TRIMS_GPIO_PIN_RVD (1<<INP_J_TRM_RV_DWN)
|
||||
#define TRIMS_GPIO_PIN_RHR (1<<INP_J_TRM_RH_UP)
|
||||
|
||||
#define TIMER_16KHZ_VECT TIMER2_OVF_vect
|
||||
#define COUNTER_16KHZ TCNT2
|
||||
|
|
|
@ -40,35 +40,35 @@
|
|||
|
||||
#include "../common_avr/board_avr.h"
|
||||
|
||||
#define GPIO_BUTTON_MENU pinl
|
||||
#define GPIO_BUTTON_EXIT pinl
|
||||
#define GPIO_BUTTON_RIGHT pinl
|
||||
#define GPIO_BUTTON_LEFT pinl
|
||||
#define GPIO_BUTTON_UP pinl
|
||||
#define GPIO_BUTTON_DOWN pinl
|
||||
#define PIN_BUTTON_MENU (1<<INP_L_KEY_MEN)
|
||||
#define PIN_BUTTON_EXIT (1<<INP_L_KEY_EXT)
|
||||
#define PIN_BUTTON_UP (1<<INP_L_KEY_UP)
|
||||
#define PIN_BUTTON_DOWN (1<<INP_L_KEY_DWN)
|
||||
#define PIN_BUTTON_RIGHT (1<<INP_L_KEY_RGT)
|
||||
#define PIN_BUTTON_LEFT (1<<INP_L_KEY_LFT)
|
||||
#define KEYS_GPIO_REG_MENU pinl
|
||||
#define KEYS_GPIO_REG_EXIT pinl
|
||||
#define KEYS_GPIO_REG_RIGHT pinl
|
||||
#define KEYS_GPIO_REG_LEFT pinl
|
||||
#define KEYS_GPIO_REG_UP pinl
|
||||
#define KEYS_GPIO_REG_DOWN pinl
|
||||
#define KEYS_GPIO_PIN_MENU (1<<INP_L_KEY_MEN)
|
||||
#define KEYS_GPIO_PIN_EXIT (1<<INP_L_KEY_EXT)
|
||||
#define KEYS_GPIO_PIN_UP (1<<INP_L_KEY_UP)
|
||||
#define KEYS_GPIO_PIN_DOWN (1<<INP_L_KEY_DWN)
|
||||
#define KEYS_GPIO_PIN_RIGHT (1<<INP_L_KEY_RGT)
|
||||
#define KEYS_GPIO_PIN_LEFT (1<<INP_L_KEY_LFT)
|
||||
|
||||
#define GPIO_TRIM_LH_L pinf
|
||||
#define GPIO_TRIM_LV_DN pinf
|
||||
#define GPIO_TRIM_RV_UP pinf
|
||||
#define GPIO_TRIM_RH_L pinf
|
||||
#define GPIO_TRIM_LH_R pinf
|
||||
#define GPIO_TRIM_LV_UP pinf
|
||||
#define GPIO_TRIM_RV_DN pinf
|
||||
#define GPIO_TRIM_RH_R pinf
|
||||
#define PIN_TRIM_LH_L (1<<INP_F_TRM_LH_DWN)
|
||||
#define PIN_TRIM_LV_DN (1<<INP_F_TRM_LV_DWN)
|
||||
#define PIN_TRIM_RV_UP (1<<INP_F_TRM_RV_UP)
|
||||
#define PIN_TRIM_RH_L (1<<INP_F_TRM_RH_DWN)
|
||||
#define PIN_TRIM_LH_R (1<<INP_F_TRM_LH_UP)
|
||||
#define PIN_TRIM_LV_UP (1<<INP_F_TRM_LV_UP)
|
||||
#define PIN_TRIM_RV_DN (1<<INP_F_TRM_RV_DWN)
|
||||
#define PIN_TRIM_RH_R (1<<INP_F_TRM_RH_UP)
|
||||
#define TRIMS_GPIO_REG_LHL pinf
|
||||
#define TRIMS_GPIO_REG_LVD pinf
|
||||
#define TRIMS_GPIO_REG_RVU pinf
|
||||
#define TRIMS_GPIO_REG_RHL pinf
|
||||
#define TRIMS_GPIO_REG_LHR pinf
|
||||
#define TRIMS_GPIO_REG_LVU pinf
|
||||
#define TRIMS_GPIO_REG_RVD pinf
|
||||
#define TRIMS_GPIO_REG_RHR pinf
|
||||
#define TRIMS_GPIO_PIN_LHL (1<<INP_F_TRM_LH_DWN)
|
||||
#define TRIMS_GPIO_PIN_LVD (1<<INP_F_TRM_LV_DWN)
|
||||
#define TRIMS_GPIO_PIN_RVU (1<<INP_F_TRM_RV_UP)
|
||||
#define TRIMS_GPIO_PIN_RHL (1<<INP_F_TRM_RH_DWN)
|
||||
#define TRIMS_GPIO_PIN_LHR (1<<INP_F_TRM_LH_UP)
|
||||
#define TRIMS_GPIO_PIN_LVU (1<<INP_F_TRM_LV_UP)
|
||||
#define TRIMS_GPIO_PIN_RVD (1<<INP_F_TRM_RV_DWN)
|
||||
#define TRIMS_GPIO_PIN_RHR (1<<INP_F_TRM_RH_UP)
|
||||
|
||||
#define TIMER_16KHZ_VECT TIMER2_OVF_vect
|
||||
#define COUNTER_16KHZ TCNT2
|
||||
|
|
|
@ -60,6 +60,7 @@ uint8_t portb, portc, porth=0, dummyport;
|
|||
uint16_t dummyport16;
|
||||
const char *eepromFile = NULL;
|
||||
FILE *fp = NULL;
|
||||
int g_snapshot_idx = 0;
|
||||
|
||||
#if defined(CPUSTM32)
|
||||
uint32_t Peri1_frequency, Peri2_frequency;
|
||||
|
@ -78,15 +79,15 @@ Dacc dacc;
|
|||
Adc Adc0;
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(EEPROM_RLC)
|
||||
extern uint16_t eeprom_pointer;
|
||||
extern uint8_t * eeprom_buffer_data;
|
||||
#else
|
||||
uint32_t eeprom_pointer;
|
||||
uint8_t * eeprom_buffer_data;
|
||||
volatile int32_t eeprom_buffer_size;
|
||||
bool eeprom_read_operation;
|
||||
#define EESIZE_SIMU (128*4096)
|
||||
#else
|
||||
extern uint16_t eeprom_pointer;
|
||||
extern uint8_t * eeprom_buffer_data;
|
||||
#define EESIZE_SIMU (128*4096) // TODO why here?
|
||||
#endif
|
||||
|
||||
#if !defined(EESIZE_SIMU)
|
||||
|
@ -147,18 +148,18 @@ void simuSetKey(uint8_t key, bool state)
|
|||
{
|
||||
// TRACE("simuSetKey(%d, %d)", key, state);
|
||||
switch (key) {
|
||||
KEY_CASE(KEY_MENU, GPIO_BUTTON_MENU, PIN_BUTTON_MENU)
|
||||
KEY_CASE(KEY_EXIT, GPIO_BUTTON_EXIT, PIN_BUTTON_EXIT)
|
||||
KEY_CASE(KEY_MENU, KEYS_GPIO_REG_MENU, KEYS_GPIO_PIN_MENU)
|
||||
KEY_CASE(KEY_EXIT, KEYS_GPIO_REG_EXIT, KEYS_GPIO_PIN_EXIT)
|
||||
#if defined(PCBTARANIS)
|
||||
KEY_CASE(KEY_ENTER, GPIO_BUTTON_ENTER, PIN_BUTTON_ENTER)
|
||||
KEY_CASE(KEY_PAGE, GPIO_BUTTON_PAGE, PIN_BUTTON_PAGE)
|
||||
KEY_CASE(KEY_MINUS, GPIO_BUTTON_MINUS, PIN_BUTTON_MINUS)
|
||||
KEY_CASE(KEY_PLUS, GPIO_BUTTON_PLUS, PIN_BUTTON_PLUS)
|
||||
KEY_CASE(KEY_ENTER, KEYS_GPIO_REG_ENTER, KEYS_GPIO_PIN_ENTER)
|
||||
KEY_CASE(KEY_PAGE, KEYS_GPIO_REG_PAGE, KEYS_GPIO_PIN_PAGE)
|
||||
KEY_CASE(KEY_MINUS, KEYS_GPIO_REG_MINUS, KEYS_GPIO_PIN_MINUS)
|
||||
KEY_CASE(KEY_PLUS, KEYS_GPIO_REG_PLUS, KEYS_GPIO_PIN_PLUS)
|
||||
#else
|
||||
KEY_CASE(KEY_RIGHT, GPIO_BUTTON_RIGHT, PIN_BUTTON_RIGHT)
|
||||
KEY_CASE(KEY_LEFT, GPIO_BUTTON_LEFT, PIN_BUTTON_LEFT)
|
||||
KEY_CASE(KEY_UP, GPIO_BUTTON_UP, PIN_BUTTON_UP)
|
||||
KEY_CASE(KEY_DOWN, GPIO_BUTTON_DOWN, PIN_BUTTON_DOWN)
|
||||
KEY_CASE(KEY_RIGHT, KEYS_GPIO_REG_RIGHT, KEYS_GPIO_PIN_RIGHT)
|
||||
KEY_CASE(KEY_LEFT, KEYS_GPIO_REG_LEFT, KEYS_GPIO_PIN_LEFT)
|
||||
KEY_CASE(KEY_UP, KEYS_GPIO_REG_UP, KEYS_GPIO_PIN_UP)
|
||||
KEY_CASE(KEY_DOWN, KEYS_GPIO_REG_DOWN, KEYS_GPIO_PIN_DOWN)
|
||||
#endif
|
||||
#if defined(PCBSKY9X) && !defined(REVX)
|
||||
KEY_CASE(BTN_REa, PIOB->PIO_PDSR, 0x40)
|
||||
|
@ -175,14 +176,14 @@ void simuSetTrim(uint8_t trim, bool state)
|
|||
// TRACE("trim=%d state=%d", trim, state);
|
||||
|
||||
switch (trim) {
|
||||
TRIM_CASE(0, GPIO_TRIM_LH_L, PIN_TRIM_LH_L)
|
||||
TRIM_CASE(1, GPIO_TRIM_LH_R, PIN_TRIM_LH_R)
|
||||
TRIM_CASE(2, GPIO_TRIM_LV_DN, PIN_TRIM_LV_DN)
|
||||
TRIM_CASE(3, GPIO_TRIM_LV_UP, PIN_TRIM_LV_UP)
|
||||
TRIM_CASE(4, GPIO_TRIM_RV_DN, PIN_TRIM_RV_DN)
|
||||
TRIM_CASE(5, GPIO_TRIM_RV_UP, PIN_TRIM_RV_UP)
|
||||
TRIM_CASE(6, GPIO_TRIM_RH_L, PIN_TRIM_RH_L)
|
||||
TRIM_CASE(7, GPIO_TRIM_RH_R, PIN_TRIM_RH_R)
|
||||
TRIM_CASE(0, TRIMS_GPIO_REG_LHL, TRIMS_GPIO_PIN_LHL)
|
||||
TRIM_CASE(1, TRIMS_GPIO_REG_LHR, TRIMS_GPIO_PIN_LHR)
|
||||
TRIM_CASE(2, TRIMS_GPIO_REG_LVD, TRIMS_GPIO_PIN_LVD)
|
||||
TRIM_CASE(3, TRIMS_GPIO_REG_LVU, TRIMS_GPIO_PIN_LVU)
|
||||
TRIM_CASE(4, TRIMS_GPIO_REG_RVD, TRIMS_GPIO_PIN_RVD)
|
||||
TRIM_CASE(5, TRIMS_GPIO_REG_RVU, TRIMS_GPIO_PIN_RVU)
|
||||
TRIM_CASE(6, TRIMS_GPIO_REG_RHL, TRIMS_GPIO_PIN_RHL)
|
||||
TRIM_CASE(7, TRIMS_GPIO_REG_RHR, TRIMS_GPIO_PIN_RHR)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,14 +212,14 @@ void simuSetSwitch(uint8_t swtch, int8_t state)
|
|||
SWITCH_3_CASE(16, GPIO_PIN_SW_Q_L, GPIO_PIN_SW_Q_H, PIN_SW_Q_L, PIN_SW_Q_H)
|
||||
SWITCH_3_CASE(17, GPIO_PIN_SW_R_L, GPIO_PIN_SW_R_H, PIN_SW_R_L, PIN_SW_R_H)
|
||||
#elif defined(PCBTARANIS)
|
||||
SWITCH_3_CASE(0, GPIO_PIN_SW_A_L, GPIO_PIN_SW_A_H, PIN_SW_A_L, PIN_SW_A_H)
|
||||
SWITCH_3_CASE(1, GPIO_PIN_SW_B_L, GPIO_PIN_SW_B_H, PIN_SW_B_L, PIN_SW_B_H)
|
||||
SWITCH_3_CASE(2, GPIO_PIN_SW_C_L, GPIO_PIN_SW_C_H, PIN_SW_C_L, PIN_SW_C_H)
|
||||
SWITCH_3_CASE(3, GPIO_PIN_SW_D_L, GPIO_PIN_SW_D_H, PIN_SW_D_L, PIN_SW_D_H)
|
||||
SWITCH_3_CASE(4, GPIO_PIN_SW_E_H, GPIO_PIN_SW_E_L, PIN_SW_E_H, PIN_SW_E_L)
|
||||
SWITCH_CASE(5, GPIO_PIN_SW_F, PIN_SW_F)
|
||||
SWITCH_3_CASE(6, GPIO_PIN_SW_G_L, GPIO_PIN_SW_G_H, PIN_SW_G_L, PIN_SW_G_H)
|
||||
SWITCH_CASE(7, GPIO_PIN_SW_H, PIN_SW_H)
|
||||
SWITCH_3_CASE(0, SWITCHES_GPIO_REG_A_L, SWITCHES_GPIO_REG_A_H, SWITCHES_GPIO_PIN_A_L, SWITCHES_GPIO_PIN_A_H)
|
||||
SWITCH_3_CASE(1, SWITCHES_GPIO_REG_B_L, SWITCHES_GPIO_REG_B_H, SWITCHES_GPIO_PIN_B_L, SWITCHES_GPIO_PIN_B_H)
|
||||
SWITCH_3_CASE(2, SWITCHES_GPIO_REG_C_L, SWITCHES_GPIO_REG_C_H, SWITCHES_GPIO_PIN_C_L, SWITCHES_GPIO_PIN_C_H)
|
||||
SWITCH_3_CASE(3, SWITCHES_GPIO_REG_D_L, SWITCHES_GPIO_REG_D_H, SWITCHES_GPIO_PIN_D_L, SWITCHES_GPIO_PIN_D_H)
|
||||
SWITCH_3_CASE(4, SWITCHES_GPIO_REG_E_H, SWITCHES_GPIO_REG_E_L, SWITCHES_GPIO_PIN_E_H, SWITCHES_GPIO_PIN_E_L)
|
||||
SWITCH_CASE(5, SWITCHES_GPIO_REG_F, SWITCHES_GPIO_PIN_F)
|
||||
SWITCH_3_CASE(6, SWITCHES_GPIO_REG_G_L, SWITCHES_GPIO_REG_G_H, SWITCHES_GPIO_PIN_G_L, SWITCHES_GPIO_PIN_G_H)
|
||||
SWITCH_CASE(7, SWITCHES_GPIO_REG_H, SWITCHES_GPIO_PIN_H)
|
||||
#elif defined(PCBSKY9X)
|
||||
SWITCH_CASE(0, PIOC->PIO_PDSR, 1<<20)
|
||||
SWITCH_CASE(1, PIOA->PIO_PDSR, 1<<15)
|
||||
|
@ -796,6 +797,7 @@ FRESULT f_open (FIL * fil, const TCHAR *name, BYTE flag)
|
|||
return FR_INVALID_NAME;
|
||||
}
|
||||
fil->fsize = tmp.st_size;
|
||||
fil->fptr = 0;
|
||||
}
|
||||
fil->fs = (FATFS*)fopen(realPath, (flag & FA_WRITE) ? "wb+" : "rb+");
|
||||
fil->fptr = 0;
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
#ifndef simpgmspace_h
|
||||
#define simpgmspace_h
|
||||
|
||||
extern int g_snapshot_idx;
|
||||
|
||||
#ifndef __GNUC__
|
||||
#include <windows.h>
|
||||
#define sleep(x) Sleep(x)
|
||||
|
@ -188,7 +190,7 @@ extern Pwm pwm;
|
|||
|
||||
extern sem_t *eeprom_write_sem;
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if !defined(EEPROM_RLC)
|
||||
extern uint32_t eeprom_pointer;
|
||||
extern uint8_t * eeprom_buffer_data;
|
||||
extern volatile int32_t eeprom_buffer_size;
|
||||
|
@ -419,20 +421,35 @@ extern OS_MutexID audioMutex;
|
|||
#define CoTickDelay(...)
|
||||
#define CoCreateFlag(...) 0
|
||||
#define CoGetOSTime(...) 0
|
||||
inline void UART3_Configure(uint32_t baudrate, uint32_t masterClock) { }
|
||||
#define UART_Stop(...)
|
||||
#define UART3_Stop(...)
|
||||
#define USART_GetITStatus(...) 0
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
#if defined(CPUSTM32)
|
||||
inline void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct) { }
|
||||
#define GPIO_SetBits(GPIOx, pin) GPIOx->BSRRL |= pin
|
||||
#define GPIO_ResetBits(GPIOx, pin) GPIOx->BSRRL &= ~pin
|
||||
#define GPIO_ReadInputDataBit(GPIOx, pin) (GPIOx->BSRRL & pin)
|
||||
#define RCC_AHB1PeriphClockCmd(...)
|
||||
#define RCC_APB2PeriphClockCmd(...)
|
||||
inline void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct) { }
|
||||
inline void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState) { }
|
||||
inline void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState) { }
|
||||
inline FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG) { return RESET; }
|
||||
inline uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx) { return 0; }
|
||||
inline void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data) { }
|
||||
inline void DMA_DeInit(DMA_Stream_TypeDef* DMAy_Streamx) { }
|
||||
inline void DMA_Init(DMA_Stream_TypeDef* DMAy_Streamx, DMA_InitTypeDef* DMA_InitStruct) { }
|
||||
inline void DMA_ITConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState) { }
|
||||
inline void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct) { }
|
||||
inline void DMA_Cmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState) { }
|
||||
inline FlagStatus DMA_GetFlagStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG) { return RESET; }
|
||||
inline void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState) { }
|
||||
inline void UART3_Configure(uint32_t baudrate, uint32_t masterClock) { }
|
||||
inline void NVIC_Init(NVIC_InitTypeDef *) { }
|
||||
#endif
|
||||
|
||||
inline void delay_01us(int dummy) { }
|
||||
#define configure_pins(...)
|
||||
|
||||
#if defined(SDCARD)
|
||||
|
|
|
@ -48,80 +48,80 @@ extern uint16_t ResetReason;
|
|||
#define FIRMWARE_ADDRESS 0x00400000
|
||||
|
||||
#if defined(REVA)
|
||||
#define GPIO_BUTTON_MENU PIOB->PIO_PDSR
|
||||
#define GPIO_BUTTON_EXIT PIOA->PIO_PDSR
|
||||
#define GPIO_BUTTON_UP PIOC->PIO_PDSR
|
||||
#define GPIO_BUTTON_DOWN PIOC->PIO_PDSR
|
||||
#define GPIO_BUTTON_RIGHT PIOC->PIO_PDSR
|
||||
#define GPIO_BUTTON_LEFT PIOC->PIO_PDSR
|
||||
#define PIN_BUTTON_MENU 0x00000040
|
||||
#define PIN_BUTTON_EXIT 0x80000000
|
||||
#define PIN_BUTTON_UP 0x00000004
|
||||
#define PIN_BUTTON_DOWN 0x00000008
|
||||
#define PIN_BUTTON_RIGHT 0x00000010
|
||||
#define PIN_BUTTON_LEFT 0x00000020
|
||||
#define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_EXIT PIOA->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_UP PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_DOWN PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_RIGHT PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_LEFT PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_PIN_MENU 0x00000040
|
||||
#define KEYS_GPIO_PIN_EXIT 0x80000000
|
||||
#define KEYS_GPIO_PIN_UP 0x00000004
|
||||
#define KEYS_GPIO_PIN_DOWN 0x00000008
|
||||
#define KEYS_GPIO_PIN_RIGHT 0x00000010
|
||||
#define KEYS_GPIO_PIN_LEFT 0x00000020
|
||||
#else
|
||||
#define GPIO_BUTTON_MENU PIOB->PIO_PDSR
|
||||
#define GPIO_BUTTON_EXIT PIOC->PIO_PDSR
|
||||
#define GPIO_BUTTON_UP PIOC->PIO_PDSR
|
||||
#define GPIO_BUTTON_DOWN PIOC->PIO_PDSR
|
||||
#define GPIO_BUTTON_RIGHT PIOC->PIO_PDSR
|
||||
#define GPIO_BUTTON_LEFT PIOC->PIO_PDSR
|
||||
#define PIN_BUTTON_MENU 0x00000020
|
||||
#define PIN_BUTTON_EXIT 0x01000000
|
||||
#define PIN_BUTTON_UP 0x00000002
|
||||
#define PIN_BUTTON_DOWN 0x00000020
|
||||
#define PIN_BUTTON_RIGHT 0x00000010
|
||||
#define PIN_BUTTON_LEFT 0x00000008
|
||||
#define KEYS_GPIO_REG_MENU PIOB->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_EXIT PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_UP PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_DOWN PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_RIGHT PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_REG_LEFT PIOC->PIO_PDSR
|
||||
#define KEYS_GPIO_PIN_MENU 0x00000020
|
||||
#define KEYS_GPIO_PIN_EXIT 0x01000000
|
||||
#define KEYS_GPIO_PIN_UP 0x00000002
|
||||
#define KEYS_GPIO_PIN_DOWN 0x00000020
|
||||
#define KEYS_GPIO_PIN_RIGHT 0x00000010
|
||||
#define KEYS_GPIO_PIN_LEFT 0x00000008
|
||||
#endif
|
||||
|
||||
#if defined(REVX)
|
||||
#define GPIO_TRIM_LH_L PIOB->PIO_PDSR
|
||||
#define GPIO_TRIM_LV_DN PIOA->PIO_PDSR
|
||||
#define GPIO_TRIM_RV_UP PIOC->PIO_PDSR
|
||||
#define GPIO_TRIM_RH_L PIOA->PIO_PDSR
|
||||
#define GPIO_TRIM_LH_R PIOA->PIO_PDSR
|
||||
#define GPIO_TRIM_LV_UP PIOC->PIO_PDSR
|
||||
#define GPIO_TRIM_RV_DN PIOA->PIO_PDSR
|
||||
#define GPIO_TRIM_RH_R PIOC->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_LHL PIOB->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_LVD PIOA->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_RVU PIOC->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_RHL PIOA->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_LHR PIOA->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_LVU PIOC->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_RVD PIOA->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_RHR PIOC->PIO_PDSR
|
||||
#else
|
||||
#define GPIO_TRIM_LH_L PIOA->PIO_PDSR
|
||||
#define GPIO_TRIM_LV_DN PIOA->PIO_PDSR
|
||||
#define GPIO_TRIM_RV_UP PIOA->PIO_PDSR
|
||||
#define GPIO_TRIM_RH_L PIOA->PIO_PDSR
|
||||
#define GPIO_TRIM_LH_R PIOB->PIO_PDSR
|
||||
#define GPIO_TRIM_LV_UP PIOC->PIO_PDSR
|
||||
#define GPIO_TRIM_RV_DN PIOC->PIO_PDSR
|
||||
#define GPIO_TRIM_RH_R PIOC->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_LHL PIOA->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_LVD PIOA->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_RVU PIOA->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_RHL PIOA->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_LHR PIOB->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_LVU PIOC->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_RVD PIOC->PIO_PDSR
|
||||
#define TRIMS_GPIO_REG_RHR PIOC->PIO_PDSR
|
||||
#endif
|
||||
|
||||
#if defined(REVX)
|
||||
#define PIN_TRIM_LH_L 0x00000010
|
||||
#define PIN_TRIM_LV_DN 0x01000000
|
||||
#define PIN_TRIM_RV_UP 0x00000400
|
||||
#define PIN_TRIM_RH_L 0x00000001
|
||||
#define PIN_TRIM_LH_R 0x00800000
|
||||
#define PIN_TRIM_LV_UP 0x10000000
|
||||
#define PIN_TRIM_RV_DN 0x00000002
|
||||
#define PIN_TRIM_RH_R 0x00000200
|
||||
#define TRIMS_GPIO_PIN_LHL 0x00000010
|
||||
#define TRIMS_GPIO_PIN_LVD 0x01000000
|
||||
#define TRIMS_GPIO_PIN_RVU 0x00000400
|
||||
#define TRIMS_GPIO_PIN_RHL 0x00000001
|
||||
#define TRIMS_GPIO_PIN_LHR 0x00800000
|
||||
#define TRIMS_GPIO_PIN_LVU 0x10000000
|
||||
#define TRIMS_GPIO_PIN_RVD 0x00000002
|
||||
#define TRIMS_GPIO_PIN_RHR 0x00000200
|
||||
#elif defined(REVA)
|
||||
#define PIN_TRIM_LH_L 0x00000080
|
||||
#define PIN_TRIM_LV_DN 0x08000000
|
||||
#define PIN_TRIM_RV_UP 0x40000000
|
||||
#define PIN_TRIM_RH_L 0x20000000
|
||||
#define PIN_TRIM_LH_R 0x00000010
|
||||
#define PIN_TRIM_LV_UP 0x10000000
|
||||
#define PIN_TRIM_RV_DN 0x00000400
|
||||
#define PIN_TRIM_RH_R 0x00000200
|
||||
#define TRIMS_GPIO_PIN_LHL 0x00000080
|
||||
#define TRIMS_GPIO_PIN_LVD 0x08000000
|
||||
#define TRIMS_GPIO_PIN_RVU 0x40000000
|
||||
#define TRIMS_GPIO_PIN_RHL 0x20000000
|
||||
#define TRIMS_GPIO_PIN_LHR 0x00000010
|
||||
#define TRIMS_GPIO_PIN_LVU 0x10000000
|
||||
#define TRIMS_GPIO_PIN_RVD 0x00000400
|
||||
#define TRIMS_GPIO_PIN_RHR 0x00000200
|
||||
#else
|
||||
#define PIN_TRIM_LH_L 0x00800000
|
||||
#define PIN_TRIM_LV_DN 0x01000000
|
||||
#define PIN_TRIM_RV_UP 0x00000002
|
||||
#define PIN_TRIM_RH_L 0x00000001
|
||||
#define PIN_TRIM_LH_R 0x00000010
|
||||
#define PIN_TRIM_LV_UP 0x10000000
|
||||
#define PIN_TRIM_RV_DN 0x00000400
|
||||
#define PIN_TRIM_RH_R 0x00000200
|
||||
#define TRIMS_GPIO_PIN_LHL 0x00800000
|
||||
#define TRIMS_GPIO_PIN_LVD 0x01000000
|
||||
#define TRIMS_GPIO_PIN_RVU 0x00000002
|
||||
#define TRIMS_GPIO_PIN_RHL 0x00000001
|
||||
#define TRIMS_GPIO_PIN_LHR 0x00000010
|
||||
#define TRIMS_GPIO_PIN_LVU 0x10000000
|
||||
#define TRIMS_GPIO_PIN_RVD 0x00000400
|
||||
#define TRIMS_GPIO_PIN_RHR 0x00000200
|
||||
#endif
|
||||
|
||||
void usbMassStorage();
|
||||
|
@ -187,7 +187,7 @@ void writeFlash(uint32_t * address, uint32_t * buffer);
|
|||
extern uint32_t readKeys();
|
||||
extern uint32_t readTrims();
|
||||
#define TRIMS_PRESSED() (readTrims())
|
||||
#define KEYS_PRESSED() (~readKeys())
|
||||
#define KEYS_PRESSED() (readKeys())
|
||||
#define DBLKEYS_PRESSED_RGT_LFT(i) ((in & (0x20 + 0x40)) == (0x20 + 0x40))
|
||||
#define DBLKEYS_PRESSED_UP_DWN(i) ((in & (0x10 + 0x08)) == (0x10 + 0x08))
|
||||
#define DBLKEYS_PRESSED_RGT_UP(i) ((in & (0x20 + 0x10)) == (0x20 + 0x10))
|
||||
|
|
|
@ -52,32 +52,33 @@ uint32_t readKeys()
|
|||
register uint32_t result = 0;
|
||||
|
||||
x = lcdLock ? lcdInputs : PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
|
||||
x = ~x;
|
||||
|
||||
#if defined(REVA)
|
||||
if (x & PIN_BUTTON_RIGHT)
|
||||
if (x & KEYS_GPIO_PIN_RIGHT)
|
||||
result |= 0x02 << KEY_RIGHT;
|
||||
if (x & PIN_BUTTON_LEFT)
|
||||
if (x & KEYS_GPIO_PIN_LEFT)
|
||||
result |= 0x02 << KEY_LEFT;
|
||||
if (x & PIN_BUTTON_UP)
|
||||
if (x & KEYS_GPIO_PIN_UP)
|
||||
result |= 0x02 << KEY_UP;
|
||||
if (x & PIN_BUTTON_DOWN)
|
||||
if (x & KEYS_GPIO_PIN_DOWN)
|
||||
result |= 0x02 << KEY_DOWN;
|
||||
if (GPIO_BUTTON_EXIT & PIN_BUTTON_EXIT)
|
||||
if (KEYS_GPIO_REG_EXIT & KEYS_GPIO_PIN_EXIT)
|
||||
result |= 0x02 << KEY_EXIT;
|
||||
if (GPIO_BUTTON_MENU & 0x000000040)
|
||||
if (KEYS_GPIO_REG_MENU & 0x000000040)
|
||||
result |= 0x02 << KEY_MENU;
|
||||
#else
|
||||
if (x & PIN_BUTTON_RIGHT)
|
||||
if (x & KEYS_GPIO_PIN_RIGHT)
|
||||
result |= 0x02 << KEY_RIGHT;
|
||||
if (x & PIN_BUTTON_UP)
|
||||
if (x & KEYS_GPIO_PIN_UP)
|
||||
result |= 0x02 << KEY_UP;
|
||||
if (x & PIN_BUTTON_LEFT)
|
||||
if (x & KEYS_GPIO_PIN_LEFT)
|
||||
result |= 0x02 << KEY_LEFT;
|
||||
if (x & PIN_BUTTON_DOWN)
|
||||
if (x & KEYS_GPIO_PIN_DOWN)
|
||||
result |= 0x02 << KEY_DOWN;
|
||||
if (x & PIN_BUTTON_EXIT)
|
||||
if (x & KEYS_GPIO_PIN_EXIT)
|
||||
result |= 0x02 << KEY_EXIT;
|
||||
if (GPIO_BUTTON_MENU & PIN_BUTTON_MENU)
|
||||
if (KEYS_GPIO_REG_MENU & KEYS_GPIO_PIN_MENU)
|
||||
result |= 0x02 << KEY_MENU;
|
||||
#endif
|
||||
|
||||
|
@ -90,21 +91,21 @@ uint32_t readTrims()
|
|||
{
|
||||
register uint32_t result = 0;
|
||||
|
||||
if (~GPIO_TRIM_LH_L & PIN_TRIM_LH_L)
|
||||
if (~TRIMS_GPIO_REG_LHL & TRIMS_GPIO_PIN_LHL)
|
||||
result |= 0x01;
|
||||
if (~GPIO_TRIM_LV_DN & PIN_TRIM_LV_DN)
|
||||
if (~TRIMS_GPIO_REG_LVD & TRIMS_GPIO_PIN_LVD)
|
||||
result |= 0x04;
|
||||
if (~GPIO_TRIM_RV_UP & PIN_TRIM_RV_UP)
|
||||
if (~TRIMS_GPIO_REG_RVU & TRIMS_GPIO_PIN_RVU)
|
||||
result |= 0x20;
|
||||
if (~GPIO_TRIM_RH_L & PIN_TRIM_RH_L)
|
||||
if (~TRIMS_GPIO_REG_RHL & TRIMS_GPIO_PIN_RHL)
|
||||
result |= 0x40;
|
||||
if (~GPIO_TRIM_LH_R & PIN_TRIM_LH_R)
|
||||
if (~TRIMS_GPIO_REG_LHR & TRIMS_GPIO_PIN_LHR)
|
||||
result |= 0x02;
|
||||
if (~GPIO_TRIM_LV_UP & PIN_TRIM_LV_UP)
|
||||
if (~TRIMS_GPIO_REG_LVU & TRIMS_GPIO_PIN_LVU)
|
||||
result |= 0x08;
|
||||
if (~GPIO_TRIM_RV_DN & PIN_TRIM_RV_DN)
|
||||
if (~TRIMS_GPIO_REG_RVD & TRIMS_GPIO_PIN_RVD)
|
||||
result |= 0x10;
|
||||
if (~GPIO_TRIM_RH_R & PIN_TRIM_RH_R)
|
||||
if (~TRIMS_GPIO_REG_RHR & TRIMS_GPIO_PIN_RHR)
|
||||
result |= 0x80;
|
||||
|
||||
return result;
|
||||
|
@ -117,7 +118,7 @@ uint8_t trimDown(uint8_t idx)
|
|||
|
||||
uint8_t keyDown()
|
||||
{
|
||||
return (~readKeys() & 0x7E) || REA_DOWN();
|
||||
return readKeys() || REA_DOWN();
|
||||
}
|
||||
|
||||
void readKeysAndTrims()
|
||||
|
|
|
@ -39,35 +39,35 @@
|
|||
|
||||
#include "../common_avr/board_avr.h"
|
||||
|
||||
#define GPIO_BUTTON_MENU pinb
|
||||
#define GPIO_BUTTON_EXIT pinb
|
||||
#define GPIO_BUTTON_RIGHT pinb
|
||||
#define GPIO_BUTTON_LEFT pinb
|
||||
#define GPIO_BUTTON_UP pinb
|
||||
#define GPIO_BUTTON_DOWN pinb
|
||||
#define PIN_BUTTON_MENU (1<<INP_B_KEY_MEN)
|
||||
#define PIN_BUTTON_EXIT (1<<INP_B_KEY_EXT)
|
||||
#define PIN_BUTTON_UP (1<<INP_B_KEY_UP)
|
||||
#define PIN_BUTTON_DOWN (1<<INP_B_KEY_DWN)
|
||||
#define PIN_BUTTON_RIGHT (1<<INP_B_KEY_RGT)
|
||||
#define PIN_BUTTON_LEFT (1<<INP_B_KEY_LFT)
|
||||
#define KEYS_GPIO_REG_MENU pinb
|
||||
#define KEYS_GPIO_REG_EXIT pinb
|
||||
#define KEYS_GPIO_REG_RIGHT pinb
|
||||
#define KEYS_GPIO_REG_LEFT pinb
|
||||
#define KEYS_GPIO_REG_UP pinb
|
||||
#define KEYS_GPIO_REG_DOWN pinb
|
||||
#define KEYS_GPIO_PIN_MENU (1<<INP_B_KEY_MEN)
|
||||
#define KEYS_GPIO_PIN_EXIT (1<<INP_B_KEY_EXT)
|
||||
#define KEYS_GPIO_PIN_UP (1<<INP_B_KEY_UP)
|
||||
#define KEYS_GPIO_PIN_DOWN (1<<INP_B_KEY_DWN)
|
||||
#define KEYS_GPIO_PIN_RIGHT (1<<INP_B_KEY_RGT)
|
||||
#define KEYS_GPIO_PIN_LEFT (1<<INP_B_KEY_LFT)
|
||||
|
||||
#define GPIO_TRIM_LH_L pind
|
||||
#define GPIO_TRIM_LV_DN pind
|
||||
#define GPIO_TRIM_RV_UP pind
|
||||
#define GPIO_TRIM_RH_L pind
|
||||
#define GPIO_TRIM_LH_R pind
|
||||
#define GPIO_TRIM_LV_UP pind
|
||||
#define GPIO_TRIM_RV_DN pind
|
||||
#define GPIO_TRIM_RH_R pind
|
||||
#define PIN_TRIM_LH_L (1<<INP_D_TRM_LH_DWN)
|
||||
#define PIN_TRIM_LV_DN (1<<INP_D_TRM_LV_DWN)
|
||||
#define PIN_TRIM_RV_UP (1<<INP_D_TRM_RV_UP)
|
||||
#define PIN_TRIM_RH_L (1<<INP_D_TRM_RH_DWN)
|
||||
#define PIN_TRIM_LH_R (1<<INP_D_TRM_LH_UP)
|
||||
#define PIN_TRIM_LV_UP (1<<INP_D_TRM_LV_UP)
|
||||
#define PIN_TRIM_RV_DN (1<<INP_D_TRM_RV_DWN)
|
||||
#define PIN_TRIM_RH_R (1<<INP_D_TRM_RH_UP)
|
||||
#define TRIMS_GPIO_REG_LHL pind
|
||||
#define TRIMS_GPIO_REG_LVD pind
|
||||
#define TRIMS_GPIO_REG_RVU pind
|
||||
#define TRIMS_GPIO_REG_RHL pind
|
||||
#define TRIMS_GPIO_REG_LHR pind
|
||||
#define TRIMS_GPIO_REG_LVU pind
|
||||
#define TRIMS_GPIO_REG_RVD pind
|
||||
#define TRIMS_GPIO_REG_RHR pind
|
||||
#define TRIMS_GPIO_PIN_LHL (1<<INP_D_TRM_LH_DWN)
|
||||
#define TRIMS_GPIO_PIN_LVD (1<<INP_D_TRM_LV_DWN)
|
||||
#define TRIMS_GPIO_PIN_RVU (1<<INP_D_TRM_RV_UP)
|
||||
#define TRIMS_GPIO_PIN_RHL (1<<INP_D_TRM_RH_DWN)
|
||||
#define TRIMS_GPIO_PIN_LHR (1<<INP_D_TRM_LH_UP)
|
||||
#define TRIMS_GPIO_PIN_LVU (1<<INP_D_TRM_LV_UP)
|
||||
#define TRIMS_GPIO_PIN_RVD (1<<INP_D_TRM_RV_DWN)
|
||||
#define TRIMS_GPIO_PIN_RHR (1<<INP_D_TRM_RH_UP)
|
||||
|
||||
#if defined(CPUM2561)
|
||||
#define TIMER_16KHZ_VECT TIMER2_OVF_vect
|
||||
|
|
|
@ -41,10 +41,10 @@
|
|||
#define PIN_PORTB 0x0100
|
||||
#define PIN_PORTC 0x0200
|
||||
|
||||
#define STICK_LV 3
|
||||
#define STICK_LH 2
|
||||
#define STICK_RV 0
|
||||
#define STICK_RH 1
|
||||
#define STICK_LH 2
|
||||
#define STICK_LV 3
|
||||
#define POT_L 6
|
||||
#define POT_R 8
|
||||
#define POT_XTRA 9
|
||||
|
@ -53,16 +53,14 @@
|
|||
#define BATTERY 10
|
||||
|
||||
#if defined(REV9E)
|
||||
#define SLIDER_L2 8 // PIN_FLP_J3 (SLIDER3) = ANC3_IN8
|
||||
#define SLIDER_R2 7 // PIN_FLP_J4 (SLIDER4) = ADC3_IN7
|
||||
#define POT_4 6 // PIN_FLP_J5 (POT4) = ADC3_IN6
|
||||
#define SLIDER_L2 8 // ADC_GPIO_PIN_POT3 (SLIDER3) = ANC3_IN8
|
||||
#define SLIDER_R2 7 // ADC_GPIO_PIN_POT4 (SLIDER4) = ADC3_IN7
|
||||
#define POT_4 6 // ADC_GPIO_PIN_POT5 (POT4) = ADC3_IN6
|
||||
#endif
|
||||
|
||||
// Sample time should exceed 1uS
|
||||
#define SAMPTIME 2 // sample time = 28 cycles
|
||||
|
||||
uint16_t Analog_values[NUMBER_ANALOG];
|
||||
|
||||
#if defined(REV9E)
|
||||
const int8_t ana_direction[NUMBER_ANALOG] = {1,-1,1,-1, -1,1,-1, -1,1, 1, -1,-1,1};
|
||||
#elif defined(REVPLUS)
|
||||
|
@ -83,32 +81,28 @@ uint16_t Analog_values[NUMBER_ANALOG];
|
|||
9 /*TX_VOLTAGE*/ };
|
||||
#else
|
||||
#define NUMBER_ANALOG_ADC1 10
|
||||
#define NUMBER_ANALOG_ADC3 0
|
||||
// mapping from Analog_values order to enum Analogs
|
||||
const uint8_t ana_mapping[NUMBER_ANALOG] = { 0 /*STICK1*/, 1 /*STICK2*/, 2 /*STICK3*/, 3 /*STICK4*/,
|
||||
4 /*POT1*/, 5 /*POT2*/, 6 /*POT3*/,
|
||||
7 /*SLIDER1*/, 8 /*SLIDER2*/,
|
||||
9 /*TX_VOLTAGE*/ };
|
||||
#endif
|
||||
|
||||
uint16_t Analog_values[NUMBER_ANALOG];
|
||||
|
||||
void adcInit()
|
||||
{
|
||||
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN; // Enable clock
|
||||
RCC->AHB1ENR |= RCC_AHB1Periph_GPIOADC; // Enable ports A&C clocks
|
||||
RCC->AHB1ENR |= ADC_AHB1Periph_GPIO; // Enable ports A&C clocks
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN; // Enable DMA2 clock
|
||||
|
||||
configure_pins(PIN_STK_J1 | PIN_STK_J2 | PIN_STK_J3 | PIN_STK_J4 |
|
||||
PIN_FLP_J1, PIN_ANALOG | PIN_PORTA);
|
||||
configure_pins(ADC_GPIO_PIN_STICK_RV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV |
|
||||
ADC_GPIO_PIN_POT1, PIN_ANALOG | PIN_PORTA);
|
||||
|
||||
#if defined(REV9E)
|
||||
configure_pins(PIN_FLP_J2 | PIN_FLP_J6, PIN_ANALOG|PIN_PORTB);
|
||||
configure_pins(ADC_GPIO_PIN_POT2 | ADC_GPIO_PIN_POT6, PIN_ANALOG|PIN_PORTB);
|
||||
#elif defined(REVPLUS)
|
||||
configure_pins(PIN_FLP_J2 | PIN_FLP_J3, PIN_ANALOG|PIN_PORTB);
|
||||
configure_pins(ADC_GPIO_PIN_POT2 | ADC_GPIO_PIN_POT3, PIN_ANALOG|PIN_PORTB);
|
||||
#else
|
||||
configure_pins(PIN_FLP_J2, PIN_ANALOG|PIN_PORTB);
|
||||
configure_pins(ADC_GPIO_PIN_POT2, PIN_ANALOG|PIN_PORTB);
|
||||
#endif
|
||||
|
||||
configure_pins(PIN_SLD_J1 | PIN_SLD_J2 | PIN_MVOLT, PIN_ANALOG | PIN_PORTC);
|
||||
configure_pins(ADC_GPIO_PIN_SLIDER1 | ADC_GPIO_PIN_SLIDER2 | ADC_GPIO_PIN_BATT, PIN_ANALOG | PIN_PORTC);
|
||||
|
||||
ADC1->CR1 = ADC_CR1_SCAN;
|
||||
ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS;
|
||||
|
@ -128,7 +122,7 @@ void adcInit()
|
|||
|
||||
#if defined(REV9E)
|
||||
RCC->APB2ENR |= RCC_APB2ENR_ADC3EN ; // Enable clock
|
||||
configure_pins( PIN_FLP_J3 | PIN_FLP_J4 | PIN_FLP_J5, PIN_ANALOG | PIN_PORTF ) ;
|
||||
configure_pins( ADC_GPIO_PIN_POT3 | ADC_GPIO_PIN_POT4 | ADC_GPIO_PIN_POT5, PIN_ANALOG | PIN_PORTF ) ;
|
||||
|
||||
ADC3->CR1 = ADC_CR1_SCAN ;
|
||||
ADC3->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS ;
|
||||
|
@ -144,7 +138,7 @@ void adcInit()
|
|||
DMA2_Stream1->M0AR = CONVERT_PTR_UINT(Analog_values + NUMBER_ANALOG_ADC1);
|
||||
DMA2_Stream1->NDTR = NUMBER_ANALOG_ADC3;
|
||||
DMA2_Stream1->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
||||
#endif // #if defined(REV9E)
|
||||
#endif
|
||||
}
|
||||
|
||||
void adcRead()
|
||||
|
@ -179,18 +173,6 @@ void adcRead()
|
|||
}
|
||||
DMA2_Stream0->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
#endif
|
||||
|
||||
// adc direction correct
|
||||
for (uint32_t i=0; i<NUMBER_ANALOG; i++) {
|
||||
if (ana_direction[i] < 0) {
|
||||
Analog_values[i] = 4096-Analog_values[i];
|
||||
}
|
||||
#if !defined(REVPLUS)
|
||||
else if (ana_direction[i] == 0) {
|
||||
Analog_values[i] = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
@ -198,7 +180,13 @@ void adcStop()
|
|||
{
|
||||
}
|
||||
|
||||
uint16_t getAnalogValue(uint32_t value)
|
||||
uint16_t getAnalogValue(uint32_t index)
|
||||
{
|
||||
return Analog_values[ana_mapping[value]];
|
||||
#if defined(REV9E)
|
||||
index = ana_mapping[index];
|
||||
#endif
|
||||
if (ana_direction[index] < 0)
|
||||
return 4096 - Analog_values[index];
|
||||
else
|
||||
return Analog_values[index];
|
||||
}
|
||||
|
|
|
@ -17,20 +17,20 @@ extern "C" {
|
|||
|
||||
#define __no_operation __NOP
|
||||
|
||||
#define LCD_NCS_HIGH() GPIO_LCD_NCS->BSRRL = PIN_LCD_NCS
|
||||
#define LCD_NCS_LOW() GPIO_LCD_NCS->BSRRH = PIN_LCD_NCS
|
||||
#define LCD_NCS_HIGH() LCD_GPIO_NCS->BSRRL = LCD_GPIO_PIN_NCS
|
||||
#define LCD_NCS_LOW() LCD_GPIO_NCS->BSRRH = LCD_GPIO_PIN_NCS
|
||||
|
||||
#define LCD_A0_HIGH() GPIO_LCD_SPI->BSRRL = PIN_LCD_A0
|
||||
#define LCD_A0_LOW() GPIO_LCD_SPI->BSRRH = PIN_LCD_A0
|
||||
#define LCD_A0_HIGH() LCD_GPIO_SPI->BSRRL = LCD_GPIO_PIN_A0
|
||||
#define LCD_A0_LOW() LCD_GPIO_SPI->BSRRH = LCD_GPIO_PIN_A0
|
||||
|
||||
#define LCD_RST_HIGH() GPIO_LCD_RST->BSRRL = PIN_LCD_RST
|
||||
#define LCD_RST_LOW() GPIO_LCD_RST->BSRRH = PIN_LCD_RST
|
||||
#define LCD_RST_HIGH() LCD_GPIO_RST->BSRRL = LCD_GPIO_PIN_RST
|
||||
#define LCD_RST_LOW() LCD_GPIO_RST->BSRRH = LCD_GPIO_PIN_RST
|
||||
|
||||
#define LCD_CLK_HIGH() GPIO_LCD_SPI->BSRRL = PIN_LCD_CLK
|
||||
#define LCD_CLK_LOW() GPIO_LCD_SPI->BSRRH = PIN_LCD_CLK
|
||||
#define LCD_CLK_HIGH() LCD_GPIO_SPI->BSRRL = LCD_GPIO_PIN_CLK
|
||||
#define LCD_CLK_LOW() LCD_GPIO_SPI->BSRRH = LCD_GPIO_PIN_CLK
|
||||
|
||||
#define LCD_MOSI_HIGH() GPIO_LCD_SPI->BSRRL = PIN_LCD_MOSI
|
||||
#define LCD_MOSI_LOW() GPIO_LCD_SPI->BSRRH = PIN_LCD_MOSI
|
||||
#define LCD_MOSI_HIGH() LCD_GPIO_SPI->BSRRL = LCD_GPIO_PIN_MOSI
|
||||
#define LCD_MOSI_LOW() LCD_GPIO_SPI->BSRRH = LCD_GPIO_PIN_MOSI
|
||||
|
||||
void AspiCmd(u8 Command_Byte);
|
||||
void AspiData(u8 Para_data);
|
||||
|
|
|
@ -76,7 +76,7 @@ void dacInit()
|
|||
dacTimerInit();
|
||||
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN ; // Enable portA clock
|
||||
configure_pins( 0x0010, PIN_ANALOG | PIN_PORTA ) ;
|
||||
configure_pins( GPIO_Pin_4, PIN_ANALOG | PIN_PORTA ) ;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_DACEN ; // Enable clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_DMA1EN ; // Enable DMA1 clock
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ void configure_pins( uint32_t pins, uint16_t config );
|
|||
extern uint16_t sessionTimer;
|
||||
|
||||
#define SLAVE_MODE() (g_model.trainerMode == TRAINER_MODE_SLAVE)
|
||||
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(GPIOTRNDET, PIN_TRNDET) == Bit_RESET)
|
||||
#define TRAINER_CONNECTED() (GPIO_ReadInputDataBit(TRAINER_GPIO_DETECT, TRAINER_GPIO_PIN_DETECT) == Bit_RESET)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -184,12 +184,12 @@ uint32_t isFirmwareStart(const void * buffer);
|
|||
uint32_t isBootloaderStart(const void * buffer);
|
||||
|
||||
// Pulses driver
|
||||
#define INTERNAL_MODULE_ON() GPIO_SetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR)
|
||||
#define INTERNAL_MODULE_OFF() GPIO_ResetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR)
|
||||
#define EXTERNAL_MODULE_ON() GPIO_SetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR)
|
||||
#define EXTERNAL_MODULE_OFF() GPIO_ResetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR)
|
||||
#define IS_INTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(GPIO_INT_RF_PWR, PIN_INT_RF_PWR) == Bit_SET)
|
||||
#define IS_EXTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR) == Bit_SET)
|
||||
#define INTERNAL_MODULE_ON() GPIO_SetBits(INTMODULE_GPIO_PWR, INTMODULE_GPIO_PIN_PWR)
|
||||
#define INTERNAL_MODULE_OFF() GPIO_ResetBits(INTMODULE_GPIO_PWR, INTMODULE_GPIO_PIN_PWR)
|
||||
#define EXTERNAL_MODULE_ON() GPIO_SetBits(EXTMODULE_GPIO_PWR, EXTMODULE_GPIO_PIN_PWR)
|
||||
#define EXTERNAL_MODULE_OFF() GPIO_ResetBits(EXTMODULE_GPIO_PWR, EXTMODULE_GPIO_PIN_PWR)
|
||||
#define IS_INTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(INTMODULE_GPIO_PWR, INTMODULE_GPIO_PIN_PWR) == Bit_SET)
|
||||
#define IS_EXTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(EXTMODULE_GPIO_PWR, EXTMODULE_GPIO_PIN_PWR) == Bit_SET)
|
||||
void init_no_pulses(uint32_t port);
|
||||
void disable_no_pulses(uint32_t port);
|
||||
void init_ppm( uint32_t module_index );
|
||||
|
@ -219,7 +219,7 @@ void keysInit(void);
|
|||
uint32_t readKeys(void);
|
||||
uint32_t readTrims(void);
|
||||
#define TRIMS_PRESSED() (readTrims())
|
||||
#define KEYS_PRESSED() (~readKeys())
|
||||
#define KEYS_PRESSED() (readKeys())
|
||||
#define DBLKEYS_PRESSED_RGT_LFT(i) ((in & ((2<<KEY_PLUS) + (2<<KEY_MINUS))) == ((2<<KEY_PLUS) + (2<<KEY_MINUS)))
|
||||
#define DBLKEYS_PRESSED_UP_DWN(i) ((in & ((2<<KEY_MENU) + (2<<KEY_PAGE))) == ((2<<KEY_MENU) + (2<<KEY_PAGE)))
|
||||
#define DBLKEYS_PRESSED_RGT_UP(i) ((in & ((2<<KEY_ENTER) + (2<<KEY_MINUS))) == ((2<<KEY_ENTER) + (2<<KEY_MINUS)))
|
||||
|
@ -270,7 +270,7 @@ void turnBacklightOff(void);
|
|||
#define setBacklight(xx) turnBacklightOn(xx, g_eeGeneral.backlightColor)
|
||||
#define __BACKLIGHT_ON turnBacklightOn(g_eeGeneral.backlightBright, g_eeGeneral.backlightColor)
|
||||
#define __BACKLIGHT_OFF turnBacklightOff()
|
||||
#define IS_BACKLIGHT_ON() (TIM_BL->CCR4 != 0) || (TIM_BL->CCR2 != 0)
|
||||
#define IS_BACKLIGHT_ON() (BACKLIGHT_TIMER->CCR4 != 0) || (BACKLIGHT_TIMER->CCR2 != 0)
|
||||
#else
|
||||
#define setBacklight(xx) TIM10->CCR1 = 100-xx
|
||||
#define __BACKLIGHT_ON TIM10->CCR1 = 100-g_eeGeneral.backlightBright
|
||||
|
@ -324,7 +324,7 @@ void hapticOff(void);
|
|||
#define HAPTIC_ON() hapticOn()
|
||||
#endif
|
||||
|
||||
// UART3 driver
|
||||
// SERIAL_USART driver
|
||||
#define DEBUG_BAUDRATE 115200
|
||||
void uart3Init(unsigned int mode, unsigned int protocol);
|
||||
void uart3Putc(const char c);
|
||||
|
|
|
@ -94,7 +94,7 @@ ifeq ($(PCB), TARANIS)
|
|||
LDSCRIPT = ../stm32_ramBoot.ld
|
||||
TRGT = arm-none-eabi-
|
||||
CPPDEFS += -DHSE_VALUE=12000000
|
||||
CPPDEFS += -DPCBTARANIS
|
||||
CPPDEFS += -DPCBTARANIS -DEEPROM_RLC
|
||||
FULL_PRJ = $(PROJECT)_ramBoot
|
||||
ifeq ($(PCBREV), REV9E)
|
||||
CPPDEFS += -DSTM32F40_41xxx
|
||||
|
|
|
@ -199,7 +199,7 @@ void interrupt10ms(void)
|
|||
Tenms |= 1; // 10 mS has passed
|
||||
|
||||
uint8_t enuk = KEY_MENU;
|
||||
uint8_t in = ~readKeys();
|
||||
uint8_t in = readKeys();
|
||||
|
||||
for (int i = 1; i < 7; i++) {
|
||||
uint8_t value = in & (1 << i);
|
||||
|
@ -806,7 +806,7 @@ int main()
|
|||
}
|
||||
|
||||
if (state == ST_REBOOT) {
|
||||
if ((~readKeys() & 0x7E) == 0) {
|
||||
if (readKeys() == 0) {
|
||||
lcd_clear();
|
||||
lcdRefresh();
|
||||
lcdRefreshWait();
|
||||
|
|
|
@ -243,7 +243,7 @@ void stm32_dma_transfer(
|
|||
)
|
||||
{
|
||||
DMA_InitTypeDef DMA_InitStructure;
|
||||
WORD rw_workbyte[] = { 0xffff };
|
||||
WORD dummy[] = { 0xffff };
|
||||
|
||||
DMA_DeInit(SD_DMA_Stream_SPI_RX);
|
||||
DMA_DeInit(SD_DMA_Stream_SPI_TX);
|
||||
|
@ -263,64 +263,42 @@ void stm32_dma_transfer(
|
|||
DMA_InitStructure.DMA_MemoryBurst =DMA_MemoryBurst_Single;
|
||||
DMA_InitStructure.DMA_PeripheralBurst =DMA_PeripheralBurst_Single;
|
||||
|
||||
//seperate RX & TX
|
||||
if ( receive ) { //true =read
|
||||
|
||||
/* DMA1 channel3 configuration SPI2 RX ---------------------------------------------*/
|
||||
// separate RX & TX
|
||||
if (receive) {
|
||||
DMA_InitStructure.DMA_Memory0BaseAddr = (DWORD)buff;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||
DMA_Init(SD_DMA_Stream_SPI_RX, &DMA_InitStructure);
|
||||
|
||||
/* DMA1 channel4 configuration SPI2 TX ---------------------------------------------*/
|
||||
DMA_InitStructure.DMA_Memory0BaseAddr = (DWORD)rw_workbyte;
|
||||
DMA_InitStructure.DMA_Memory0BaseAddr = (DWORD)dummy;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
|
||||
DMA_Init(SD_DMA_Stream_SPI_TX, &DMA_InitStructure);
|
||||
|
||||
}
|
||||
else {//false = write
|
||||
|
||||
#if _FS_READONLY == 0 //READ AND WRITE = write enabled.
|
||||
/* DMA1 channel2 configuration SPI1 RX ---------------------------------------------*/
|
||||
/* DMA1 channel4 configuration SPI2 RX ---------------------------------------------*/
|
||||
DMA_InitStructure.DMA_Memory0BaseAddr = (DWORD)rw_workbyte;
|
||||
else {
|
||||
#if _FS_READONLY == 0
|
||||
DMA_InitStructure.DMA_Memory0BaseAddr = (DWORD)dummy;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
|
||||
DMA_Init(SD_DMA_Stream_SPI_RX, &DMA_InitStructure);
|
||||
|
||||
/* DMA1 channel3 configuration SPI1 TX ---------------------------------------------*/
|
||||
/* DMA1 channel5 configuration SPI2 TX ---------------------------------------------*/
|
||||
DMA_InitStructure.DMA_Memory0BaseAddr = (DWORD)buff;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||
DMA_Init(SD_DMA_Stream_SPI_TX, &DMA_InitStructure);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* Enable DMA RX Channel */
|
||||
/* Enable DMA Channels */
|
||||
DMA_Cmd(SD_DMA_Stream_SPI_RX, ENABLE);
|
||||
/* Enable DMA TX Channel */
|
||||
DMA_Cmd(SD_DMA_Stream_SPI_TX, ENABLE);
|
||||
|
||||
/* Enable SPI TX/RX request */
|
||||
SPI_I2S_DMACmd(SD_SPI, SPI_I2S_DMAReq_Rx | SPI_I2S_DMAReq_Tx, ENABLE);
|
||||
|
||||
/* Wait until DMA1_Channel 3 Transfer Complete */
|
||||
|
||||
while (DMA_GetFlagStatus(SD_DMA_Stream_SPI_TX, SD_DMA_FLAG_SPI_TC_TX) == RESET) { ; }
|
||||
|
||||
/* Wait until DMA1_Channel 2 Receive Complete */
|
||||
|
||||
while (DMA_GetFlagStatus(SD_DMA_Stream_SPI_RX, SD_DMA_FLAG_SPI_TC_RX) == RESET) { ; }
|
||||
|
||||
// same w/o function-call:
|
||||
// while ( ( ( DMA1->ISR ) & SD_DMA_FLAG_SPI_TC_RX ) == RESET ) { ; }
|
||||
|
||||
/* Disable DMA RX Channel */
|
||||
/* Disable DMA Channels */
|
||||
DMA_Cmd(SD_DMA_Stream_SPI_RX, DISABLE);
|
||||
/* Disable DMA TX Channel */
|
||||
DMA_Cmd(SD_DMA_Stream_SPI_TX, DISABLE);
|
||||
|
||||
/* Disable SPI RX/TX request */
|
||||
|
@ -368,9 +346,7 @@ void power_on (void)
|
|||
|
||||
/* Configure SPI pins: SCK MISO and MOSI with alternate function push-down */
|
||||
GPIO_InitStructure.GPIO_Pin = SD_GPIO_PIN_SCK | SD_GPIO_PIN_MOSI|SD_GPIO_PIN_MISO;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(SD_GPIO, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(SD_GPIO,SD_GPIO_PinSource_SCK ,SD_GPIO_AF);
|
||||
|
@ -418,8 +394,7 @@ void power_off (void)
|
|||
RCC_APB1PeriphClockCmd(SD_RCC_APB1Periph_SPI, DISABLE);
|
||||
|
||||
//All SPI-Pins to input with weak internal pull-downs
|
||||
GPIO_InitStructure.GPIO_Pin = SD_GPIO_PIN_SCK | SD_GPIO_PIN_MISO
|
||||
| SD_GPIO_PIN_MOSI;
|
||||
GPIO_InitStructure.GPIO_Pin = SD_GPIO_PIN_SCK | SD_GPIO_PIN_MISO | SD_GPIO_PIN_MOSI;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
|
||||
|
|
|
@ -3,314 +3,321 @@
|
|||
|
||||
// Keys
|
||||
#if defined(REV9E)
|
||||
#define RCC_AHB1Periph_GPIOBUTTON (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOF|RCC_AHB1Periph_GPIOG)
|
||||
#define KEYS_RCC_AHB1Periph_GPIO (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOF|RCC_AHB1Periph_GPIOG)
|
||||
#else
|
||||
#define RCC_AHB1Periph_GPIOBUTTON (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE)
|
||||
#define KEYS_RCC_AHB1Periph_GPIO (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE)
|
||||
#endif
|
||||
|
||||
#define GPIO_BUTTON_PLUS GPIOE->IDR
|
||||
#define GPIO_BUTTON_MINUS GPIOE->IDR
|
||||
#define GPIO_BUTTON_MENU GPIOD->IDR
|
||||
#define GPIO_BUTTON_EXIT GPIOD->IDR
|
||||
#define GPIO_BUTTON_PAGE GPIOD->IDR
|
||||
#define KEYS_GPIO_REG_PLUS GPIOE->IDR
|
||||
#define KEYS_GPIO_REG_MINUS GPIOE->IDR
|
||||
#define KEYS_GPIO_REG_MENU GPIOD->IDR
|
||||
#define KEYS_GPIO_REG_EXIT GPIOD->IDR
|
||||
#define KEYS_GPIO_REG_PAGE GPIOD->IDR
|
||||
#if defined(REV9E)
|
||||
#if defined(SIMU)
|
||||
#define PIN_BUTTON_PLUS GPIO_Pin_5 // This is for SIMU: reuse rotary encoder pins to map UP and DOWN keyboard keys
|
||||
#define PIN_BUTTON_MINUS GPIO_Pin_6 // This is for SIMU: reuse rotary encoder pins to map UP and DOWN keyboard keys
|
||||
#define KEYS_GPIO_PIN_PLUS GPIO_Pin_5 // This is for SIMU: reuse rotary encoder pins to map UP and DOWN keyboard keys
|
||||
#define KEYS_GPIO_PIN_MINUS GPIO_Pin_6 // This is for SIMU: reuse rotary encoder pins to map UP and DOWN keyboard keys
|
||||
#endif
|
||||
#define GPIO_BUTTON_ENTER GPIOF->IDR
|
||||
#define PIN_BUTTON_ENTER GPIO_Pin_0 // PF.00
|
||||
#define KEYS_GPIO_REG_ENTER GPIOF->IDR
|
||||
#define KEYS_GPIO_PIN_ENTER GPIO_Pin_0 // PF.00
|
||||
#else
|
||||
#define PIN_BUTTON_PLUS GPIO_Pin_10 // PE.10
|
||||
#define PIN_BUTTON_MINUS GPIO_Pin_11 // PE.11
|
||||
#define GPIO_BUTTON_ENTER GPIOE->IDR
|
||||
#define PIN_BUTTON_ENTER GPIO_Pin_12 // PE.12
|
||||
#define KEYS_GPIO_PIN_PLUS GPIO_Pin_10 // PE.10
|
||||
#define KEYS_GPIO_PIN_MINUS GPIO_Pin_11 // PE.11
|
||||
#define KEYS_GPIO_REG_ENTER GPIOE->IDR
|
||||
#define KEYS_GPIO_PIN_ENTER GPIO_Pin_12 // PE.12
|
||||
#endif
|
||||
#define PIN_BUTTON_MENU GPIO_Pin_7 // PD.07
|
||||
#define PIN_BUTTON_PAGE GPIO_Pin_3 // PD.02
|
||||
#define PIN_BUTTON_EXIT GPIO_Pin_2 // PD.03
|
||||
#define KEYS_GPIO_PIN_MENU GPIO_Pin_7 // PD.07
|
||||
#define KEYS_GPIO_PIN_PAGE GPIO_Pin_3 // PD.02
|
||||
#define KEYS_GPIO_PIN_EXIT GPIO_Pin_2 // PD.03
|
||||
|
||||
// Trims
|
||||
#define GPIO_TRIM_RV_DN GPIOC->IDR
|
||||
#define PIN_TRIM_RV_DN GPIO_Pin_3 // PC.03
|
||||
#define GPIO_TRIM_RV_UP GPIOC->IDR
|
||||
#define PIN_TRIM_RV_UP GPIO_Pin_2 // PC.02
|
||||
#define GPIO_TRIM_RH_L GPIOC->IDR
|
||||
#define PIN_TRIM_RH_L GPIO_Pin_1 // PC.01
|
||||
#define GPIO_TRIM_RH_R GPIOC->IDR
|
||||
#define PIN_TRIM_RH_R GPIO_Pin_13 // PC.13
|
||||
#define GPIO_TRIM_LH_L GPIOE->IDR
|
||||
#define PIN_TRIM_LH_L GPIO_Pin_4 // PE.04
|
||||
#define GPIO_TRIM_LH_R GPIOE->IDR
|
||||
#define PIN_TRIM_LH_R GPIO_Pin_3 // PE.03
|
||||
#define TRIMS_GPIO_REG_RVD GPIOC->IDR
|
||||
#define TRIMS_GPIO_PIN_RVD GPIO_Pin_3 // PC.03
|
||||
#define TRIMS_GPIO_REG_RVU GPIOC->IDR
|
||||
#define TRIMS_GPIO_PIN_RVU GPIO_Pin_2 // PC.02
|
||||
#define TRIMS_GPIO_REG_RHL GPIOC->IDR
|
||||
#define TRIMS_GPIO_PIN_RHL GPIO_Pin_1 // PC.01
|
||||
#define TRIMS_GPIO_REG_RHR GPIOC->IDR
|
||||
#define TRIMS_GPIO_PIN_RHR GPIO_Pin_13 // PC.13
|
||||
#define TRIMS_GPIO_REG_LHL GPIOE->IDR
|
||||
#define TRIMS_GPIO_PIN_LHL GPIO_Pin_4 // PE.04
|
||||
#define TRIMS_GPIO_REG_LHR GPIOE->IDR
|
||||
#define TRIMS_GPIO_PIN_LHR GPIO_Pin_3 // PE.03
|
||||
#if defined(REV9E)
|
||||
#define GPIO_TRIM_LV_DN GPIOG->IDR
|
||||
#define PIN_TRIM_LV_DN GPIO_Pin_1 // PG.01
|
||||
#define GPIO_TRIM_LV_UP GPIOG->IDR
|
||||
#define PIN_TRIM_LV_UP GPIO_Pin_0 // PG.00
|
||||
#define TRIMS_GPIO_REG_LVD GPIOG->IDR
|
||||
#define TRIMS_GPIO_PIN_LVD GPIO_Pin_1 // PG.01
|
||||
#define TRIMS_GPIO_REG_LVU GPIOG->IDR
|
||||
#define TRIMS_GPIO_PIN_LVU GPIO_Pin_0 // PG.00
|
||||
#else
|
||||
#define GPIO_TRIM_LV_DN GPIOE->IDR
|
||||
#define PIN_TRIM_LV_DN GPIO_Pin_6 // PE.06
|
||||
#define GPIO_TRIM_LV_UP GPIOE->IDR
|
||||
#define PIN_TRIM_LV_UP GPIO_Pin_5 // PE.05
|
||||
#define TRIMS_GPIO_REG_LVD GPIOE->IDR
|
||||
#define TRIMS_GPIO_PIN_LVD GPIO_Pin_6 // PE.06
|
||||
#define TRIMS_GPIO_REG_LVU GPIOE->IDR
|
||||
#define TRIMS_GPIO_PIN_LVU GPIO_Pin_5 // PE.05
|
||||
#endif
|
||||
|
||||
// Switches
|
||||
#define GPIO_PIN_SW_A_H GPIOB->IDR
|
||||
#define PIN_SW_A_H GPIO_Pin_5 // PB.05
|
||||
#define GPIO_PIN_SW_A_L GPIOE->IDR
|
||||
#define PIN_SW_A_L GPIO_Pin_0 // PE.00
|
||||
#define SWITCHES_GPIO_REG_A_H GPIOB->IDR
|
||||
#define SWITCHES_GPIO_PIN_A_H GPIO_Pin_5 // PB.05
|
||||
#define SWITCHES_GPIO_REG_A_L GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_A_L GPIO_Pin_0 // PE.00
|
||||
|
||||
#define GPIO_PIN_SW_B_H GPIOE->IDR
|
||||
#define PIN_SW_B_H GPIO_Pin_1 // PE.01
|
||||
#define GPIO_PIN_SW_B_L GPIOE->IDR
|
||||
#define PIN_SW_B_L GPIO_Pin_2 // PE.02
|
||||
#define SWITCHES_GPIO_REG_B_H GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_B_H GPIO_Pin_1 // PE.01
|
||||
#define SWITCHES_GPIO_REG_B_L GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_B_L GPIO_Pin_2 // PE.02
|
||||
|
||||
#define GPIO_PIN_SW_C_H GPIOE->IDR
|
||||
#define PIN_SW_C_H GPIO_Pin_15 // PE.15
|
||||
#define GPIO_PIN_SW_C_L GPIOA->IDR
|
||||
#define PIN_SW_C_L GPIO_Pin_5 // PA.05
|
||||
#define SWITCHES_GPIO_REG_C_H GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_C_H GPIO_Pin_15 // PE.15
|
||||
#define SWITCHES_GPIO_REG_C_L GPIOA->IDR
|
||||
#define SWITCHES_GPIO_PIN_C_L GPIO_Pin_5 // PA.05
|
||||
|
||||
#if defined(REVPLUS)
|
||||
#define GPIO_PIN_SW_D_H (GPIOE->IDR)
|
||||
#define PIN_SW_D_H GPIO_Pin_7 // PE.07
|
||||
#define GPIO_PIN_SW_D_L (GPIOE->IDR)
|
||||
#define PIN_SW_D_L GPIO_Pin_13 // PE.13
|
||||
#define SWITCHES_GPIO_REG_D_H (GPIOE->IDR)
|
||||
#define SWITCHES_GPIO_PIN_D_H GPIO_Pin_7 // PE.07
|
||||
#define SWITCHES_GPIO_REG_D_L (GPIOE->IDR)
|
||||
#define SWITCHES_GPIO_PIN_D_L GPIO_Pin_13 // PE.13
|
||||
#else
|
||||
#define GPIO_PIN_SW_D_H GPIOE->IDR
|
||||
#define PIN_SW_D_H GPIO_Pin_7 // PE.07
|
||||
#define GPIO_PIN_SW_D_L GPIOB->IDR
|
||||
#define PIN_SW_D_L GPIO_Pin_1 // PB.01
|
||||
#define SWITCHES_GPIO_REG_D_H GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_D_H GPIO_Pin_7 // PE.07
|
||||
#define SWITCHES_GPIO_REG_D_L GPIOB->IDR
|
||||
#define SWITCHES_GPIO_PIN_D_L GPIO_Pin_1 // PB.01
|
||||
#endif
|
||||
|
||||
#define GPIO_PIN_SW_E_L GPIOB->IDR
|
||||
#define PIN_SW_E_L GPIO_Pin_3 // PB.03
|
||||
#define GPIO_PIN_SW_E_H GPIOB->IDR
|
||||
#define PIN_SW_E_H GPIO_Pin_4 // PB.04
|
||||
#define SWITCHES_GPIO_REG_E_L GPIOB->IDR
|
||||
#define SWITCHES_GPIO_PIN_E_L GPIO_Pin_3 // PB.03
|
||||
#define SWITCHES_GPIO_REG_E_H GPIOB->IDR
|
||||
#define SWITCHES_GPIO_PIN_E_H GPIO_Pin_4 // PB.04
|
||||
|
||||
#if defined(REV9E)
|
||||
#define GPIO_PIN_SW_F_L GPIOF->IDR
|
||||
#define PIN_SW_F_L GPIO_Pin_15 // PF.15
|
||||
#define GPIO_PIN_SW_F_H GPIOE->IDR
|
||||
#define PIN_SW_F_H GPIO_Pin_14 // PE.14
|
||||
#define SWITCHES_GPIO_REG_F_L GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_F_L GPIO_Pin_15 // PF.15
|
||||
#define SWITCHES_GPIO_REG_F_H GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_F_H GPIO_Pin_14 // PE.14
|
||||
#else
|
||||
#define GPIO_PIN_SW_F GPIOE->IDR
|
||||
#define PIN_SW_F GPIO_Pin_14 // PE.14
|
||||
#define SWITCHES_GPIO_REG_F GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_F GPIO_Pin_14 // PE.14
|
||||
#endif
|
||||
|
||||
#define GPIO_PIN_SW_G_H GPIOE->IDR
|
||||
#define PIN_SW_G_H GPIO_Pin_9 // PE.09
|
||||
#define GPIO_PIN_SW_G_L GPIOE->IDR
|
||||
#define PIN_SW_G_L GPIO_Pin_8 // PE.08
|
||||
#define SWITCHES_GPIO_REG_G_H GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_G_H GPIO_Pin_9 // PE.09
|
||||
#define SWITCHES_GPIO_REG_G_L GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_G_L GPIO_Pin_8 // PE.08
|
||||
|
||||
#if defined(REV9E)
|
||||
#define GPIO_PIN_SW_H_H GPIOD->IDR
|
||||
#define PIN_SW_H_H GPIO_Pin_10 // PD.10
|
||||
#define GPIO_PIN_SW_H_L GPIOD->IDR
|
||||
#define PIN_SW_H_L GPIO_Pin_14 // PD.14
|
||||
#define SWITCHES_GPIO_REG_H_H GPIOD->IDR
|
||||
#define SWITCHES_GPIO_PIN_H_H GPIO_Pin_10 // PD.10
|
||||
#define SWITCHES_GPIO_REG_H_L GPIOD->IDR
|
||||
#define SWITCHES_GPIO_PIN_H_L GPIO_Pin_14 // PD.14
|
||||
#elif defined(REVPLUS)
|
||||
#define GPIO_PIN_SW_H GPIOD->IDR
|
||||
#define PIN_SW_H GPIO_Pin_14 // PD.14
|
||||
#define SWITCHES_GPIO_REG_H GPIOD->IDR
|
||||
#define SWITCHES_GPIO_PIN_H GPIO_Pin_14 // PD.14
|
||||
#else
|
||||
#define GPIO_PIN_SW_H GPIOE->IDR
|
||||
#define PIN_SW_H GPIO_Pin_13 // PE.13
|
||||
#define SWITCHES_GPIO_REG_H GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_H GPIO_Pin_13 // PE.13
|
||||
#endif
|
||||
|
||||
#if defined(REV9E)
|
||||
#define GPIO_PIN_SW_I_H GPIOF->IDR
|
||||
#define PIN_SW_I_H GPIO_Pin_1 // PF.01
|
||||
#define GPIO_PIN_SW_I_L GPIOF->IDR
|
||||
#define PIN_SW_I_L GPIO_Pin_2 // PF.02
|
||||
#define GPIO_PIN_SW_J_H GPIOF->IDR
|
||||
#define PIN_SW_J_H GPIO_Pin_3 // PF.03
|
||||
#define GPIO_PIN_SW_J_L GPIOF->IDR
|
||||
#define PIN_SW_J_L GPIO_Pin_4 // PF.04
|
||||
#define GPIO_PIN_SW_K_H GPIOF->IDR
|
||||
#define PIN_SW_K_H GPIO_Pin_5 // PF.05
|
||||
#define GPIO_PIN_SW_K_L GPIOF->IDR
|
||||
#define PIN_SW_K_L GPIO_Pin_6 // PF.06
|
||||
#define GPIO_PIN_SW_L_H GPIOF->IDR
|
||||
#define PIN_SW_L_H GPIO_Pin_7 // PF.07
|
||||
#define GPIO_PIN_SW_L_L GPIOE->IDR
|
||||
#define PIN_SW_L_L GPIO_Pin_10 // PE.10
|
||||
#define GPIO_PIN_SW_M_H GPIOF->IDR
|
||||
#define PIN_SW_M_H GPIO_Pin_11 // PF.11
|
||||
#define GPIO_PIN_SW_M_L GPIOF->IDR
|
||||
#define PIN_SW_M_L GPIO_Pin_12 // PF.12
|
||||
#define GPIO_PIN_SW_N_H GPIOF->IDR
|
||||
#define PIN_SW_N_H GPIO_Pin_13 // PF.13
|
||||
#define GPIO_PIN_SW_N_L GPIOF->IDR
|
||||
#define PIN_SW_N_L GPIO_Pin_14 // PF.14
|
||||
#define GPIO_PIN_SW_O_H GPIOG->IDR
|
||||
#define PIN_SW_O_H GPIO_Pin_13 // PG.13
|
||||
#define GPIO_PIN_SW_O_L GPIOG->IDR
|
||||
#define PIN_SW_O_L GPIO_Pin_12 // PG.12
|
||||
#define GPIO_PIN_SW_P_H GPIOG->IDR
|
||||
#define PIN_SW_P_H GPIO_Pin_11 // PG.11
|
||||
#define GPIO_PIN_SW_P_L GPIOG->IDR
|
||||
#define PIN_SW_P_L GPIO_Pin_10 // PG.10
|
||||
#define GPIO_PIN_SW_Q_H GPIOE->IDR
|
||||
#define PIN_SW_Q_H GPIO_Pin_11 // PE.11
|
||||
#define GPIO_PIN_SW_Q_L GPIOE->IDR
|
||||
#define PIN_SW_Q_L GPIO_Pin_12 // PE.12
|
||||
#define GPIO_PIN_SW_R_H GPIOG->IDR
|
||||
#define PIN_SW_R_H GPIO_Pin_7 // PG.07
|
||||
#define GPIO_PIN_SW_R_L GPIOG->IDR
|
||||
#define PIN_SW_R_L GPIO_Pin_8 // PG.08
|
||||
#define SWITCHES_GPIO_REG_I_H GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_I_H GPIO_Pin_1 // PF.01
|
||||
#define SWITCHES_GPIO_REG_I_L GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_I_L GPIO_Pin_2 // PF.02
|
||||
#define SWITCHES_GPIO_REG_J_H GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_J_H GPIO_Pin_3 // PF.03
|
||||
#define SWITCHES_GPIO_REG_J_L GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_J_L GPIO_Pin_4 // PF.04
|
||||
#define SWITCHES_GPIO_REG_K_H GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_K_H GPIO_Pin_5 // PF.05
|
||||
#define SWITCHES_GPIO_REG_K_L GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_K_L GPIO_Pin_6 // PF.06
|
||||
#define SWITCHES_GPIO_REG_L_H GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_L_H GPIO_Pin_7 // PF.07
|
||||
#define SWITCHES_GPIO_REG_L_L GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_L_L GPIO_Pin_10 // PE.10
|
||||
#define SWITCHES_GPIO_REG_M_H GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_M_H GPIO_Pin_11 // PF.11
|
||||
#define SWITCHES_GPIO_REG_M_L GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_M_L GPIO_Pin_12 // PF.12
|
||||
#define SWITCHES_GPIO_REG_N_H GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_N_H GPIO_Pin_13 // PF.13
|
||||
#define SWITCHES_GPIO_REG_N_L GPIOF->IDR
|
||||
#define SWITCHES_GPIO_PIN_N_L GPIO_Pin_14 // PF.14
|
||||
#define SWITCHES_GPIO_REG_O_H GPIOG->IDR
|
||||
#define SWITCHES_GPIO_PIN_O_H GPIO_Pin_13 // PG.13
|
||||
#define SWITCHES_GPIO_REG_O_L GPIOG->IDR
|
||||
#define SWITCHES_GPIO_PIN_O_L GPIO_Pin_12 // PG.12
|
||||
#define SWITCHES_GPIO_REG_P_H GPIOG->IDR
|
||||
#define SWITCHES_GPIO_PIN_P_H GPIO_Pin_11 // PG.11
|
||||
#define SWITCHES_GPIO_REG_P_L GPIOG->IDR
|
||||
#define SWITCHES_GPIO_PIN_P_L GPIO_Pin_10 // PG.10
|
||||
#define SWITCHES_GPIO_REG_Q_H GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_Q_H GPIO_Pin_11 // PE.11
|
||||
#define SWITCHES_GPIO_REG_Q_L GPIOE->IDR
|
||||
#define SWITCHES_GPIO_PIN_Q_L GPIO_Pin_12 // PE.12
|
||||
#define SWITCHES_GPIO_REG_R_H GPIOG->IDR
|
||||
#define SWITCHES_GPIO_PIN_R_H GPIO_Pin_7 // PG.07
|
||||
#define SWITCHES_GPIO_REG_R_L GPIOG->IDR
|
||||
#define SWITCHES_GPIO_PIN_R_L GPIO_Pin_8 // PG.08
|
||||
#endif
|
||||
|
||||
// ADC
|
||||
#define PIN_STK_J1 GPIO_Pin_0 // PA.00
|
||||
#define PIN_STK_J2 GPIO_Pin_1 // PA.01
|
||||
#define PIN_STK_J3 GPIO_Pin_2 // PA.02
|
||||
#define PIN_STK_J4 GPIO_Pin_3 // PA.03
|
||||
#define PIN_SLD_J1 GPIO_Pin_4 // PC.04
|
||||
#define PIN_SLD_J2 GPIO_Pin_5 // PC.05
|
||||
#define PIN_FLP_J1 GPIO_Pin_6 // PA.06
|
||||
#define PIN_FLP_J2 GPIO_Pin_0 // PB.00
|
||||
#if defined(REV9E)
|
||||
#define PIN_FLP_J3 GPIO_Pin_10 // PF.10
|
||||
#define PIN_FLP_J4 GPIO_Pin_9 // PF.09
|
||||
#define PIN_FLP_J5 GPIO_Pin_8 // PF.08
|
||||
#define PIN_FLP_J6 GPIO_Pin_1 // PB.01
|
||||
#elif defined(REVPLUS)
|
||||
#define PIN_FLP_J3 GPIO_Pin_1 // PB.01
|
||||
#define ADC_AHB1Periph_GPIO (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOF)
|
||||
#else
|
||||
#define ADC_AHB1Periph_GPIO (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC)
|
||||
#endif
|
||||
#define PIN_MVOLT GPIO_Pin_0 // PC.00
|
||||
#define RCC_AHB1Periph_GPIOADC RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC
|
||||
#define ADC_GPIO_PIN_STICK_RV GPIO_Pin_0 // PA.00
|
||||
#define ADC_GPIO_PIN_STICK_RH GPIO_Pin_1 // PA.01
|
||||
#define ADC_GPIO_PIN_STICK_LH GPIO_Pin_2 // PA.02
|
||||
#define ADC_GPIO_PIN_STICK_LV GPIO_Pin_3 // PA.03
|
||||
#define ADC_GPIO_PIN_SLIDER1 GPIO_Pin_4 // PC.04
|
||||
#define ADC_GPIO_PIN_SLIDER2 GPIO_Pin_5 // PC.05
|
||||
#define ADC_GPIO_PIN_POT1 GPIO_Pin_6 // PA.06
|
||||
#define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00
|
||||
#if defined(REV9E)
|
||||
#define ADC_GPIO_PIN_POT3 GPIO_Pin_10 // PF.10
|
||||
#define ADC_GPIO_PIN_POT4 GPIO_Pin_9 // PF.09
|
||||
#define ADC_GPIO_PIN_POT5 GPIO_Pin_8 // PF.08
|
||||
#define ADC_GPIO_PIN_POT6 GPIO_Pin_1 // PB.01
|
||||
#elif defined(REVPLUS)
|
||||
#define ADC_GPIO_PIN_POT3 GPIO_Pin_1 // PB.01
|
||||
#endif
|
||||
#define ADC_GPIO_PIN_BATT GPIO_Pin_0 // PC.00
|
||||
|
||||
// Power_OFF Delay and LED
|
||||
#define PIN_PWR_LED GPIO_Pin_6 // PC.06
|
||||
#define PIN_PWR_STATUS GPIO_Pin_1 // PD.01
|
||||
#define PIN_MCU_PWR GPIO_Pin_0 // PD.00
|
||||
#define RCC_AHB1Periph_GPIOPWR RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD
|
||||
#define GPIOPWRLED GPIOC
|
||||
#define GPIOPWR GPIOD
|
||||
#define GPIO_EXT_RF_PWR GPIOD
|
||||
#define PIN_EXT_RF_PWR GPIO_Pin_8
|
||||
#define PWR_RCC_AHB1Periph_GPIO (RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD)
|
||||
#define PWR_GPIO GPIOD
|
||||
#define PWR_GPIO_PIN_SWITCH GPIO_Pin_1 // PD.01
|
||||
#define PWR_GPIO_PIN_ON GPIO_Pin_0 // PD.00
|
||||
#define PWR_GPIO_LED GPIOC
|
||||
#define PWR_GPIO_PIN_LED GPIO_Pin_6 // PC.06
|
||||
|
||||
// Internal Module
|
||||
#define INTMODULE_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOA
|
||||
#if defined(REVPLUS)
|
||||
#define GPIO_INT_RF_PWR GPIOC
|
||||
#define PIN_INT_RF_PWR GPIO_Pin_6
|
||||
#define INTMODULE_GPIO_PWR GPIOC
|
||||
#define INTMODULE_GPIO_PIN_PWR GPIO_Pin_6
|
||||
#else
|
||||
#define GPIO_INT_RF_PWR GPIOD
|
||||
#define PIN_INT_RF_PWR GPIO_Pin_15
|
||||
#define INTMODULE_GPIO_PWR GPIOD
|
||||
#define INTMODULE_GPIO_PIN_PWR GPIO_Pin_15
|
||||
#endif
|
||||
#define INTMODULE_GPIO_PIN GPIO_Pin_10 // PA.10
|
||||
#define INTMODULE_GPIO GPIOA
|
||||
#define INTMODULE_GPIO_PinSource GPIO_PinSource10
|
||||
|
||||
// External Module
|
||||
#define EXTMODULE_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOA
|
||||
#define EXTMODULE_GPIO_PWR GPIOD
|
||||
#define EXTMODULE_GPIO_PIN_PWR GPIO_Pin_8
|
||||
#define EXTMODULE_GPIO_PIN GPIO_Pin_7 // PA.07
|
||||
#define EXTMODULE_GPIO GPIOA
|
||||
#define EXTMODULE_GPIO_PinSource GPIO_PinSource7
|
||||
|
||||
// Trainer Port
|
||||
#define GPIO_TR_INOUT GPIOC
|
||||
#define PIN_TR_PPM_IN GPIO_Pin_8 // PC.08
|
||||
#define PIN_TR_PPM_OUT GPIO_Pin_9 // PC.09
|
||||
#define GPIOTRNDET GPIOA
|
||||
#define PIN_TRNDET GPIO_Pin_8
|
||||
#define TRAINER_GPIO GPIOC
|
||||
#define TRAINER_GPIO_PIN_IN GPIO_Pin_8 // PC.08
|
||||
#define TRAINER_GPIO_PIN_OUT GPIO_Pin_9 // PC.09
|
||||
#define TRAINER_GPIO_DETECT GPIOA
|
||||
#define TRAINER_GPIO_PIN_DETECT GPIO_Pin_8 // PA.08
|
||||
|
||||
// Cppm
|
||||
#define RCC_AHB1Periph_GPIO_INTPPM RCC_AHB1Periph_GPIOA
|
||||
#define PIN_INTPPM_OUT GPIO_Pin_10 // PA.10
|
||||
#define GPIO_INTPPM GPIOA
|
||||
#define GPIO_PinSource_INTPPM GPIO_PinSource10
|
||||
#define RCC_AHB1Periph_GPIO_EXTPPM RCC_AHB1Periph_GPIOA
|
||||
#define PIN_EXTPPM_OUT GPIO_Pin_7 // PA.07
|
||||
#define GPIO_EXTPPM GPIOA
|
||||
#define GPIO_PinSource_EXTPPM GPIO_PinSource7
|
||||
// SERIAL_USART
|
||||
#define SERIAL_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOB
|
||||
#define SERIAL_RCC_APB1Periph_USART RCC_APB1Periph_USART3
|
||||
#define SERIAL_GPIO GPIOB
|
||||
#define SERIAL_GPIO_PIN_TX GPIO_Pin_10 // PB.10
|
||||
#define SERIAL_GPIO_PIN_RX GPIO_Pin_11 // PB.11
|
||||
#define SERIAL_GPIO_PinSource_TX GPIO_PinSource10
|
||||
#define SERIAL_GPIO_PinSource_RX GPIO_PinSource11
|
||||
#define SERIAL_GPIO_AF GPIO_AF_USART3
|
||||
#define SERIAL_USART USART3
|
||||
|
||||
// Heart Beat
|
||||
#define PIN_HEART_BEAT GPIO_Pin_7 // PC.07
|
||||
// Telemetry
|
||||
#define TELEMETRY_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOD
|
||||
#define TELEMETRY_RCC_APB1Periph_USART RCC_APB1Periph_USART2
|
||||
#define TELEMETRY_GPIO_DIR GPIOA
|
||||
#define TELEMETRY_GPIO_PIN_DIR GPIO_Pin_15 // PA.15
|
||||
#define TELEMETRY_GPIO GPIOD
|
||||
#define TELEMETRY_GPIO_PIN_TX GPIO_Pin_5 // PD.05
|
||||
#define TELEMETRY_GPIO_PIN_RX GPIO_Pin_6 // PD.06
|
||||
#define TELEMETRY_GPIO_PinSource_TX GPIO_PinSource5
|
||||
#define TELEMETRY_GPIO_PinSource_RX GPIO_PinSource6
|
||||
#define TELEMETRY_GPIO_AF GPIO_AF_USART2
|
||||
#define TELEMETRY_USART USART2
|
||||
#define TELEMETRY_USART_IRQHandler USART2_IRQHandler
|
||||
#define TELEMETRY_USART_IRQn USART2_IRQn
|
||||
|
||||
// UART3
|
||||
#define RCC_AHB1Periph_GPIO_UART3 RCC_AHB1Periph_GPIOB
|
||||
#define RCC_APB1Periph_UART3 RCC_APB1Periph_USART3
|
||||
#define GPIO_UART3 GPIOB
|
||||
#define GPIO_PIN_UART3_TX GPIO_Pin_10 // PB.10
|
||||
#define GPIO_PIN_UART3_RX GPIO_Pin_11 // PB.11
|
||||
#define GPIO_PinSource_UART3_TX GPIO_PinSource10
|
||||
#define GPIO_PinSource_UART3_RX GPIO_PinSource11
|
||||
#define GPIO_AF_UART3 GPIO_AF_USART3
|
||||
#define UART3 USART3
|
||||
|
||||
// Smart-Port
|
||||
#define RCC_AHB1Periph_GPIO_SPORT RCC_AHB1Periph_GPIOD
|
||||
#define RCC_APB1Periph_SPORT RCC_APB1Periph_USART2
|
||||
#define GPIO_PIN_SPORT_ON GPIOD
|
||||
#define PIN_SPORT_ON GPIO_Pin_4 // PD.04
|
||||
#define GPIO_PIN_SPORT_TXRX GPIOD
|
||||
#define PIN_SPORT_TX GPIO_Pin_5 // PD.05
|
||||
#define PIN_SPORT_RX GPIO_Pin_6 // PD.06
|
||||
#define GPIO_PinSource_SPORT_TX GPIO_PinSource5
|
||||
#define GPIO_PinSource_SPORT_RX GPIO_PinSource6
|
||||
#define GPIO_AF_SPORT GPIO_AF_USART2
|
||||
#define SPORT_USART USART2
|
||||
#define SPORT_IRQHandler USART2_IRQHandler
|
||||
#define SPORT_IRQn USART2_IRQn
|
||||
|
||||
// USB_OTG
|
||||
#define PIN_FS_VBUS GPIO_Pin_9 // PA.09
|
||||
#define PIN_FS_DM GPIO_Pin_11 // PA.11
|
||||
#define PIN_FS_DP GPIO_Pin_12 // PA.12
|
||||
// USB
|
||||
#define USB_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOA
|
||||
#define USB_GPIO GPIOA
|
||||
#define USB_GPIO_PIN_VBUS GPIO_Pin_9 // PA.09
|
||||
#define USB_GPIO_PIN_DM GPIO_Pin_11 // PA.11
|
||||
#define USB_GPIO_PIN_DP GPIO_Pin_12 // PA.12
|
||||
#define USB_GPIO_PinSource_DM GPIO_PinSource11
|
||||
#define USB_GPIO_PinSource_DP GPIO_PinSource12
|
||||
#define USB_GPIO_AF GPIO_AF_OTG1_FS
|
||||
|
||||
// BackLight
|
||||
#if defined(REV9E)
|
||||
#define TIM_BL TIM9
|
||||
#define GPIOBL GPIOE
|
||||
#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOE
|
||||
#define Pin_BL_AF GPIO_AF_TIM9
|
||||
#define GPIO_Pin_BL GPIO_Pin_6 // PE.06
|
||||
#define GPIO_PinSource_BL GPIO_PinSource6
|
||||
#define Pin_BLW_AF GPIO_AF_TIM9
|
||||
#define GPIO_Pin_BLW GPIO_Pin_5 // PE.05
|
||||
#define GPIO_PinSource_BLW GPIO_PinSource5
|
||||
#define BACKLIGHT_TIMER TIM9
|
||||
#define BACKLIGHT_GPIO GPIOE
|
||||
#define BACKLIGHT_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOE
|
||||
#define BACKLIGHT_GPIO_PIN_1 GPIO_Pin_6 // PE.06
|
||||
#define BACKLIGHT_GPIO_PIN_2 GPIO_Pin_5 // PE.05
|
||||
#define BACKLIGHT_GPIO_PinSource_1 GPIO_PinSource6
|
||||
#define BACKLIGHT_GPIO_PinSource_2 GPIO_PinSource5
|
||||
#define BACKLIGHT_GPIO_AF_1 GPIO_AF_TIM9
|
||||
#define BACKLIGHT_GPIO_AF_2 GPIO_AF_TIM9
|
||||
#elif defined (REVPLUS)
|
||||
#define TIM_BL TIM4
|
||||
#define GPIOBL GPIOD
|
||||
#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOD
|
||||
#define Pin_BL_AF GPIO_AF_TIM4
|
||||
#define GPIO_Pin_BL GPIO_Pin_15 // PD.15
|
||||
#define GPIO_PinSource_BL GPIO_PinSource15
|
||||
#define Pin_BLW_AF GPIO_AF_TIM4
|
||||
#define GPIO_Pin_BLW GPIO_Pin_13 // PD.13
|
||||
#define GPIO_PinSource_BLW GPIO_PinSource13
|
||||
#define BACKLIGHT_TIMER TIM4
|
||||
#define BACKLIGHT_GPIO GPIOD
|
||||
#define BACKLIGHT_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOD
|
||||
#define BACKLIGHT_GPIO_AF_1 GPIO_AF_TIM4
|
||||
#define BACKLIGHT_GPIO_PIN_1 GPIO_Pin_15 // PD.15
|
||||
#define BACKLIGHT_GPIO_PinSource_1 GPIO_PinSource15
|
||||
#define BACKLIGHT_GPIO_AF_2 GPIO_AF_TIM4
|
||||
#define BACKLIGHT_GPIO_PIN_2 GPIO_Pin_13 // PD.13
|
||||
#define BACKLIGHT_GPIO_PinSource_2 GPIO_PinSource13
|
||||
#else
|
||||
#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOB
|
||||
#define GPIO_Pin_BL GPIO_Pin_8 // PB.08
|
||||
#define Pin_BL_AF GPIO_AF_TIM10
|
||||
#define GPIOBL GPIOB
|
||||
#define GPIO_PinSource_BL GPIO_PinSource8
|
||||
#define BACKLIGHT_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOB
|
||||
#define BACKLIGHT_GPIO_PIN_1 GPIO_Pin_8 // PB.08
|
||||
#define BACKLIGHT_GPIO_AF_1 GPIO_AF_TIM10
|
||||
#define BACKLIGHT_GPIO GPIOB
|
||||
#define BACKLIGHT_GPIO_PinSource_1 GPIO_PinSource8
|
||||
#endif
|
||||
|
||||
// LCD
|
||||
#if defined(REV9E)
|
||||
#define RCC_AHB1Periph_LCD (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD)
|
||||
#define RCC_AHB1Periph_LCD_RST RCC_AHB1Periph_GPIOD
|
||||
#define RCC_AHB1Periph_LCD_NCS RCC_AHB1Periph_GPIOA
|
||||
#define GPIO_LCD_SPI GPIOC
|
||||
#define GPIO_LCD_NCS GPIOA
|
||||
#define GPIO_LCD_RST GPIOD
|
||||
#define PIN_LCD_MOSI GPIO_Pin_12 // PC.12
|
||||
#define PIN_LCD_CLK GPIO_Pin_10 // PC.10
|
||||
#define PIN_LCD_NCS GPIO_Pin_15 // PA.15
|
||||
#define PIN_LCD_A0 GPIO_Pin_11 // PC.11
|
||||
#define PIN_LCD_RST GPIO_Pin_15 // PD.15
|
||||
#define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD)
|
||||
#define LCD_RCC_AHB1Periph_RST RCC_AHB1Periph_GPIOD
|
||||
#define LCD_RCC_AHB1Periph_NCS RCC_AHB1Periph_GPIOA
|
||||
#define LCD_GPIO_SPI GPIOC
|
||||
#define LCD_GPIO_NCS GPIOA
|
||||
#define LCD_GPIO_RST GPIOD
|
||||
#define LCD_GPIO_PIN_MOSI GPIO_Pin_12 // PC.12
|
||||
#define LCD_GPIO_PIN_CLK GPIO_Pin_10 // PC.10
|
||||
#define LCD_GPIO_PIN_NCS GPIO_Pin_15 // PA.15
|
||||
#define LCD_GPIO_PIN_A0 GPIO_Pin_11 // PC.11
|
||||
#define LCD_GPIO_PIN_RST GPIO_Pin_15 // PD.15
|
||||
#elif defined(REVPLUS)
|
||||
#define RCC_AHB1Periph_LCD (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD)
|
||||
#define RCC_AHB1Periph_LCD_RST RCC_AHB1Periph_GPIOD
|
||||
#define RCC_AHB1Periph_LCD_NCS RCC_AHB1Periph_GPIOA
|
||||
#define GPIO_LCD_SPI GPIOC
|
||||
#define GPIO_LCD_NCS GPIOA
|
||||
#define GPIO_LCD_RST GPIOD
|
||||
#define PIN_LCD_MOSI GPIO_Pin_12 // PC.12
|
||||
#define PIN_LCD_CLK GPIO_Pin_10 // PC.10
|
||||
#define PIN_LCD_NCS GPIO_Pin_15 // PA.15
|
||||
#define PIN_LCD_A0 GPIO_Pin_11 // PC.11
|
||||
#define PIN_LCD_RST GPIO_Pin_12 // PD.12
|
||||
#define LCD_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD)
|
||||
#define LCD_RCC_AHB1Periph_RST RCC_AHB1Periph_GPIOD
|
||||
#define LCD_RCC_AHB1Periph_NCS RCC_AHB1Periph_GPIOA
|
||||
#define LCD_GPIO_SPI GPIOC
|
||||
#define LCD_GPIO_NCS GPIOA
|
||||
#define LCD_GPIO_RST GPIOD
|
||||
#define LCD_GPIO_PIN_MOSI GPIO_Pin_12 // PC.12
|
||||
#define LCD_GPIO_PIN_CLK GPIO_Pin_10 // PC.10
|
||||
#define LCD_GPIO_PIN_NCS GPIO_Pin_15 // PA.15
|
||||
#define LCD_GPIO_PIN_A0 GPIO_Pin_11 // PC.11
|
||||
#define LCD_GPIO_PIN_RST GPIO_Pin_12 // PD.12
|
||||
#else
|
||||
#define RCC_AHB1Periph_LCD RCC_AHB1Periph_GPIOD
|
||||
#define GPIO_LCD_SPI GPIOD
|
||||
#define GPIO_LCD_NCS GPIOD
|
||||
#define GPIO_LCD_RST GPIOD
|
||||
#define PIN_LCD_MOSI GPIO_Pin_10 // PD.10
|
||||
#define PIN_LCD_CLK GPIO_Pin_11 // PD.11
|
||||
#define PIN_LCD_NCS GPIO_Pin_14 // PD.14
|
||||
#define PIN_LCD_A0 GPIO_Pin_13 // PD.13
|
||||
#define PIN_LCD_RST GPIO_Pin_12 // PD.12
|
||||
#define LCD_RCC_AHB1Periph RCC_AHB1Periph_GPIOD
|
||||
#define LCD_GPIO_SPI GPIOD
|
||||
#define LCD_GPIO_NCS GPIOD
|
||||
#define LCD_GPIO_RST GPIOD
|
||||
#define LCD_GPIO_PIN_MOSI GPIO_Pin_10 // PD.10
|
||||
#define LCD_GPIO_PIN_CLK GPIO_Pin_11 // PD.11
|
||||
#define LCD_GPIO_PIN_NCS GPIO_Pin_14 // PD.14
|
||||
#define LCD_GPIO_PIN_A0 GPIO_Pin_13 // PD.13
|
||||
#define LCD_GPIO_PIN_RST GPIO_Pin_12 // PD.12
|
||||
#endif
|
||||
|
||||
// I2C Bus: EEPROM and CAT5137
|
||||
|
@ -363,35 +370,25 @@
|
|||
|
||||
// Haptic
|
||||
#if defined(REVPLUS)
|
||||
#define RCC_AHB1Periph_GPIOHAPTIC RCC_AHB1Periph_GPIOB
|
||||
#define GPIO_PinSource_HAPTIC GPIO_PinSource8
|
||||
#define GPIO_HAPTIC GPIOB
|
||||
#define PIN_HAPTIC GPIO_Pin_8
|
||||
#define HAPTIC_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOB
|
||||
#define HAPTIC_GPIO_PinSource GPIO_PinSource8
|
||||
#define HAPTIC_GPIO GPIOB
|
||||
#define HAPTIC_GPIO_PIN GPIO_Pin_8
|
||||
#else
|
||||
#define RCC_AHB1Periph_GPIOHAPTIC RCC_AHB1Periph_GPIOC
|
||||
#define GPIO_HAPTIC GPIOC
|
||||
#define PIN_HAPTIC GPIO_Pin_12
|
||||
#define HAPTIC_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOC
|
||||
#define HAPTIC_GPIO GPIOC
|
||||
#define HAPTIC_GPIO_PIN GPIO_Pin_12
|
||||
#endif
|
||||
|
||||
// Top LCD on X9E
|
||||
#if defined(REV9E)
|
||||
#define GPIO_VA GPIOG
|
||||
#define PIN_VA_DATA GPIO_Pin_5
|
||||
#define PIN_VA_WR GPIO_Pin_4
|
||||
#define PIN_VA_CS GPIO_Pin_3
|
||||
#define PIN_VA_CS2 GPIO_Pin_15
|
||||
#define PIN_VA_BL GPIO_Pin_2
|
||||
#define RCC_AHB1Periph_VA RCC_AHB1Periph_GPIOG
|
||||
#define CS1_HIGH GPIO_VA->BSRRL = PIN_VA_CS
|
||||
#define CS1_LOW GPIO_VA->BSRRH = PIN_VA_CS
|
||||
#define CS2_HIGH GPIO_VA->BSRRL = PIN_VA_CS2
|
||||
#define CS2_LOW GPIO_VA->BSRRH = PIN_VA_CS2
|
||||
#define WR_HIGH GPIO_VA->BSRRL = PIN_VA_WR
|
||||
#define WR_LOW GPIO_VA->BSRRH = PIN_VA_WR
|
||||
#define DATA_HIGH GPIO_VA->BSRRL = PIN_VA_DATA
|
||||
#define DATA_LOW GPIO_VA->BSRRH = PIN_VA_DATA
|
||||
#define VA_BL_ON GPIO_VA->BSRRL = PIN_VA_BL
|
||||
#define VA_BL_OFF GPIO_VA->BSRRH = PIN_VA_BL
|
||||
#define TOPLCD_GPIO GPIOG
|
||||
#define TOPLCD_GPIO_PIN_DATA GPIO_Pin_5
|
||||
#define TOPLCD_GPIO_PIN_WR GPIO_Pin_4
|
||||
#define TOPLCD_GPIO_PIN_CS1 GPIO_Pin_3
|
||||
#define TOPLCD_GPIO_PIN_CS2 GPIO_Pin_15
|
||||
#define TOPLCD_GPIO_PIN_BL GPIO_Pin_2
|
||||
#define TOPLCD_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOG
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -52,16 +52,16 @@ void hapticOn(uint32_t pwmPercent)
|
|||
|
||||
void hapticInit(void)
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOHAPTIC, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(HAPTIC_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_HAPTIC;
|
||||
GPIO_InitStructure.GPIO_Pin = HAPTIC_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_HAPTIC, &GPIO_InitStructure);
|
||||
GPIO_Init(HAPTIC_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_PinAFConfig(GPIO_HAPTIC, GPIO_PinSource_HAPTIC, GPIO_AF_TIM10);
|
||||
GPIO_PinAFConfig(HAPTIC_GPIO, HAPTIC_GPIO_PinSource, GPIO_AF_TIM10);
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock
|
||||
TIM10->ARR = 100 ;
|
||||
|
@ -80,25 +80,25 @@ void hapticInit(void)
|
|||
void hapticInit(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOHAPTIC, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(HAPTIC_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
|
||||
/* GPIO Configuration*/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_HAPTIC;
|
||||
GPIO_InitStructure.GPIO_Pin = HAPTIC_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_HAPTIC, &GPIO_InitStructure);
|
||||
GPIO_Init(HAPTIC_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
void hapticOff(void)
|
||||
{
|
||||
GPIO_ResetBits(GPIO_HAPTIC, PIN_HAPTIC);
|
||||
GPIO_ResetBits(HAPTIC_GPIO, HAPTIC_GPIO_PIN);
|
||||
}
|
||||
|
||||
void hapticOn()
|
||||
{
|
||||
GPIO_SetBits(GPIO_HAPTIC, PIN_HAPTIC);
|
||||
GPIO_SetBits(HAPTIC_GPIO, HAPTIC_GPIO_PIN);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
void I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite);
|
||||
void I2C_EE_WaitEepromStandbyState(void);
|
||||
void I2C_set_volume(register uint8_t volume);
|
||||
uint8_t I2C_read_volume(void);
|
||||
|
||||
void eepromInit(void)
|
||||
{
|
||||
|
|
|
@ -40,36 +40,33 @@
|
|||
|
||||
uint32_t readKeys()
|
||||
{
|
||||
register uint32_t d = GPIOD->IDR;
|
||||
register uint32_t e = GPIOE->IDR;
|
||||
register uint32_t f = GPIOF->IDR;
|
||||
register uint32_t result = 0;
|
||||
register uint32_t d = ~GPIOD->IDR;
|
||||
|
||||
#if !defined(REV9E) || defined(SIMU)
|
||||
register uint32_t e = ~GPIOE->IDR;
|
||||
(void)e;
|
||||
(void)f;
|
||||
#endif
|
||||
|
||||
#if defined(REV9E)
|
||||
if (f & PIN_BUTTON_ENTER)
|
||||
if (!(GPIOF->IDR & KEYS_GPIO_PIN_ENTER))
|
||||
#else
|
||||
if (e & PIN_BUTTON_ENTER)
|
||||
if (e & KEYS_GPIO_PIN_ENTER)
|
||||
#endif
|
||||
result |= 0x02 << KEY_ENTER;
|
||||
|
||||
#if !defined(REV9E) || defined(SIMU)
|
||||
if (e & PIN_BUTTON_PLUS)
|
||||
if (e & KEYS_GPIO_PIN_PLUS)
|
||||
result |= 0x02 << KEY_PLUS;
|
||||
if (e & PIN_BUTTON_MINUS)
|
||||
if (e & KEYS_GPIO_PIN_MINUS)
|
||||
result |= 0x02 << KEY_MINUS;
|
||||
#else
|
||||
result |= 0x02 << KEY_PLUS;
|
||||
result |= 0x02 << KEY_MINUS;
|
||||
#endif
|
||||
|
||||
if (d & PIN_BUTTON_MENU)
|
||||
if (d & KEYS_GPIO_PIN_MENU)
|
||||
result |= 0x02 << KEY_MENU;
|
||||
if (d & PIN_BUTTON_PAGE)
|
||||
if (d & KEYS_GPIO_PIN_PAGE)
|
||||
result |= 0x02 << KEY_PAGE;
|
||||
if (d & PIN_BUTTON_EXIT)
|
||||
if (d & KEYS_GPIO_PIN_EXIT)
|
||||
result |= 0x02 << KEY_EXIT;
|
||||
|
||||
// TRACE("readKeys(): %x %x => %x", d, e, result);
|
||||
|
@ -86,30 +83,30 @@ uint32_t readTrims()
|
|||
#endif
|
||||
register uint32_t result = 0;
|
||||
|
||||
if (~e & PIN_TRIM_LH_L)
|
||||
if (~e & TRIMS_GPIO_PIN_LHL)
|
||||
result |= 0x01; // LH_L
|
||||
if (~e & PIN_TRIM_LH_R)
|
||||
if (~e & TRIMS_GPIO_PIN_LHR)
|
||||
result |= 0x02; // LH_R
|
||||
|
||||
#if defined(REV9E)
|
||||
if (~g & PIN_TRIM_LV_DN)
|
||||
if (~g & TRIMS_GPIO_PIN_LVD)
|
||||
result |= 0x04; // LV_DN
|
||||
if (~g & PIN_TRIM_LV_UP)
|
||||
if (~g & TRIMS_GPIO_PIN_LVU)
|
||||
result |= 0x08; // LV_UP
|
||||
#else
|
||||
if (~e & PIN_TRIM_LV_DN)
|
||||
if (~e & TRIMS_GPIO_PIN_LVD)
|
||||
result |= 0x04; // LV_DN
|
||||
if (~e & PIN_TRIM_LV_UP)
|
||||
if (~e & TRIMS_GPIO_PIN_LVU)
|
||||
result |= 0x08; // LV_UP
|
||||
#endif
|
||||
|
||||
if (~c & PIN_TRIM_RV_DN)
|
||||
if (~c & TRIMS_GPIO_PIN_RVD)
|
||||
result |= 0x10; // RV_DN
|
||||
if (~c & PIN_TRIM_RV_UP)
|
||||
if (~c & TRIMS_GPIO_PIN_RVU)
|
||||
result |= 0x20; // RV_UP
|
||||
if (~c & PIN_TRIM_RH_L)
|
||||
if (~c & TRIMS_GPIO_PIN_RHL)
|
||||
result |= 0x40; // RH_L
|
||||
if (~c & PIN_TRIM_RH_R)
|
||||
if (~c & TRIMS_GPIO_PIN_RHR)
|
||||
result |= 0x80; // RH_R
|
||||
|
||||
// TRACE("readTrims(): %x %x => %x", c, e, result);
|
||||
|
@ -124,7 +121,7 @@ uint8_t trimDown(uint8_t idx)
|
|||
|
||||
uint8_t keyDown()
|
||||
{
|
||||
return ~readKeys() & 0x7E ;
|
||||
return readKeys();
|
||||
}
|
||||
|
||||
#if defined(REV9E)
|
||||
|
@ -137,7 +134,7 @@ void readKeysAndTrims()
|
|||
register uint32_t i;
|
||||
|
||||
uint8_t enuk = KEY_MENU;
|
||||
uint32_t in = ~readKeys();
|
||||
uint32_t in = readKeys();
|
||||
for (i = 1; i <= TRM_BASE; i++) {
|
||||
keys[enuk].input(in & (1 << i));
|
||||
++enuk;
|
||||
|
@ -171,53 +168,53 @@ void readKeysAndTrims()
|
|||
#if defined(REV9E)
|
||||
#define ADD_3POS_CASE(x, i) \
|
||||
case SW_S ## x ## 0: \
|
||||
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H) && (~GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
|
||||
xxx = (SWITCHES_GPIO_REG_ ## x ## _H & SWITCHES_GPIO_PIN_ ## x ## _H) && (~SWITCHES_GPIO_REG_ ## x ## _L & SWITCHES_GPIO_PIN_ ## x ## _L); \
|
||||
break; \
|
||||
case SW_S ## x ## 1: \
|
||||
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H) && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
|
||||
xxx = (SWITCHES_GPIO_REG_ ## x ## _H & SWITCHES_GPIO_PIN_ ## x ## _H) && (SWITCHES_GPIO_REG_ ## x ## _L & SWITCHES_GPIO_PIN_ ## x ## _L); \
|
||||
break; \
|
||||
case SW_S ## x ## 2: \
|
||||
xxx = (~GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H) && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
|
||||
xxx = (~SWITCHES_GPIO_REG_ ## x ## _H & SWITCHES_GPIO_PIN_ ## x ## _H) && (SWITCHES_GPIO_REG_ ## x ## _L & SWITCHES_GPIO_PIN_ ## x ## _L); \
|
||||
break
|
||||
#define ADD_3POS_INVERTED_CASE(x, i) ADD_3POS_CASE(x, i)
|
||||
#else
|
||||
#define ADD_2POS_CASE(x) \
|
||||
case SW_S ## x ## 0: \
|
||||
xxx = GPIO_PIN_SW_ ## x & PIN_SW_ ## x ; \
|
||||
xxx = SWITCHES_GPIO_REG_ ## x & SWITCHES_GPIO_PIN_ ## x ; \
|
||||
break; \
|
||||
case SW_S ## x ## 2: \
|
||||
xxx = ~GPIO_PIN_SW_ ## x & PIN_SW_ ## x ; \
|
||||
xxx = ~SWITCHES_GPIO_REG_ ## x & SWITCHES_GPIO_PIN_ ## x ; \
|
||||
break
|
||||
#define ADD_3POS_CASE(x, i) \
|
||||
case SW_S ## x ## 0: \
|
||||
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H); \
|
||||
xxx = (SWITCHES_GPIO_REG_ ## x ## _H & SWITCHES_GPIO_PIN_ ## x ## _H); \
|
||||
if (IS_3POS(i)) { \
|
||||
xxx = xxx && (~GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
|
||||
xxx = xxx && (~SWITCHES_GPIO_REG_ ## x ## _L & SWITCHES_GPIO_PIN_ ## x ## _L); \
|
||||
} \
|
||||
break; \
|
||||
case SW_S ## x ## 1: \
|
||||
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H) && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
|
||||
xxx = (SWITCHES_GPIO_REG_ ## x ## _H & SWITCHES_GPIO_PIN_ ## x ## _H) && (SWITCHES_GPIO_REG_ ## x ## _L & SWITCHES_GPIO_PIN_ ## x ## _L); \
|
||||
break; \
|
||||
case SW_S ## x ## 2: \
|
||||
xxx = (~GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H); \
|
||||
xxx = (~SWITCHES_GPIO_REG_ ## x ## _H & SWITCHES_GPIO_PIN_ ## x ## _H); \
|
||||
if (IS_3POS(i)) { \
|
||||
xxx = xxx && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
|
||||
xxx = xxx && (SWITCHES_GPIO_REG_ ## x ## _L & SWITCHES_GPIO_PIN_ ## x ## _L); \
|
||||
} \
|
||||
break
|
||||
#define ADD_3POS_INVERTED_CASE(x, i) \
|
||||
case SW_S ## x ## 0: \
|
||||
xxx = (~GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H); \
|
||||
xxx = (~SWITCHES_GPIO_REG_ ## x ## _H & SWITCHES_GPIO_PIN_ ## x ## _H); \
|
||||
if (IS_3POS(i)) { \
|
||||
xxx = xxx && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
|
||||
xxx = xxx && (SWITCHES_GPIO_REG_ ## x ## _L & SWITCHES_GPIO_PIN_ ## x ## _L); \
|
||||
} \
|
||||
break; \
|
||||
case SW_S ## x ## 1: \
|
||||
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H) && (GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
|
||||
xxx = (SWITCHES_GPIO_REG_ ## x ## _H & SWITCHES_GPIO_PIN_ ## x ## _H) && (SWITCHES_GPIO_REG_ ## x ## _L & SWITCHES_GPIO_PIN_ ## x ## _L); \
|
||||
break; \
|
||||
case SW_S ## x ## 2: \
|
||||
xxx = (GPIO_PIN_SW_ ## x ## _H & PIN_SW_ ## x ## _H); \
|
||||
xxx = (SWITCHES_GPIO_REG_ ## x ## _H & SWITCHES_GPIO_PIN_ ## x ## _H); \
|
||||
if (IS_3POS(i)) { \
|
||||
xxx = xxx && (~GPIO_PIN_SW_ ## x ## _L & PIN_SW_ ## x ## _L); \
|
||||
xxx = xxx && (~SWITCHES_GPIO_REG_ ## x ## _L & SWITCHES_GPIO_PIN_ ## x ## _L); \
|
||||
} \
|
||||
break
|
||||
#endif
|
||||
|
@ -273,19 +270,19 @@ void keysInit()
|
|||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBUTTON, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(KEYS_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
|
||||
#if defined(REV9E)
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_TRIM_LH_R | PIN_TRIM_LH_L
|
||||
| PIN_SW_F_H | PIN_SW_A_L | PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_D_H | PIN_SW_D_L | PIN_SW_G_H | PIN_SW_G_L | PIN_SW_L_L | PIN_SW_Q_H | PIN_SW_Q_L;
|
||||
GPIO_InitStructure.GPIO_Pin = TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_LHL
|
||||
| SWITCHES_GPIO_PIN_F_H | SWITCHES_GPIO_PIN_A_L | SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_C_H | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_L_L | SWITCHES_GPIO_PIN_Q_H | SWITCHES_GPIO_PIN_Q_L;
|
||||
#elif defined(REVPLUS)
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L
|
||||
| PIN_TRIM_LV_DN | PIN_TRIM_LV_UP
|
||||
| PIN_SW_F | PIN_SW_A_L | PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_D_H | PIN_SW_D_L | PIN_SW_G_H | PIN_SW_G_L;
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIO_PIN_PLUS | KEYS_GPIO_PIN_ENTER | KEYS_GPIO_PIN_MINUS | TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_LHL
|
||||
| TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU
|
||||
| SWITCHES_GPIO_PIN_F | SWITCHES_GPIO_PIN_A_L | SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_C_H | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L;
|
||||
#else
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_PLUS | PIN_BUTTON_ENTER | PIN_BUTTON_MINUS | PIN_TRIM_LH_R | PIN_TRIM_LH_L
|
||||
| PIN_TRIM_LV_DN | PIN_TRIM_LV_UP
|
||||
| PIN_SW_F | PIN_SW_A_L | PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_D_H | PIN_SW_G_H | PIN_SW_G_L | PIN_SW_H;
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIO_PIN_PLUS | KEYS_GPIO_PIN_ENTER | KEYS_GPIO_PIN_MINUS | TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_LHL
|
||||
| TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU
|
||||
| SWITCHES_GPIO_PIN_F | SWITCHES_GPIO_PIN_A_L | SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_C_H | SWITCHES_GPIO_PIN_D_H | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_H;
|
||||
#endif
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
|
@ -294,33 +291,33 @@ void keysInit()
|
|||
GPIO_Init(GPIOE, &GPIO_InitStructure);
|
||||
|
||||
#if defined(REV9E)
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_ENTER | PIN_SW_F_L | PIN_SW_I_H | PIN_SW_I_L | PIN_SW_J_H | PIN_SW_J_L | PIN_SW_K_H | PIN_SW_K_L | PIN_SW_L_H | PIN_SW_M_H | PIN_SW_M_L | PIN_SW_N_H | PIN_SW_N_L;
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIO_PIN_ENTER | SWITCHES_GPIO_PIN_F_L | SWITCHES_GPIO_PIN_I_H | SWITCHES_GPIO_PIN_I_L | SWITCHES_GPIO_PIN_J_H | SWITCHES_GPIO_PIN_J_L | SWITCHES_GPIO_PIN_K_H | SWITCHES_GPIO_PIN_K_L | SWITCHES_GPIO_PIN_L_H | SWITCHES_GPIO_PIN_M_H | SWITCHES_GPIO_PIN_M_L | SWITCHES_GPIO_PIN_N_H | SWITCHES_GPIO_PIN_N_L;
|
||||
GPIO_Init(GPIOF, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_TRIM_LV_DN | PIN_TRIM_LV_UP | PIN_SW_O_H | PIN_SW_O_L | PIN_SW_P_H | PIN_SW_P_L | PIN_SW_R_H | PIN_SW_R_L;
|
||||
GPIO_InitStructure.GPIO_Pin = TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU | SWITCHES_GPIO_PIN_O_H | SWITCHES_GPIO_PIN_O_L | SWITCHES_GPIO_PIN_P_H | SWITCHES_GPIO_PIN_P_L | SWITCHES_GPIO_PIN_R_H | SWITCHES_GPIO_PIN_R_L;
|
||||
GPIO_Init(GPIOG, &GPIO_InitStructure);
|
||||
#endif
|
||||
|
||||
#if defined(REV9E)
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE | PIN_SW_H_H | PIN_SW_H_L;
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_PAGE | SWITCHES_GPIO_PIN_H_H | SWITCHES_GPIO_PIN_H_L;
|
||||
#elif defined(REVPLUS)
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE | PIN_SW_H;
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_PAGE | SWITCHES_GPIO_PIN_H;
|
||||
#else
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_MENU | PIN_BUTTON_EXIT | PIN_BUTTON_PAGE;
|
||||
GPIO_InitStructure.GPIO_Pin = KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_PAGE;
|
||||
#endif
|
||||
GPIO_Init(GPIOD, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_TRIM_RV_DN | PIN_TRIM_RV_UP | PIN_TRIM_RH_L | PIN_TRIM_RH_R;
|
||||
GPIO_InitStructure.GPIO_Pin = TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_RHR;
|
||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
|
||||
#if defined(REVPLUS)
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SW_E_L | PIN_SW_E_H | PIN_SW_A_H;
|
||||
GPIO_InitStructure.GPIO_Pin = SWITCHES_GPIO_PIN_E_L | SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_A_H;
|
||||
#else
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SW_E_L | PIN_SW_E_H | PIN_SW_A_H | PIN_SW_D_L;
|
||||
GPIO_InitStructure.GPIO_Pin = SWITCHES_GPIO_PIN_E_L | SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_A_H | SWITCHES_GPIO_PIN_D_L;
|
||||
#endif
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SW_C_L;
|
||||
GPIO_InitStructure.GPIO_Pin = SWITCHES_GPIO_PIN_C_L;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -42,9 +42,9 @@ static void Delay(uint32_t ms)
|
|||
// New hardware SPI driver for LCD
|
||||
void initLcdSpi()
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_LCD, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_LCD_RST, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_LCD_NCS, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(LCD_RCC_AHB1Periph, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(LCD_RCC_AHB1Periph_RST, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(LCD_RCC_AHB1Periph_NCS, ENABLE);
|
||||
|
||||
RCC->APB1ENR |= RCC_APB1ENR_SPI3EN ; // Enable clock
|
||||
// APB1 clock / 2 = 133nS per clock
|
||||
|
@ -54,10 +54,10 @@ void initLcdSpi()
|
|||
SPI3->CR1 |= SPI_CR1_MSTR ; // Make sure in case SSM/SSI needed to be set first
|
||||
SPI3->CR1 |= SPI_CR1_SPE ;
|
||||
|
||||
configure_pins( PIN_LCD_NCS, PIN_OUTPUT | PIN_PORTA | PIN_OS25) ;
|
||||
configure_pins( PIN_LCD_RST, PIN_OUTPUT | PIN_PORTD | PIN_OS25) ;
|
||||
configure_pins( PIN_LCD_A0, PIN_OUTPUT | PIN_PORTC | PIN_OS50) ;
|
||||
configure_pins( PIN_LCD_MOSI|PIN_LCD_CLK, PIN_PORTC | PIN_OS50 | PIN_PER_6 | PIN_PERIPHERAL ) ;
|
||||
configure_pins( LCD_GPIO_PIN_NCS, PIN_OUTPUT | PIN_PORTA | PIN_OS25) ;
|
||||
configure_pins( LCD_GPIO_PIN_RST, PIN_OUTPUT | PIN_PORTD | PIN_OS25) ;
|
||||
configure_pins( LCD_GPIO_PIN_A0, PIN_OUTPUT | PIN_PORTC | PIN_OS50) ;
|
||||
configure_pins( LCD_GPIO_PIN_MOSI|LCD_GPIO_PIN_CLK, PIN_PORTC | PIN_OS50 | PIN_PER_6 | PIN_PERIPHERAL ) ;
|
||||
|
||||
|
||||
// NVIC_SetPriority( DMA1_Stream7_IRQn, 8 ) ;
|
||||
|
@ -263,18 +263,18 @@ void lcdRefresh()
|
|||
/**Init the Backlight GPIO */
|
||||
static void LCD_BL_Config()
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBL, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(BACKLIGHT_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
#if defined(REV9E)
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL|GPIO_Pin_BLW;
|
||||
GPIO_InitStructure.GPIO_Pin = BACKLIGHT_GPIO_PIN_1|BACKLIGHT_GPIO_PIN_2;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIOBL, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, Pin_BL_AF);
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BLW, Pin_BL_AF);
|
||||
GPIO_Init(BACKLIGHT_GPIO, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource_1, BACKLIGHT_GPIO_AF_1);
|
||||
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource_2, BACKLIGHT_GPIO_AF_1);
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM9EN ; // Enable clock
|
||||
TIM9->ARR = 100 ;
|
||||
TIM9->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 50000 - 1; // 20us * 100 = 2ms => 500Hz
|
||||
|
@ -285,14 +285,14 @@ static void LCD_BL_Config()
|
|||
TIM9->EGR = 0 ;
|
||||
TIM9->CR1 = TIM_CR1_CEN ; // Counter enable
|
||||
#elif defined(REVPLUS)
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL|GPIO_Pin_BLW;
|
||||
GPIO_InitStructure.GPIO_Pin = BACKLIGHT_GPIO_PIN_1|BACKLIGHT_GPIO_PIN_2;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIOBL, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, Pin_BL_AF);
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BLW, Pin_BL_AF);
|
||||
GPIO_Init(BACKLIGHT_GPIO, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource_1, BACKLIGHT_GPIO_AF_1);
|
||||
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource_2, BACKLIGHT_GPIO_AF_1);
|
||||
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN ; // Enable clock
|
||||
TIM4->ARR = 100 ;
|
||||
|
@ -305,13 +305,13 @@ static void LCD_BL_Config()
|
|||
TIM4->EGR = 0 ;
|
||||
TIM4->CR1 = TIM_CR1_CEN ; // Counter enable
|
||||
#else
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL;
|
||||
GPIO_InitStructure.GPIO_Pin = BACKLIGHT_GPIO_PIN_1;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIOBL, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, Pin_BL_AF);
|
||||
GPIO_Init(BACKLIGHT_GPIO, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(BACKLIGHT_GPIO, BACKLIGHT_GPIO_PinSource_1, BACKLIGHT_GPIO_AF_1);
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM10EN ; // Enable clock
|
||||
TIM10->ARR = 100 ;
|
||||
|
@ -328,31 +328,31 @@ static void LCD_BL_Config()
|
|||
*/
|
||||
static void LCD_Hardware_Init()
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_LCD, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(LCD_RCC_AHB1Periph, ENABLE);
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
/*!< Configure lcd CLK\ MOSI\ A0pin in output push-pull mode *************/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_LCD_MOSI | PIN_LCD_CLK | PIN_LCD_A0;
|
||||
GPIO_InitStructure.GPIO_Pin = LCD_GPIO_PIN_MOSI | LCD_GPIO_PIN_CLK | LCD_GPIO_PIN_A0;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_LCD_SPI, &GPIO_InitStructure);
|
||||
GPIO_Init(LCD_GPIO_SPI, &GPIO_InitStructure);
|
||||
|
||||
LCD_NCS_HIGH();
|
||||
|
||||
/*!< Configure lcd NCS pin in output push-pull mode ,PULLUP *************/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS;
|
||||
GPIO_InitStructure.GPIO_Pin = LCD_GPIO_PIN_NCS;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(GPIO_LCD_NCS, &GPIO_InitStructure);
|
||||
GPIO_Init(LCD_GPIO_NCS, &GPIO_InitStructure);
|
||||
|
||||
/*!< Configure lcd RST pin in output pushpull mode ,PULLUP *************/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_LCD_RST;
|
||||
GPIO_Init(GPIO_LCD_RST, &GPIO_InitStructure);
|
||||
GPIO_InitStructure.GPIO_Pin = LCD_GPIO_PIN_RST;
|
||||
GPIO_Init(LCD_GPIO_RST, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -445,25 +445,25 @@ void lcdSetRefVolt(uint8_t val)
|
|||
#if defined(REV9E)
|
||||
void turnBacklightOn(uint8_t level, uint8_t color)
|
||||
{
|
||||
TIM_BL->CCR1 = ((100-level)*(20-color))/20;
|
||||
TIM_BL->CCR2 = ((100-level)*color)/20;
|
||||
BACKLIGHT_TIMER->CCR1 = ((100-level)*(20-color))/20;
|
||||
BACKLIGHT_TIMER->CCR2 = ((100-level)*color)/20;
|
||||
}
|
||||
|
||||
void turnBacklightOff(void)
|
||||
{
|
||||
TIM_BL->CCR1 = 0;
|
||||
TIM_BL->CCR2 = 0;
|
||||
BACKLIGHT_TIMER->CCR1 = 0;
|
||||
BACKLIGHT_TIMER->CCR2 = 0;
|
||||
}
|
||||
#elif defined(REVPLUS)
|
||||
void turnBacklightOn(uint8_t level, uint8_t color)
|
||||
{
|
||||
TIM_BL->CCR4 = ((100-level)*(20-color))/20;
|
||||
TIM_BL->CCR2 = ((100-level)*color)/20;
|
||||
BACKLIGHT_TIMER->CCR4 = ((100-level)*(20-color))/20;
|
||||
BACKLIGHT_TIMER->CCR2 = ((100-level)*color)/20;
|
||||
}
|
||||
|
||||
void turnBacklightOff(void)
|
||||
{
|
||||
TIM_BL->CCR4 = 0;
|
||||
TIM_BL->CCR2 = 0;
|
||||
BACKLIGHT_TIMER->CCR4 = 0;
|
||||
BACKLIGHT_TIMER->CCR2 = 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -154,16 +154,16 @@ static void init_pa10_none()
|
|||
|
||||
// Timer1, channel 3
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_INTPPM, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(INTMODULE_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_INTPPM_OUT;
|
||||
GPIO_InitStructure.GPIO_Pin = INTMODULE_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT ;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_INTPPM, &GPIO_InitStructure);
|
||||
GPIO_Init(INTMODULE_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_SetBits(GPIO_INTPPM, PIN_INTPPM_OUT) ; // Set high
|
||||
GPIO_SetBits(INTMODULE_GPIO, INTMODULE_GPIO_PIN) ; // Set high
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN ; // Enable clock
|
||||
|
||||
|
@ -200,16 +200,16 @@ static void init_pa7_none()
|
|||
|
||||
// Timer8
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_EXTPPM, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(EXTMODULE_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_EXTPPM_OUT;
|
||||
GPIO_InitStructure.GPIO_Pin = EXTMODULE_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT ;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_EXTPPM, &GPIO_InitStructure);
|
||||
GPIO_Init(EXTMODULE_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_SetBits(GPIO_EXTPPM, PIN_EXTPPM_OUT) ; // Set high
|
||||
GPIO_SetBits(EXTMODULE_GPIO, EXTMODULE_GPIO_PIN) ; // Set high
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM8EN ; // Enable clock
|
||||
|
||||
|
@ -245,15 +245,15 @@ static void init_pa10_pxx()
|
|||
|
||||
// RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN ; // Enable portA clock
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_INTPPM, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(INTMODULE_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
|
||||
GPIO_PinAFConfig(GPIO_INTPPM, GPIO_PinSource_INTPPM, GPIO_AF_TIM1);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_INTPPM_OUT;
|
||||
GPIO_PinAFConfig(INTMODULE_GPIO, INTMODULE_GPIO_PinSource, GPIO_AF_TIM1);
|
||||
GPIO_InitStructure.GPIO_Pin = INTMODULE_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_INTPPM, &GPIO_InitStructure);
|
||||
GPIO_Init(INTMODULE_GPIO, &GPIO_InitStructure);
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN ; // Enable clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN ; // Enable DMA2 clock
|
||||
|
@ -262,21 +262,15 @@ static void init_pa10_pxx()
|
|||
TIM1->ARR = 18000 ; // 9mS
|
||||
TIM1->CCR2 = 15000 ; // Update time
|
||||
TIM1->PSC = (PERI2_FREQUENCY * TIMER_MULT_APB2) / 2000000 - 1 ; // 0.5uS from 30MHz
|
||||
|
||||
TIM1->CCER = TIM_CCER_CC3E ;
|
||||
|
||||
TIM1->CR2 = TIM_CR2_OIS3 ; // O/P idle high
|
||||
TIM1->BDTR = TIM_BDTR_MOE ; // Enable outputs
|
||||
TIM1->CCR3 = modulePulsesData[INTERNAL_MODULE].pxx.pulses[0];
|
||||
TIM1->CCMR2 = TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3M_0 ; // Force O/P high
|
||||
TIM1->EGR = 1 ; // Restart
|
||||
|
||||
// TIM1->SR &= ~TIM_SR_UIF ; // Clear flag
|
||||
// TIM1->SR &= ~TIM_SR_CC2IF ; // Clear flag
|
||||
TIM1->DIER |= TIM_DIER_CC3DE ; // Enable DMA on CC3 match
|
||||
TIM1->DCR = 15 ; // DMA to CC1
|
||||
|
||||
// TIM1->CR1 = TIM_CR1_OPM ; // Just run once
|
||||
// Enable the DMA channel here, DMA2 stream 6, channel 6
|
||||
DMA2_Stream6->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
DMA2->HIFCR = DMA_HIFCR_CTCIF6 | DMA_HIFCR_CHTIF6 | DMA_HIFCR_CTEIF6 | DMA_HIFCR_CDMEIF6 | DMA_HIFCR_CFEIF6 ; // Write ones to clear bits
|
||||
|
@ -284,8 +278,6 @@ static void init_pa10_pxx()
|
|||
| DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC | DMA_SxCR_DIR_0 | DMA_SxCR_PFCTRL ;
|
||||
DMA2_Stream6->PAR = CONVERT_PTR_UINT(&TIM1->DMAR);
|
||||
DMA2_Stream6->M0AR = CONVERT_PTR_UINT(&modulePulsesData[INTERNAL_MODULE].pxx.pulses[1]);
|
||||
// DMA2_Stream2->FCR = 0x05 ; //DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
||||
// DMA2_Stream2->NDTR = 100 ;
|
||||
DMA2_Stream6->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
|
||||
TIM1->CCMR2 = TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_0 ; // Toggle CC1 o/p
|
||||
|
@ -316,9 +308,9 @@ static void init_pa10_ppm()
|
|||
modulePulsesData[INTERNAL_MODULE].ppm.ptr = modulePulsesData[INTERNAL_MODULE].ppm.pulses;
|
||||
|
||||
//RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN ; // Enable portA clock
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_INTPPM, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(INTMODULE_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
|
||||
configure_pins( PIN_INTPPM_OUT, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_1 | PIN_OS25) ;
|
||||
configure_pins( INTMODULE_GPIO_PIN, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_1 | PIN_OS25) ;
|
||||
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN ; // Enable clock
|
||||
TIM1->CR1 &= ~TIM_CR1_CEN ;
|
||||
|
@ -412,14 +404,14 @@ void init_pa7_pxx()
|
|||
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN ; // Enable portA clock
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_EXTPPM, ENABLE);
|
||||
GPIO_PinAFConfig(GPIO_EXTPPM, GPIO_PinSource_EXTPPM, GPIO_AF_TIM8);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_EXTPPM_OUT;
|
||||
RCC_AHB1PeriphClockCmd(EXTMODULE_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
GPIO_PinAFConfig(EXTMODULE_GPIO, EXTMODULE_GPIO_PinSource, GPIO_AF_TIM8);
|
||||
GPIO_InitStructure.GPIO_Pin = EXTMODULE_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_EXTPPM, &GPIO_InitStructure);
|
||||
GPIO_Init(EXTMODULE_GPIO, &GPIO_InitStructure);
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM8EN ; // Enable clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN ; // Enable DMA2 clock
|
||||
|
||||
|
@ -480,14 +472,14 @@ static void init_pa7_dsm2()
|
|||
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN ; // Enable portA clock
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_EXTPPM, ENABLE);
|
||||
GPIO_PinAFConfig(GPIO_EXTPPM, GPIO_PinSource_EXTPPM, GPIO_AF_TIM8);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_EXTPPM_OUT;
|
||||
RCC_AHB1PeriphClockCmd(EXTMODULE_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
GPIO_PinAFConfig(EXTMODULE_GPIO, EXTMODULE_GPIO_PinSource, GPIO_AF_TIM8);
|
||||
GPIO_InitStructure.GPIO_Pin = EXTMODULE_GPIO_PIN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_EXTPPM, &GPIO_InitStructure);
|
||||
GPIO_Init(EXTMODULE_GPIO, &GPIO_InitStructure);
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM8EN ; // Enable clock
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN ; // Enable DMA2 clock
|
||||
|
||||
|
@ -550,7 +542,7 @@ static void init_pa7_ppm()
|
|||
modulePulsesData[EXTERNAL_MODULE].ppm.ptr = modulePulsesData[EXTERNAL_MODULE].ppm.pulses;
|
||||
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN ; // Enable portA clock
|
||||
configure_pins( PIN_EXTPPM_OUT, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_3 | PIN_OS25) ;
|
||||
configure_pins( EXTMODULE_GPIO_PIN, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_3 | PIN_OS25) ;
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM8EN ; // Enable clock
|
||||
TIM8->CR1 &= ~TIM_CR1_CEN ;
|
||||
|
||||
|
|
|
@ -44,40 +44,40 @@ void pwrInit()
|
|||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
/* GPIOC GPIOD clock enable */
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOPWR, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
|
||||
/* GPIO Configuration*/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_MCU_PWR;
|
||||
GPIO_InitStructure.GPIO_Pin = PWR_GPIO_PIN_ON;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(GPIOPWR, &GPIO_InitStructure);
|
||||
GPIO_Init(PWR_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_PWR_STATUS;
|
||||
GPIO_InitStructure.GPIO_Pin = PWR_GPIO_PIN_SWITCH;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_Init(GPIOPWR, &GPIO_InitStructure);
|
||||
GPIO_Init(PWR_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_PWR_LED;
|
||||
GPIO_InitStructure.GPIO_Pin = PWR_GPIO_PIN_LED;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_Init(GPIOPWRLED, &GPIO_InitStructure);
|
||||
GPIO_Init(PWR_GPIO_LED, &GPIO_InitStructure);
|
||||
|
||||
GPIO_ResetBits(GPIO_INT_RF_PWR, PIN_INT_RF_PWR);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_INT_RF_PWR;
|
||||
GPIO_ResetBits(INTMODULE_GPIO_PWR, INTMODULE_GPIO_PIN_PWR);
|
||||
GPIO_InitStructure.GPIO_Pin = INTMODULE_GPIO_PIN_PWR;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_Init(GPIO_INT_RF_PWR, &GPIO_InitStructure);
|
||||
GPIO_Init(INTMODULE_GPIO_PWR, &GPIO_InitStructure);
|
||||
|
||||
GPIO_ResetBits(GPIO_EXT_RF_PWR, PIN_EXT_RF_PWR);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_EXT_RF_PWR;
|
||||
GPIO_ResetBits(EXTMODULE_GPIO_PWR, EXTMODULE_GPIO_PIN_PWR);
|
||||
GPIO_InitStructure.GPIO_Pin = EXTMODULE_GPIO_PIN_PWR;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_Init(GPIO_EXT_RF_PWR, &GPIO_InitStructure);
|
||||
GPIO_Init(EXTMODULE_GPIO_PWR, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_TRNDET;
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_GPIO_PIN_DETECT;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_Init(GPIOTRNDET, &GPIO_InitStructure);
|
||||
GPIO_Init(TRAINER_GPIO_DETECT, &GPIO_InitStructure);
|
||||
|
||||
// Soft power ON
|
||||
GPIO_SetBits(GPIOPWR, PIN_MCU_PWR);
|
||||
GPIO_SetBits(PWR_GPIO, PWR_GPIO_PIN_ON);
|
||||
|
||||
#if defined(REV9E)
|
||||
while (pwrPressed()) ;
|
||||
|
@ -86,7 +86,7 @@ void pwrInit()
|
|||
|
||||
void pwrOff()
|
||||
{
|
||||
GPIO_ResetBits(GPIOPWR, PIN_MCU_PWR);
|
||||
GPIO_ResetBits(PWR_GPIO, PWR_GPIO_PIN_ON);
|
||||
#if defined(REV9E)
|
||||
// 9E needs watchdog reset because CPU is still running while the power
|
||||
// key is held pressed by the user
|
||||
|
@ -99,7 +99,7 @@ void pwrOff()
|
|||
#if defined(REV9E)
|
||||
uint32_t pwrPressed()
|
||||
{
|
||||
return GPIO_ReadInputDataBit(GPIOPWR, PIN_PWR_STATUS) == Bit_RESET;
|
||||
return GPIO_ReadInputDataBit(PWR_GPIO, PWR_GPIO_PIN_SWITCH) == Bit_RESET;
|
||||
}
|
||||
#if !defined(BOOT)
|
||||
uint32_t pwrPressTime = 0;
|
||||
|
@ -136,7 +136,7 @@ uint32_t pwrCheck()
|
|||
#if defined(SIMU)
|
||||
return e_power_on;
|
||||
#else
|
||||
if (GPIO_ReadInputDataBit(GPIOPWR, PIN_PWR_STATUS) == Bit_RESET)
|
||||
if (GPIO_ReadInputDataBit(PWR_GPIO, PWR_GPIO_PIN_SWITCH) == Bit_RESET)
|
||||
return e_power_on;
|
||||
else if (usbPlugged())
|
||||
return e_power_usb;
|
||||
|
|
|
@ -41,35 +41,34 @@ extern Fifo<512> telemetryFifo;
|
|||
void telemetryPortInit(uint32_t baudrate)
|
||||
{
|
||||
if (baudrate == 0) {
|
||||
USART_DeInit(SPORT_USART);
|
||||
USART_DeInit(TELEMETRY_USART);
|
||||
return;
|
||||
}
|
||||
|
||||
USART_InitTypeDef USART_InitStructure;
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_SPORT, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(TELEMETRY_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
|
||||
GPIO_PinAFConfig(GPIO_PIN_SPORT_TXRX, GPIO_PinSource_SPORT_RX, GPIO_AF_SPORT);
|
||||
GPIO_PinAFConfig(GPIO_PIN_SPORT_TXRX, GPIO_PinSource_SPORT_TX, GPIO_AF_SPORT);
|
||||
GPIO_PinAFConfig(TELEMETRY_GPIO, TELEMETRY_GPIO_PinSource_RX, TELEMETRY_GPIO_AF);
|
||||
GPIO_PinAFConfig(TELEMETRY_GPIO, TELEMETRY_GPIO_PinSource_TX, TELEMETRY_GPIO_AF);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SPORT_TX | PIN_SPORT_RX;
|
||||
GPIO_InitStructure.GPIO_Pin = TELEMETRY_GPIO_PIN_TX | TELEMETRY_GPIO_PIN_RX;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIO_PIN_SPORT_TXRX, &GPIO_InitStructure);
|
||||
GPIO_Init(TELEMETRY_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SPORT_ON;
|
||||
GPIO_InitStructure.GPIO_Pin = TELEMETRY_GPIO_PIN_DIR;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIO_PIN_SPORT_ON, &GPIO_InitStructure);
|
||||
GPIO_Init(TELEMETRY_GPIO_DIR, &GPIO_InitStructure);
|
||||
GPIO_ResetBits(TELEMETRY_GPIO_DIR, TELEMETRY_GPIO_PIN_DIR);
|
||||
|
||||
GPIO_ResetBits(GPIO_PIN_SPORT_ON, PIN_SPORT_ON);
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPORT, ENABLE);
|
||||
RCC_APB1PeriphClockCmd(TELEMETRY_RCC_APB1Periph_USART, ENABLE);
|
||||
|
||||
USART_InitStructure.USART_BaudRate = baudrate;
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||
|
@ -78,12 +77,12 @@ void telemetryPortInit(uint32_t baudrate)
|
|||
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||
|
||||
USART_Init(SPORT_USART, &USART_InitStructure);
|
||||
USART_Cmd(SPORT_USART, ENABLE);
|
||||
USART_ITConfig(SPORT_USART, USART_IT_RXNE, ENABLE);
|
||||
USART_Init(TELEMETRY_USART, &USART_InitStructure);
|
||||
USART_Cmd(TELEMETRY_USART, ENABLE);
|
||||
USART_ITConfig(TELEMETRY_USART, USART_IT_RXNE, ENABLE);
|
||||
|
||||
NVIC_SetPriority(SPORT_IRQn, 6);
|
||||
NVIC_EnableIRQ(SPORT_IRQn);
|
||||
NVIC_SetPriority(TELEMETRY_USART_IRQn, 6);
|
||||
NVIC_EnableIRQ(TELEMETRY_USART_IRQn);
|
||||
}
|
||||
|
||||
struct SportTxBuffer
|
||||
|
@ -96,47 +95,47 @@ void sportSendBuffer(uint8_t *buffer, uint32_t count)
|
|||
{
|
||||
sportTxBuffer.ptr = buffer ;
|
||||
sportTxBuffer.count = count ;
|
||||
GPIO_PIN_SPORT_ON->BSRRL = PIN_SPORT_ON ; // output enable
|
||||
SPORT_USART->CR1 &= ~USART_CR1_RE ; // turn off receiver
|
||||
SPORT_USART->CR1 |= USART_CR1_TXEIE ;
|
||||
TELEMETRY_GPIO_DIR->BSRRL = TELEMETRY_GPIO_PIN_DIR ; // output enable
|
||||
TELEMETRY_USART->CR1 &= ~USART_CR1_RE ; // turn off receiver
|
||||
TELEMETRY_USART->CR1 |= USART_CR1_TXEIE ;
|
||||
}
|
||||
|
||||
#if !defined(SIMU)
|
||||
#define USART_FLAG_ERRORS (USART_FLAG_ORE | USART_FLAG_NE | USART_FLAG_FE | USART_FLAG_PE)
|
||||
|
||||
extern "C" void SPORT_IRQHandler()
|
||||
extern "C" void TELEMETRY_USART_IRQHandler()
|
||||
{
|
||||
uint32_t status;
|
||||
uint8_t data;
|
||||
|
||||
status = SPORT_USART->SR;
|
||||
status = TELEMETRY_USART->SR;
|
||||
|
||||
if (status & USART_SR_TXE) {
|
||||
if (sportTxBuffer.count) {
|
||||
SPORT_USART->DR = *sportTxBuffer.ptr++;
|
||||
TELEMETRY_USART->DR = *sportTxBuffer.ptr++;
|
||||
if (--sportTxBuffer.count == 0) {
|
||||
SPORT_USART->CR1 &= ~USART_CR1_TXEIE; // stop Tx interrupt
|
||||
SPORT_USART->CR1 |= USART_CR1_TCIE; // enable complete interrupt
|
||||
TELEMETRY_USART->CR1 &= ~USART_CR1_TXEIE; // stop Tx interrupt
|
||||
TELEMETRY_USART->CR1 |= USART_CR1_TCIE; // enable complete interrupt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((status & USART_SR_TC) && (SPORT_USART->CR1 & USART_CR1_TCIE)) {
|
||||
SPORT_USART->CR1 &= ~USART_CR1_TCIE ; // stop Complete interrupt
|
||||
GPIO_PIN_SPORT_ON->BSRRH = PIN_SPORT_ON ; // output disable
|
||||
SPORT_USART->CR1 |= USART_CR1_RE ;
|
||||
if ((status & USART_SR_TC) && (TELEMETRY_USART->CR1 & USART_CR1_TCIE)) {
|
||||
TELEMETRY_USART->CR1 &= ~USART_CR1_TCIE ; // stop Complete interrupt
|
||||
TELEMETRY_GPIO_DIR->BSRRH = TELEMETRY_GPIO_PIN_DIR ; // output disable
|
||||
TELEMETRY_USART->CR1 |= USART_CR1_RE ;
|
||||
while (status & (USART_FLAG_RXNE)) {
|
||||
status = SPORT_USART->DR;
|
||||
status = SPORT_USART->SR ;
|
||||
status = TELEMETRY_USART->DR;
|
||||
status = TELEMETRY_USART->SR ;
|
||||
}
|
||||
}
|
||||
|
||||
while (status & (USART_FLAG_RXNE | USART_FLAG_ERRORS)) {
|
||||
data = SPORT_USART->DR;
|
||||
data = TELEMETRY_USART->DR;
|
||||
if (!(status & USART_FLAG_ERRORS)) {
|
||||
telemetryFifo.push(data);
|
||||
}
|
||||
status = SPORT_USART->SR;
|
||||
status = TELEMETRY_USART->SR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,17 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define CS1_HIGH() TOPLCD_GPIO->BSRRL = TOPLCD_GPIO_PIN_CS1
|
||||
#define CS1_LOW() TOPLCD_GPIO->BSRRH = TOPLCD_GPIO_PIN_CS1
|
||||
#define CS2_HIGH() TOPLCD_GPIO->BSRRL = TOPLCD_GPIO_PIN_CS2
|
||||
#define CS2_LOW() TOPLCD_GPIO->BSRRH = TOPLCD_GPIO_PIN_CS2
|
||||
#define WR_HIGH() TOPLCD_GPIO->BSRRL = TOPLCD_GPIO_PIN_WR
|
||||
#define WR_LOW() TOPLCD_GPIO->BSRRH = TOPLCD_GPIO_PIN_WR
|
||||
#define DATA_HIGH() TOPLCD_GPIO->BSRRL = TOPLCD_GPIO_PIN_DATA
|
||||
#define DATA_LOW() TOPLCD_GPIO->BSRRH = TOPLCD_GPIO_PIN_DATA
|
||||
#define BL_ON() TOPLCD_GPIO->BSRRL = TOPLCD_GPIO_PIN_BL
|
||||
#define BL_OFF() TOPLCD_GPIO->BSRRH = TOPLCD_GPIO_PIN_BL
|
||||
|
||||
const uint8_t TimeLCDsegs[] = { 0xAF, 0x06, 0x6D, 0x4F, 0xC6, 0xCB, 0xEB, 0x0E, 0xEF, 0xCF };
|
||||
const uint8_t RssiLCDsegs[] = { 0xFA, 0x60, 0xBC, 0xF4, 0x66, 0xD6, 0xDE, 0x70, 0xFE, 0xF6 };
|
||||
const uint8_t OpTimeLCDsegs[] = { 0x5F, 0x06, 0x6B, 0x2F, 0x36, 0x3D, 0x7D, 0x07, 0x7F, 0x3F };
|
||||
|
@ -49,57 +60,57 @@ void delay1_7us()
|
|||
void ht1621SendCommand(uint8_t chip, unsigned char command)
|
||||
{
|
||||
if (chip)
|
||||
CS2_LOW;
|
||||
CS2_LOW();
|
||||
else
|
||||
CS1_LOW;
|
||||
CS1_LOW();
|
||||
|
||||
delay1_7us();
|
||||
WR_LOW; //PRESENT 100 COMMAND CODE
|
||||
WR_LOW(); //PRESENT 100 COMMAND CODE
|
||||
delay1_7us();
|
||||
DATA_HIGH;
|
||||
DATA_HIGH();
|
||||
delay1_7us();
|
||||
WR_HIGH;
|
||||
WR_HIGH();
|
||||
delay1_7us();
|
||||
WR_LOW;
|
||||
WR_LOW();
|
||||
delay1_7us();
|
||||
DATA_LOW;
|
||||
DATA_LOW();
|
||||
delay1_7us();
|
||||
WR_HIGH;
|
||||
WR_HIGH();
|
||||
delay1_7us();
|
||||
|
||||
WR_LOW;
|
||||
WR_LOW();
|
||||
delay1_7us();
|
||||
DATA_LOW;
|
||||
DATA_LOW();
|
||||
delay1_7us();
|
||||
WR_HIGH;
|
||||
WR_HIGH();
|
||||
delay1_7us();
|
||||
|
||||
for (int i=0; i<8; i++) {
|
||||
WR_LOW;
|
||||
WR_LOW();
|
||||
delay1_7us();
|
||||
if ((command & 0x80) !=0)
|
||||
{
|
||||
DATA_HIGH;
|
||||
DATA_HIGH();
|
||||
delay1_7us();
|
||||
}
|
||||
else
|
||||
{
|
||||
DATA_LOW;
|
||||
DATA_LOW();
|
||||
delay1_7us();
|
||||
}
|
||||
WR_HIGH;
|
||||
WR_HIGH();
|
||||
delay1_7us();
|
||||
command = command << 1;
|
||||
}
|
||||
WR_LOW;
|
||||
WR_LOW();
|
||||
delay1_7us();
|
||||
WR_HIGH;
|
||||
WR_HIGH();
|
||||
delay1_7us();
|
||||
|
||||
if (chip)
|
||||
CS2_HIGH;
|
||||
CS2_HIGH();
|
||||
else
|
||||
CS1_HIGH;
|
||||
CS1_HIGH();
|
||||
|
||||
delay1_7us();
|
||||
}
|
||||
|
@ -107,13 +118,13 @@ void ht1621SendCommand(uint8_t chip, unsigned char command)
|
|||
void ht1621WrData(uint8_t data, uint8_t count)
|
||||
{
|
||||
while (count) {
|
||||
WR_LOW;
|
||||
WR_LOW();
|
||||
if (data & 0x80)
|
||||
DATA_HIGH;
|
||||
DATA_HIGH();
|
||||
else
|
||||
DATA_LOW;
|
||||
DATA_LOW();
|
||||
delay1_7us();
|
||||
WR_HIGH;
|
||||
WR_HIGH();
|
||||
delay1_7us();
|
||||
data <<= 1;
|
||||
count -= 1;
|
||||
|
@ -125,11 +136,11 @@ void ht1621WrAllData(uint8_t chip, uint8_t *pData)
|
|||
int len;
|
||||
if (chip) {
|
||||
len = sizeof(Ht1621Data2);
|
||||
CS2_LOW;
|
||||
CS2_LOW();
|
||||
}
|
||||
else {
|
||||
len = sizeof(Ht1621Data1);
|
||||
CS1_LOW;
|
||||
CS1_LOW();
|
||||
}
|
||||
delay1_7us();
|
||||
ht1621WrData(0xa0, 3);
|
||||
|
@ -138,9 +149,9 @@ void ht1621WrAllData(uint8_t chip, uint8_t *pData)
|
|||
ht1621WrData(*pData++, 8);
|
||||
}
|
||||
if (chip)
|
||||
CS2_HIGH;
|
||||
CS2_HIGH();
|
||||
else
|
||||
CS1_HIGH;
|
||||
CS1_HIGH();
|
||||
delay1_7us();
|
||||
}
|
||||
|
||||
|
@ -168,21 +179,21 @@ extern "C" void TIM8_BRK_TIM12_IRQHandler()
|
|||
|
||||
if ( pc->state == TOP_LCD_CKLOW )
|
||||
{
|
||||
WR_LOW ; //PRESENT 100 COMMAND CODE
|
||||
WR_LOW() ; //PRESENT 100 COMMAND CODE
|
||||
if ((*pc->data & 0x80) !=0)
|
||||
{
|
||||
DATA_HIGH ;
|
||||
DATA_HIGH() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
DATA_LOW ;
|
||||
DATA_LOW() ;
|
||||
}
|
||||
*pc->data <<= 1 ;
|
||||
pc->state = TOP_LCD_CKHI ;
|
||||
}
|
||||
else if ( pc->state == TOP_LCD_CKHI )
|
||||
{
|
||||
WR_HIGH ;
|
||||
WR_HIGH() ;
|
||||
if ( --pc->count == 0 )
|
||||
{
|
||||
pc->state = TOP_LCD_END ;
|
||||
|
@ -196,13 +207,13 @@ extern "C" void TIM8_BRK_TIM12_IRQHandler()
|
|||
{
|
||||
if ( pc->chip )
|
||||
{
|
||||
CS2_HIGH ;
|
||||
CS2_HIGH() ;
|
||||
pc->state = TOP_LCD_IDLE ;
|
||||
TIM12->DIER &= ~1 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
CS1_HIGH ;
|
||||
CS1_HIGH() ;
|
||||
pc->chip = 1 ;
|
||||
pc->data = pc->data2 ;
|
||||
pc->count = pc->count2 ;
|
||||
|
@ -211,19 +222,19 @@ extern "C" void TIM8_BRK_TIM12_IRQHandler()
|
|||
}
|
||||
else if ( pc->state == TOP_LCD_IDLE )
|
||||
{
|
||||
WR_HIGH;
|
||||
if ( pc->chip ) CS2_LOW ; else CS1_LOW ;
|
||||
WR_HIGH();
|
||||
if ( pc->chip ) CS2_LOW() ; else CS1_LOW() ;
|
||||
pc->state = TOP_LCD_1CKLOW ;
|
||||
}
|
||||
else if ( pc->state == TOP_LCD_1CKLOW )
|
||||
{
|
||||
WR_LOW ;
|
||||
DATA_HIGH ; // First 1 bit
|
||||
WR_LOW() ;
|
||||
DATA_HIGH() ; // First 1 bit
|
||||
pc->state = TOP_LCD_1CKHI ;
|
||||
}
|
||||
else if ( pc->state == TOP_LCD_1CKHI )
|
||||
{
|
||||
WR_HIGH ;
|
||||
WR_HIGH() ;
|
||||
if ( --pc->count == 0 )
|
||||
{
|
||||
pc->state = TOP_LCD_END ;
|
||||
|
@ -238,16 +249,16 @@ extern "C" void TIM8_BRK_TIM12_IRQHandler()
|
|||
|
||||
void topLcdInit()
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_VA, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(TOPLCD_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_VA_DATA | PIN_VA_WR |PIN_VA_BL|PIN_VA_CS|PIN_VA_CS2;
|
||||
GPIO_InitStructure.GPIO_Pin = TOPLCD_GPIO_PIN_DATA | TOPLCD_GPIO_PIN_WR |TOPLCD_GPIO_PIN_BL|TOPLCD_GPIO_PIN_CS1|TOPLCD_GPIO_PIN_CS2;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(GPIO_VA, &GPIO_InitStructure);
|
||||
GPIO_Init(TOPLCD_GPIO, &GPIO_InitStructure);
|
||||
|
||||
VA_BL_ON;
|
||||
BL_ON();
|
||||
|
||||
ht1621SendCommand(0, 0x03);
|
||||
ht1621SendCommand(0, 0x01);
|
||||
|
@ -263,7 +274,7 @@ void topLcdInit()
|
|||
|
||||
void topLcdOff()
|
||||
{
|
||||
VA_BL_OFF;
|
||||
BL_OFF();
|
||||
topLcdRefreshStart();
|
||||
topLcdRefreshEnd();
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ void init_trainer_ppm()
|
|||
trainerPulsesData.ppm.ptr = trainerPulsesData.ppm.pulses;
|
||||
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN ; // Enable portC clock
|
||||
configure_pins( PIN_TR_PPM_OUT, PIN_PERIPHERAL | PIN_PORTC | PIN_PER_2 | PIN_OS25) ;
|
||||
configure_pins( PIN_TR_PPM_IN, PIN_PORTA | PIN_INPUT ) ;
|
||||
configure_pins( TRAINER_GPIO_PIN_OUT, PIN_PERIPHERAL | PIN_PORTC | PIN_PER_2 | PIN_OS25) ;
|
||||
configure_pins( TRAINER_GPIO_PIN_IN, PIN_PORTA | PIN_INPUT ) ;
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN ; // Enable clock
|
||||
TIM3->CR1 &= ~TIM_CR1_CEN ;
|
||||
|
||||
|
@ -74,7 +74,7 @@ void init_trainer_ppm()
|
|||
// TODO - testing
|
||||
void stop_trainer_ppm()
|
||||
{
|
||||
configure_pins( PIN_TR_PPM_OUT, PIN_INPUT | PIN_PORTC ) ; // Pin as input
|
||||
configure_pins( TRAINER_GPIO_PIN_OUT, PIN_INPUT | PIN_PORTC ) ; // Pin as input
|
||||
TIM3->DIER = 0 ; // Stop Interrupt
|
||||
TIM3->CR1 &= ~TIM_CR1_CEN ; // Stop counter
|
||||
NVIC_DisableIRQ(TIM3_IRQn) ; // Stop Interrupt
|
||||
|
@ -93,13 +93,13 @@ void init_trainer_capture()
|
|||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_TR_PPM_IN;
|
||||
GPIO_InitStructure.GPIO_Pin = TRAINER_GPIO_PIN_IN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIO_TR_INOUT, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(GPIO_TR_INOUT, GPIO_PinSource8, GPIO_AF_TIM3);
|
||||
GPIO_Init(TRAINER_GPIO, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(TRAINER_GPIO, GPIO_PinSource8, GPIO_AF_TIM3);
|
||||
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN ;
|
||||
TIM3->ARR = 0xFFFF ;
|
||||
|
|
|
@ -46,19 +46,19 @@ void uart3Setup(unsigned int baudrate)
|
|||
USART_InitTypeDef USART_InitStructure;
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_UART3, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(SERIAL_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
|
||||
GPIO_PinAFConfig(GPIO_UART3, GPIO_PinSource_UART3_RX, GPIO_AF_UART3);
|
||||
GPIO_PinAFConfig(GPIO_UART3, GPIO_PinSource_UART3_TX, GPIO_AF_UART3);
|
||||
GPIO_PinAFConfig(SERIAL_GPIO, SERIAL_GPIO_PinSource_RX, SERIAL_GPIO_AF);
|
||||
GPIO_PinAFConfig(SERIAL_GPIO, SERIAL_GPIO_PinSource_TX, SERIAL_GPIO_AF);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_UART3_TX | GPIO_PIN_UART3_RX;
|
||||
GPIO_InitStructure.GPIO_Pin = SERIAL_GPIO_PIN_TX | SERIAL_GPIO_PIN_RX;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIO_UART3, &GPIO_InitStructure);
|
||||
GPIO_Init(SERIAL_GPIO, &GPIO_InitStructure);
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART3, ENABLE);
|
||||
RCC_APB1PeriphClockCmd(SERIAL_RCC_APB1Periph_USART, ENABLE);
|
||||
|
||||
USART_InitStructure.USART_BaudRate = baudrate;
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||
|
@ -67,11 +67,11 @@ void uart3Setup(unsigned int baudrate)
|
|||
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||
|
||||
USART_Init(UART3, &USART_InitStructure);
|
||||
USART_Cmd(UART3, ENABLE);
|
||||
USART_Init(SERIAL_USART, &USART_InitStructure);
|
||||
USART_Cmd(SERIAL_USART, ENABLE);
|
||||
|
||||
USART_ITConfig(UART3, USART_IT_RXNE, ENABLE);
|
||||
USART_ITConfig(UART3, USART_IT_TXE, DISABLE);
|
||||
USART_ITConfig(SERIAL_USART, USART_IT_RXNE, ENABLE);
|
||||
USART_ITConfig(SERIAL_USART, USART_IT_TXE, DISABLE);
|
||||
|
||||
NVIC_SetPriority(USART3_IRQn, 7);
|
||||
NVIC_EnableIRQ(USART3_IRQn);
|
||||
|
@ -105,7 +105,7 @@ void uart3Init(unsigned int mode, unsigned int protocol)
|
|||
void uart3Putc(const char c)
|
||||
{
|
||||
uart3TxFifo.push(c);
|
||||
USART_ITConfig(UART3, USART_IT_TXE, ENABLE);
|
||||
USART_ITConfig(SERIAL_USART, USART_IT_TXE, ENABLE);
|
||||
}
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
@ -132,14 +132,14 @@ void uart3Stop()
|
|||
extern "C" void USART3_IRQHandler(void)
|
||||
{
|
||||
// Send
|
||||
if (USART_GetITStatus(UART3, USART_IT_TXE) != RESET) {
|
||||
if (USART_GetITStatus(SERIAL_USART, USART_IT_TXE) != RESET) {
|
||||
uint8_t txchar;
|
||||
if (uart3TxFifo.pop(txchar)) {
|
||||
/* Write one byte to the transmit data register */
|
||||
USART_SendData(UART3, txchar);
|
||||
USART_SendData(SERIAL_USART, txchar);
|
||||
}
|
||||
else {
|
||||
USART_ITConfig(UART3, USART_IT_TXE, DISABLE);
|
||||
USART_ITConfig(SERIAL_USART, USART_IT_TXE, DISABLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,39 +45,27 @@ void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)
|
|||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA , ENABLE);
|
||||
|
||||
/* Configure SOF ID DM DP Pins */
|
||||
GPIO_InitStructure.GPIO_Pin = // GPIO_Pin_8 |
|
||||
GPIO_Pin_11 |
|
||||
GPIO_Pin_12;
|
||||
RCC_AHB1PeriphClockCmd(USB_RCC_AHB1Periph_GPIO, ENABLE);
|
||||
|
||||
/* Configure DM and DP Pins */
|
||||
GPIO_InitStructure.GPIO_Pin = USB_GPIO_PIN_DM | USB_GPIO_PIN_DP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(USB_GPIO, &GPIO_InitStructure);
|
||||
|
||||
//GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_OTG1_FS) ;
|
||||
GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_OTG1_FS) ;
|
||||
GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_OTG1_FS) ;
|
||||
GPIO_PinAFConfig(USB_GPIO, USB_GPIO_PinSource_DM, USB_GPIO_AF);
|
||||
GPIO_PinAFConfig(USB_GPIO, USB_GPIO_PinSource_DP, USB_GPIO_AF);
|
||||
|
||||
/* Configure VBUS Pin */
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
|
||||
/* Configure VBUS Pin */
|
||||
GPIO_InitStructure.GPIO_Pin = USB_GPIO_PIN_VBUS;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
GPIO_Init(USB_GPIO, &GPIO_InitStructure);
|
||||
|
||||
/* // Configure ID pin
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_OTG1_FS) ;
|
||||
*/
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
|
||||
RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE) ;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ int usbPlugged(void)
|
|||
static uint8_t debounced_state = 0;
|
||||
static uint8_t last_state = 0;
|
||||
|
||||
if ( GPIO_ReadInputDataBit(GPIOA, PIN_FS_VBUS) ) {
|
||||
if ( GPIO_ReadInputDataBit(USB_GPIO, USB_GPIO_PIN_VBUS) ) {
|
||||
if (last_state) debounced_state = 1;
|
||||
last_state = 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue