[X9D] Makefile option added: CPUARM
[Sky9x] GVARS Bug in EEPROM [Sky9x] Mu-law codec added
This commit is contained in:
+3
-3
@@ -9,7 +9,7 @@
|
||||
#ifndef _FFCONF
|
||||
#define _FFCONF 6502 /* Revision ID */
|
||||
|
||||
#if defined(PCBSKY9X) && !defined(SIMU)
|
||||
#if defined(CPUARM) && !defined(SIMU)
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -98,7 +98,7 @@ extern "C" {
|
||||
/ 1 - ASCII only (Valid for non LFN cfg.)
|
||||
*/
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define _USE_LFN 2 /* 0 to 3 */
|
||||
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
|
||||
#else
|
||||
@@ -184,7 +184,7 @@ extern "C" {
|
||||
/* A header file that defines sync object types on the O/S, such as
|
||||
/ windows.h, ucos_ii.h and semphr.h, must be included prior to ff.h. */
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define _FS_REENTRANT 1 /* 0:Disable or 1:Enable */
|
||||
#else
|
||||
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
|
||||
|
||||
+4
-4
@@ -449,10 +449,10 @@ RUN_FROM_FLASH = 1
|
||||
ifeq ($(PCB), X9D)
|
||||
# X9D, so ...
|
||||
OPT = 2
|
||||
CPPDEFS += -DPCBX9D -DPCBSKY9X -DREVB -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 -DLCD212
|
||||
CPPDEFS += -DPCBX9D -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM -DROTARY_ENCODERS=1 -DLCD212
|
||||
EXTRAINCDIRS += sky9x CoOS/kernel CoOS/portable
|
||||
BOARDSRC = board_sky9x.cpp
|
||||
EXTRABOARDSRC += sky9x/lcd_driver.cpp
|
||||
BOARDSRC = board_x9d.cpp
|
||||
EXTRABOARDSRC += x9d/lcd_driver.cpp
|
||||
SRC += sky9x/core_cm3.c sky9x/board_lowlevel.c sky9x/crt.c sky9x/vectors_sam3s.c
|
||||
SRC += CoOS/kernel/core.c CoOS/kernel/hook.c CoOS/kernel/task.c CoOS/kernel/event.c CoOS/kernel/time.c CoOS/kernel/timer.c CoOS/kernel/flag.c CoOS/kernel/mutex.c CoOS/kernel/serviceReq.c CoOS/portable/GCC/port.c CoOS/portable/arch.c
|
||||
SRC += sky9x/usb/device/core/USBD_UDP.c sky9x/usb/device/core/USBDDriver.c
|
||||
@@ -462,7 +462,7 @@ ifeq ($(PCB), X9D)
|
||||
EEPROMSRC = eeprom_arm.cpp eeprom_conversions.cpp
|
||||
PULSESSRC = pulses_arm.cpp
|
||||
CPPSRC += sky9x/audio.cpp haptic.cpp
|
||||
CPPSRC += sky9x/sound_driver.cpp sky9x/haptic_driver.cpp sky9x/sdcard_driver.cpp
|
||||
CPPSRC += sky9x/sound_driver.cpp sky9x/sdcard_driver.cpp
|
||||
CPPSRC += bmp.cpp monitors_views.cpp
|
||||
|
||||
ifeq ($(SDCARD), YES)
|
||||
|
||||
+6
-5
@@ -44,13 +44,14 @@ extern bool warbleC;
|
||||
extern uint8_t hapticTick;
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#include "sky9x/sound.h"
|
||||
inline void _beep(uint8_t b) {
|
||||
#if defined(CPUARM)
|
||||
inline void _beep(uint8_t b)
|
||||
{
|
||||
buzzer_sound(b);
|
||||
}
|
||||
#else
|
||||
inline void _beep(uint8_t b) {
|
||||
inline void _beep(uint8_t b)
|
||||
{
|
||||
g_beepCnt = b;
|
||||
}
|
||||
#endif
|
||||
@@ -86,7 +87,7 @@ extern void beep(uint8_t val);
|
||||
#define IS_AUDIO_BUSY() (g_beepCnt || beepAgain || beepOn)
|
||||
#define AUDIO_RESET()
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
inline void AUDIO_HEARTBEAT()
|
||||
{
|
||||
if(g_beepCnt) {
|
||||
|
||||
+3
-130
@@ -751,7 +751,7 @@ void board_init()
|
||||
|
||||
startSound() ;
|
||||
|
||||
alawInit();
|
||||
codecsInit();
|
||||
|
||||
eeprom_init();
|
||||
|
||||
@@ -760,7 +760,6 @@ void board_init()
|
||||
init_SDcard();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// keys:
|
||||
@@ -779,21 +778,8 @@ uint32_t read_keys()
|
||||
|
||||
x = lcdLock ? lcdInputs : PIOC->PIO_PDSR; // 6 LEFT, 5 RIGHT, 4 DOWN, 3 UP ()
|
||||
x <<= 1;
|
||||
#if defined(PCBX9D)
|
||||
y = 0;
|
||||
if (x & 0x00000020)
|
||||
y |= 0x02 << KEY_PLUS;
|
||||
if (x & 0x00000004)
|
||||
y |= 0x02 << KEY_MENU;
|
||||
if (x & 0x00000010)
|
||||
y |= 0x02 << KEY_MINUS;
|
||||
if (x & 0x00000040)
|
||||
y |= 0x02 << KEY_PAGE;
|
||||
if (x & 0x02000000)
|
||||
y |= 0x02 << KEY_EXIT;
|
||||
if (PIOB->PIO_PDSR & 0x000000020)
|
||||
y |= 0x02 << KEY_ENTER;
|
||||
#elif defined(REVA)
|
||||
|
||||
#if defined(REVA)
|
||||
y = (x & 0x00000060);
|
||||
if (x & 0x00000008)
|
||||
y |= 0x10;
|
||||
@@ -898,118 +884,6 @@ uint8_t keyDown()
|
||||
return ~read_keys() & 0x7E ;
|
||||
}
|
||||
|
||||
#if defined(PCBX9D)
|
||||
extern uint32_t keyState(EnumKeys enuk)
|
||||
{
|
||||
register uint32_t c ;
|
||||
|
||||
CPU_UINT xxx = 0;
|
||||
|
||||
if (enuk < (int) DIM(keys)) return keys[enuk].state() ? 1 : 0;
|
||||
|
||||
c = PIOC->PIO_PDSR ;
|
||||
|
||||
// printf("c=%x\n", c); fflush(stdout);
|
||||
|
||||
switch ((uint8_t) enuk) {
|
||||
case SW_SA0:
|
||||
xxx = !(c & 0x80000000);
|
||||
break;
|
||||
|
||||
case SW_SA2:
|
||||
xxx = c & 0x80000000;
|
||||
break;
|
||||
|
||||
case SW_SB0:
|
||||
xxx = !(c & 0x08000000) && !(c & 0x04000000);
|
||||
break;
|
||||
|
||||
case SW_SB1:
|
||||
xxx = (c & 0x08000000) && !(c & 0x04000000);
|
||||
break;
|
||||
|
||||
case SW_SB2:
|
||||
xxx = !(c & 0x08000000) && (c & 0x04000000);
|
||||
break;
|
||||
|
||||
case SW_SC0:
|
||||
xxx = !(c & 0x00800000) && !(c & 0x00400000);
|
||||
break;
|
||||
|
||||
case SW_SC1:
|
||||
xxx = (c & 0x00800000) && !(c & 0x00400000);
|
||||
break;
|
||||
|
||||
case SW_SC2:
|
||||
xxx = !(c & 0x00800000) && (c & 0x00400000);
|
||||
break;
|
||||
|
||||
case SW_SD0:
|
||||
xxx = !(c & 0x00200000) && !(c & 0x00100000);
|
||||
break;
|
||||
|
||||
case SW_SD1:
|
||||
xxx = (c & 0x00200000) && !(c & 0x00100000);
|
||||
break;
|
||||
|
||||
case SW_SD2:
|
||||
xxx = !(c & 0x00200000) && (c & 0x00100000);
|
||||
break;
|
||||
|
||||
case SW_SE0:
|
||||
xxx = !(c & 0x00080000) && !(c & 0x00040000);
|
||||
break;
|
||||
|
||||
case SW_SE1:
|
||||
xxx = (c & 0x00080000) && !(c & 0x00040000);
|
||||
break;
|
||||
|
||||
case SW_SE2:
|
||||
xxx = !(c & 0x00080000) && (c & 0x00040000);
|
||||
break;
|
||||
|
||||
case SW_SF0:
|
||||
xxx = !(c & 0x00020000) && !(c & 0x00010000);
|
||||
break;
|
||||
|
||||
case SW_SF1:
|
||||
xxx = (c & 0x00020000) && !(c & 0x00010000);
|
||||
break;
|
||||
|
||||
case SW_SF2:
|
||||
xxx = !(c & 0x00020000) && (c & 0x00010000);
|
||||
break;
|
||||
|
||||
case SW_SG0:
|
||||
xxx = !(c & 0x00008000) && !(c & 0x00004000);
|
||||
break;
|
||||
|
||||
case SW_SG1:
|
||||
xxx = (c & 0x00008000) && !(c & 0x00004000);
|
||||
break;
|
||||
|
||||
case SW_SG2:
|
||||
xxx = !(c & 0x00008000) && (c & 0x00004000);
|
||||
break;
|
||||
|
||||
case SW_SH0:
|
||||
xxx = !(c & 0x00002000);
|
||||
break;
|
||||
|
||||
case SW_SH2:
|
||||
xxx = c & 0x00002000;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (xxx) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
extern uint32_t keyState(EnumKeys enuk)
|
||||
{
|
||||
register uint32_t a ;
|
||||
@@ -1080,7 +954,6 @@ extern uint32_t keyState(EnumKeys enuk)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t Analog_values[NUMBER_ANALOG] ;
|
||||
uint8_t temperature = 0; // Raw temp reading
|
||||
|
||||
+1153
File diff suppressed because it is too large
Load Diff
+112
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny <shadow@privy.de>
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
*
|
||||
* open9x is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef board_sky9x_h
|
||||
#define board_sky9x_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include "sky9x/board.h"
|
||||
#include "sky9x/sound_driver.h"
|
||||
#include "sky9x/haptic_driver.h"
|
||||
#include "sky9x/debug.h"
|
||||
|
||||
#if defined(BLUETOOTH)
|
||||
#include "sky9x/bluetooth.h"
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
extern void init_SDcard();
|
||||
extern void sdInit();
|
||||
}
|
||||
|
||||
#define sdPoll10ms()
|
||||
|
||||
void usbMassStorage();
|
||||
|
||||
#define PIN_ENABLE 0x001
|
||||
#define PIN_PERIPHERAL 0x000
|
||||
#define PIN_INPUT 0x002
|
||||
#define PIN_OUTPUT 0x000
|
||||
#define PIN_PULLUP 0x004
|
||||
#define PIN_NO_PULLUP 0x000
|
||||
#define PIN_PULLDOWN 0x008
|
||||
#define PIN_NO_PULLDOWN 0x000
|
||||
#define PIN_PERI_MASK_L 0x010
|
||||
#define PIN_PERI_MASK_H 0x020
|
||||
#define PIN_PER_A 0x000
|
||||
#define PIN_PER_B 0x010
|
||||
#define PIN_PER_C 0x020
|
||||
#define PIN_PER_D 0x030
|
||||
#define PIN_PORT_MASK 0x0C0
|
||||
#define PIN_PORTA 0x000
|
||||
#define PIN_PORTB 0x040
|
||||
#define PIN_PORTC 0x080
|
||||
#define PIN_LOW 0x000
|
||||
#define PIN_HIGH 0x100
|
||||
|
||||
void configure_pins( uint32_t pins, uint16_t config );
|
||||
uint16_t getCurrent();
|
||||
|
||||
extern uint8_t temperature ; // Raw temp reading
|
||||
extern uint8_t maxTemperature ; // Raw temp reading
|
||||
uint8_t getTemperature();
|
||||
|
||||
#define strcpy_P strcpy
|
||||
#define strcat_P strcat
|
||||
|
||||
extern uint32_t read_keys();
|
||||
#define KEYS_PRESSED() (~read_keys())
|
||||
#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))
|
||||
#define DBLKEYS_PRESSED_LFT_DWN(i) ((in & (0x40 + 0x08)) == (0x40 + 0x08))
|
||||
|
||||
#if !defined(REVA)
|
||||
extern uint16_t Current_analogue;
|
||||
extern uint16_t Current_max;
|
||||
extern uint32_t Current_accumulator;
|
||||
extern uint32_t Current_used;
|
||||
extern uint16_t sessionTimer;
|
||||
#endif
|
||||
|
||||
#if defined(REVC)
|
||||
#define BOOTLOADER_REQUEST() (usbPlugged())
|
||||
#else
|
||||
#define BOOTLOADER_REQUEST() (check_soft_power() == e_power_usb)
|
||||
#endif
|
||||
|
||||
#define SLAVE_MODE() (check_soft_power() == e_power_trainer)
|
||||
#define JACK_PPM_OUT() PIOC->PIO_PDR = PIO_PC22
|
||||
#define JACK_PPM_IN() PIOC->PIO_PER = PIO_PC22
|
||||
|
||||
#endif
|
||||
+2
-4
@@ -77,7 +77,7 @@ ISR(EE_READY_vect)
|
||||
eeprom_write_byte();
|
||||
}
|
||||
else {
|
||||
#if defined (PCBGRUVIN9X)
|
||||
#if defined(PCBGRUVIN9X)
|
||||
EECR &= ~(1<<EERIE);
|
||||
#else
|
||||
EECR &= ~(1<<EERIE);
|
||||
@@ -95,10 +95,8 @@ void eeWriteBlockCmp(const void *i_pointer_ram, uint16_t i_pointer_eeprom, size_
|
||||
eeprom_buffer_data = (const char*)i_pointer_ram;
|
||||
eeprom_buffer_size = size+1;
|
||||
|
||||
#ifdef SIMU
|
||||
#if defined(SIMU)
|
||||
sem_post(eeprom_write_sem);
|
||||
#elif defined (PCBSKY9X)
|
||||
|
||||
#elif defined (PCBGRUVIN9X)
|
||||
EECR |= (1<<EERIE);
|
||||
#else
|
||||
|
||||
+10
-10
@@ -56,7 +56,7 @@
|
||||
|
||||
uint8_t frskyRxBuffer[FRSKY_RX_PACKET_SIZE]; // Receive buffer. 9 bytes (full packet), worst case 18 bytes with byte-stuffing (+1)
|
||||
uint8_t frskyTxBuffer[FRSKY_TX_PACKET_SIZE]; // Ditto for transmit buffer
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
uint8_t frskyTxBufferCount = 0;
|
||||
#endif
|
||||
uint8_t FrskyRxBufferReady = 0;
|
||||
@@ -427,7 +427,7 @@ uint8_t privateDataPos;
|
||||
a second buffer to receive data while one buffer is being processed (slowly).
|
||||
*/
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
void processSerialData(uint8_t data)
|
||||
#else
|
||||
NOINLINE void processSerialData(uint8_t stat, uint8_t data)
|
||||
@@ -441,7 +441,7 @@ NOINLINE void processSerialData(uint8_t stat, uint8_t data)
|
||||
btPushByte(data);
|
||||
#endif
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
if (stat & ((1 << FE0) | (1 << DOR0) | (1 << UPE0))) {
|
||||
// discard buffer and start fresh on any comms error
|
||||
FrskyRxBufferReady = 0;
|
||||
@@ -523,7 +523,7 @@ NOINLINE void processSerialData(uint8_t stat, uint8_t data)
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(PCBSKY9X) && !defined(SIMU)
|
||||
#if !defined(CPUARM) && !defined(SIMU)
|
||||
ISR(USART0_RX_vect)
|
||||
{
|
||||
uint8_t stat;
|
||||
@@ -574,7 +574,7 @@ ISR(USART0_RX_vect)
|
||||
#endif
|
||||
|
||||
/******************************************/
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
void frskyTransmitBuffer( uint32_t size )
|
||||
{
|
||||
txPdcUsart( frskyTxBuffer, size ) ;
|
||||
@@ -588,7 +588,7 @@ void frskyTransmitBuffer()
|
||||
|
||||
uint8_t frskyAlarmsSendState = 0 ;
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
void frskyPushValue(uint8_t *&ptr, uint8_t value)
|
||||
{
|
||||
// byte stuff the only byte than might need it
|
||||
@@ -702,7 +702,7 @@ inline void FRSKY10mspoll(void)
|
||||
|
||||
NOINLINE void check_frsky()
|
||||
{
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
rxPdcUsart(processSerialData); // Receive serial data here
|
||||
#endif
|
||||
|
||||
@@ -850,7 +850,7 @@ bool FRSKY_alarmRaised(uint8_t idx)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
inline void FRSKY_EnableTXD(void)
|
||||
{
|
||||
frskyTxBufferCount = 0;
|
||||
@@ -869,7 +869,7 @@ void FRSKY_Init(void)
|
||||
// clear frsky variables
|
||||
resetTelemetry();
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
startPdcUsartReceive() ;
|
||||
#elif !defined(SIMU)
|
||||
|
||||
@@ -1138,7 +1138,7 @@ void putsTelemetryChannel(uint8_t x, uint8_t y, uint8_t channel, int16_t val, ui
|
||||
enum FrskyViews {
|
||||
e_frsky_custom_screen_1,
|
||||
e_frsky_custom_screen_2,
|
||||
IF_PCBSKY9X(e_frsky_custom_screen_3)
|
||||
IF_CPUARM(e_frsky_custom_screen_3)
|
||||
e_frsky_voltages,
|
||||
e_frsky_after_flight,
|
||||
FRSKY_VIEW_MAX = e_frsky_after_flight
|
||||
|
||||
+14
-16
@@ -44,9 +44,7 @@ enum EnumTabDiag {
|
||||
e_Vers,
|
||||
e_Keys,
|
||||
e_Ana,
|
||||
#if !defined(PCBX9D) // TODO
|
||||
IF_PCBSKY9X(e_Hardware)
|
||||
#endif
|
||||
e_Calib
|
||||
};
|
||||
|
||||
@@ -68,9 +66,7 @@ const MenuFuncP_PROGMEM menuTabDiag[] PROGMEM = {
|
||||
menuGeneralVersion,
|
||||
menuGeneralDiagKeys,
|
||||
menuGeneralDiagAna,
|
||||
#if !defined(PCBX9D) // TODO
|
||||
IF_PCBSKY9X(menuGeneralHardware)
|
||||
#endif
|
||||
menuGeneralCalib
|
||||
};
|
||||
|
||||
@@ -110,7 +106,7 @@ enum menuGeneralSetupItems {
|
||||
ITEM_SETUP_ALARMS_LABEL,
|
||||
ITEM_SETUP_BATTERY_WARNING,
|
||||
IF_PCBSKY9X(ITEM_SETUP_CAPACITY_WARNING)
|
||||
IF_PCBSKY9X(ITEM_SETUP_TEMPERATURE_WARNING)
|
||||
IF_CPUARM(ITEM_SETUP_TEMPERATURE_WARNING)
|
||||
ITEM_SETUP_INACTIVITY_ALARM,
|
||||
ITEM_SETUP_MEMORY_WARNING,
|
||||
ITEM_SETUP_ALARM_WARNING,
|
||||
@@ -143,7 +139,7 @@ void menuGeneralSetup(uint8_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) (uint8_t)-1, 0, 0, IF_AUDIO(0) IF_VOICE(0) IF_HAPTIC((uint8_t)-1) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) IF_PCBSKY9X(0) 0, (uint8_t)-1, 0, IF_PCBSKY9X(0) IF_PCBSKY9X(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) 0, (uint8_t)-1, 0, 0, (uint8_t)-1, 0, 0, 0, IF_SPLASH(0) IF_FRSKY(0) IF_FRSKY(0) 0, (uint8_t)-1, IF_PCBX9D(0) 1/*to force edit mode*/});
|
||||
MENU(STR_MENURADIOSETUP, menuTabDiag, e_Setup, ITEM_SETUP_MAX+1, {0, IF_RTCLOCK(2) IF_RTCLOCK(2) (uint8_t)-1, 0, 0, IF_AUDIO(0) IF_VOICE(0) IF_HAPTIC((uint8_t)-1) IF_HAPTIC(0) IF_HAPTIC(0) IF_HAPTIC(0) IF_PCBSKY9X(0) 0, (uint8_t)-1, 0, IF_PCBSKY9X(0) IF_CPUARM(0) 0, 0, 0, IF_ROTARY_ENCODERS(0) 0, (uint8_t)-1, 0, 0, (uint8_t)-1, 0, 0, 0, IF_SPLASH(0) IF_FRSKY(0) IF_FRSKY(0) 0, (uint8_t)-1, IF_PCBX9D(0) 1/*to force edit mode*/});
|
||||
|
||||
uint8_t sub = m_posVert - 1;
|
||||
|
||||
@@ -245,7 +241,7 @@ void menuGeneralSetup(uint8_t event)
|
||||
case ITEM_SETUP_SPEAKER_VOLUME:
|
||||
{
|
||||
lcd_putsLeft(y, STR_SPEAKER_VOLUME);
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.speakerVolume, attr|LEFT);
|
||||
if (attr) {
|
||||
CHECK_INCDEC_GENVAR(event, g_eeGeneral.speakerVolume, 0, NUM_VOL_LEVELS-1);
|
||||
@@ -340,7 +336,9 @@ void menuGeneralSetup(uint8_t event)
|
||||
putsTelemetryValue(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.mAhWarn*50, UNIT_MAH, attr|LEFT) ;
|
||||
if(attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.mAhWarn, 0, 100);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
case ITEM_SETUP_TEMPERATURE_WARNING:
|
||||
lcd_putsLeft(y, STR_TEMPWARNING);
|
||||
putsTelemetryValue(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.temperatureWarn, UNIT_DEGREES, attr|LEFT) ;
|
||||
@@ -547,7 +545,7 @@ void menuGeneralSdManager(uint8_t event)
|
||||
s_menu[s_menu_count++] = STR_SD_FORMAT;
|
||||
}
|
||||
else {
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
uint8_t index = m_posVert-1-s_pgOfs;
|
||||
char * ext = reusableBuffer.sd.lines[index];
|
||||
ext += strlen(ext) - 4;
|
||||
@@ -668,7 +666,7 @@ void menuGeneralSdManager(uint8_t event)
|
||||
else if (result == STR_SD_FORMAT) {
|
||||
displayPopup(STR_FORMATTING);
|
||||
closeLogs();
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
Card_state = SD_ST_DATA;
|
||||
audioQueue.stopSD();
|
||||
#endif
|
||||
@@ -691,7 +689,7 @@ void menuGeneralSdManager(uint8_t event)
|
||||
if ((uint16_t)m_posVert == reusableBuffer.sd.count) m_posVert--;
|
||||
reusableBuffer.sd.offset = s_pgOfs-1;
|
||||
}
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
/* TODO else if (result == STR_LOAD_FILE) {
|
||||
f_getcwd(lfn, SD_SCREEN_FILE_LENGTH);
|
||||
strcat(lfn, "/");
|
||||
@@ -792,7 +790,7 @@ void menuGeneralVersion(uint8_t event)
|
||||
lcd_putsLeft(2*FH, stamp1);
|
||||
lcd_putsLeft(3*FH, stamp2);
|
||||
lcd_putsLeft(4*FH, stamp3);
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(PCBSKY9X) && !defined(REVA)
|
||||
if (Coproc_valid == 1) {
|
||||
lcd_putsLeft(5*FH, PSTR("CoPr:"));
|
||||
lcd_outdez8(10*FW, 5*FH, Coproc_read);
|
||||
@@ -851,7 +849,7 @@ void menuGeneralDiagAna(uint8_t event)
|
||||
{
|
||||
#if defined(PCBSKY9X) && !defined(REVA)
|
||||
#define ANAS_ITEMS_COUNT 4
|
||||
#elif defined(PCBSKY9X)
|
||||
#elif defined(CPUARM)
|
||||
#define ANAS_ITEMS_COUNT 3
|
||||
#else
|
||||
#define ANAS_ITEMS_COUNT 2
|
||||
@@ -868,13 +866,13 @@ void menuGeneralDiagAna(uint8_t event)
|
||||
lcd_outdez8(x+10*FW-1, y, (int16_t)calibratedStick[CONVERT_MODE(i+1)-1]*25/256);
|
||||
}
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
// Display raw BandGap result (debug)
|
||||
lcd_puts(64+5, 1+4*FH, STR_BG);
|
||||
lcd_outdezAtt(64+5+6*FW-3, 1+4*FH, BandGap, 0);
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
lcd_putsLeft(5*FH, STR_BATT_CALIB);
|
||||
static uint32_t adcBatt;
|
||||
adcBatt = ((adcBatt * 7) + anaIn(7)) / 8; // running average, sourced directly (to avoid unending debate :P)
|
||||
@@ -900,14 +898,14 @@ void menuGeneralDiagAna(uint8_t event)
|
||||
if (m_posVert==2) CHECK_INCDEC_GENVAR(event, g_eeGeneral.currentCalib, -49, 49);
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
lcd_putsLeft(7*FH, STR_TEMP_CALIB);
|
||||
putsTelemetryValue(LEN_CALIB_FIELDS*FW+4*FW, 7*FH, getTemperature(), UNIT_DEGREES, (m_posVert==3 ? INVERS : 0)) ;
|
||||
if (m_posVert==3) CHECK_INCDEC_GENVAR(event, g_eeGeneral.temperatureCalib, -100, 100);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X) && !defined(PCBX9D)
|
||||
#if defined(PCBSKY9X)
|
||||
enum menuGeneralHwItems {
|
||||
ITEM_SETUP_HW_OPTREX_DISPLAY,
|
||||
IF_BLUETOOTH(ITEM_SETUP_HW_BT_BAUDRATE)
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ void putEvent(uint8_t evt)
|
||||
s_evt = evt;
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
uint8_t getEvent(bool trim)
|
||||
{
|
||||
uint8_t evt = s_evt;
|
||||
@@ -63,7 +63,7 @@ uint8_t getEvent()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define KEY_LONG_DELAY 32
|
||||
#else
|
||||
#define KEY_LONG_DELAY 24
|
||||
|
||||
+2
-2
@@ -594,7 +594,7 @@ void putsTime(xcoord_t x, uint8_t y, putstime_t tme, LcdFlags att, LcdFlags att2
|
||||
x += 2*8+1;
|
||||
}
|
||||
#define separator ':'
|
||||
#elif defined(PCBSKY9X)
|
||||
#elif defined(CPUARM)
|
||||
char separator = ':';
|
||||
if (tme >= 3600 && (~att & DBLSIZE)) {
|
||||
qr = div(qr.quot, 60);
|
||||
@@ -715,7 +715,7 @@ void putsSwitches(xcoord_t x, uint8_t y, int8_t idx, LcdFlags att)
|
||||
if (idx > MAX_SWITCH) {
|
||||
idx -= ((att & SWONOFF) ? MAX_SWITCH+1 : MAX_SWITCH);
|
||||
char suffix = 'm';
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (idx > MAX_SWITCH+1) {
|
||||
suffix = 's';
|
||||
idx -= MAX_SWITCH+1;
|
||||
|
||||
+1
-1
@@ -213,7 +213,7 @@ void displayTimers()
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
void displayVoltage()
|
||||
{
|
||||
if (g_vbat100mV > g_eeGeneral.vBatWarn && g_eeGeneral.temperatureWarn && getTemperature() >= g_eeGeneral.temperatureWarn) {
|
||||
|
||||
+37
-37
@@ -120,7 +120,7 @@ bool listSdFiles(const char *path, const char *extension, const uint8_t maxlen,
|
||||
|
||||
static uint16_t s_last_menu_offset = 0;
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (selection) {
|
||||
memset(reusableBuffer.models.menu_bss, 0, sizeof(reusableBuffer.models.menu_bss));
|
||||
strcpy(reusableBuffer.models.menu_bss[0], path);
|
||||
@@ -216,7 +216,7 @@ void menuModelSelect(uint8_t event)
|
||||
{
|
||||
TITLE(STR_MENUMODELSEL);
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define REFRESH(x)
|
||||
#elif defined(PCBGRUVIN9X) && defined(SDCARD)
|
||||
static bool refresh = true;
|
||||
@@ -254,7 +254,7 @@ void menuModelSelect(uint8_t event)
|
||||
#endif
|
||||
if (s_editMode > 0) s_editMode = 0;
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
if (event
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
|| oldSub != m_posVert
|
||||
@@ -430,7 +430,7 @@ void menuModelSelect(uint8_t event)
|
||||
|
||||
}
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
lcd_puts(9*FW-(LEN_FREE-4)*FW, 0, STR_FREE);
|
||||
if (refresh) reusableBuffer.models.eepromfree = EeFsGetFree();
|
||||
lcd_outdezAtt(17*FW, 0, reusableBuffer.models.eepromfree, 0);
|
||||
@@ -469,7 +469,7 @@ void menuModelSelect(uint8_t event)
|
||||
k %= MAX_MODELS;
|
||||
|
||||
if (eeModelExists(k)) {
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
putsModelName(4*FW, y, ModelNames[k], k, 0);
|
||||
#else
|
||||
uint16_t & size = reusableBuffer.models.listsizes[i];
|
||||
@@ -488,7 +488,7 @@ void menuModelSelect(uint8_t event)
|
||||
}
|
||||
|
||||
if (s_warning) {
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
s_warning_info = ModelNames[sub];
|
||||
#else
|
||||
char * name = reusableBuffer.models.mainname;
|
||||
@@ -621,7 +621,7 @@ enum menuModelSetupItems {
|
||||
ITEM_MODEL_PROTOCOL_PARAMS
|
||||
};
|
||||
|
||||
#if defined(PCBSKY9X) || defined(PCBGRUVIN9X)
|
||||
#if defined(CPUARM) || defined(PCBGRUVIN9X)
|
||||
#define FIELD_TIMER_MAX 3
|
||||
#else
|
||||
#define FIELD_TIMER_MAX 2
|
||||
@@ -665,7 +665,7 @@ void menuModelSetup(uint8_t event)
|
||||
switch(k) {
|
||||
case ITEM_MODEL_NAME:
|
||||
editName(MODEL_SETUP_2ND_COLUMN, y, g_model.name, sizeof(g_model.name), event, attr, m_posHorz);
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
memcpy(ModelNames[g_eeGeneral.currModel], g_model.name, sizeof(g_model.name));
|
||||
#endif
|
||||
break;
|
||||
@@ -698,7 +698,7 @@ void menuModelSetup(uint8_t event)
|
||||
putsTime(MODEL_SETUP_2ND_COLUMN+5*FW-2, y, timer->start,
|
||||
(attr && m_posHorz==1 ? blink:0),
|
||||
(attr && m_posHorz==2 ? blink:0) );
|
||||
#if defined(PCBSKY9X) || defined(PCBGRUVIN9X)
|
||||
#if defined(CPUARM) || defined(PCBGRUVIN9X)
|
||||
lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+10*FW-1, y, g_model.timers[k-ITEM_MODEL_TIMER1].remanent ? 'R' : '-', (attr && m_posHorz==3) ? blink : 0);
|
||||
#endif
|
||||
if (attr && (editMode>0 || p1valdiff)) {
|
||||
@@ -716,7 +716,7 @@ void menuModelSetup(uint8_t event)
|
||||
timer->start -= qr.rem ;
|
||||
if ((int16_t)timer->start < 0) timer->start=0;
|
||||
break;
|
||||
#if defined(PCBSKY9X) || defined(PCBGRUVIN9X)
|
||||
#if defined(CPUARM) || defined(PCBGRUVIN9X)
|
||||
case 3:
|
||||
CHECK_INCDEC_MODELVAR(event, g_model.timers[k-ITEM_MODEL_TIMER1].remanent, 0, 1);
|
||||
break;
|
||||
@@ -953,7 +953,7 @@ uint8_t editDelay(const uint8_t y, const uint8_t event, const uint8_t attr, cons
|
||||
|
||||
#if defined(FLIGHT_PHASES)
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define PhasesType uint16_t
|
||||
#else
|
||||
#define PhasesType uint8_t
|
||||
@@ -965,12 +965,12 @@ PhasesType editPhases(uint8_t x, uint8_t y, uint8_t event, PhasesType value, uin
|
||||
|
||||
uint8_t posHorz = m_posHorz;
|
||||
|
||||
#if defined(PCBSKY9X) && !defined(LCD212)
|
||||
#if defined(CPUARM) && !defined(LCD212)
|
||||
bool expoMenu = (x==EXPO_ONE_2ND_COLUMN-2*FW);
|
||||
#endif
|
||||
|
||||
for (uint8_t p=0; p<MAX_PHASES; p++) {
|
||||
#if defined(PCBSKY9X) && !defined(LCD212)
|
||||
#if defined(CPUARM) && !defined(LCD212)
|
||||
if (expoMenu && ((attr && p < posHorz-4) || (x > EXPO_ONE_2ND_COLUMN+2*FW)))
|
||||
continue;
|
||||
#endif
|
||||
@@ -1189,7 +1189,7 @@ void menuModelPhasesAll(uint8_t event)
|
||||
|
||||
uint8_t att;
|
||||
for (uint8_t i=0; i<MAX_PHASES; i++) {
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
int8_t y = (1+i-s_pgOfs)*FH;
|
||||
if (y<1*FH || y>7*FH) continue;
|
||||
#else
|
||||
@@ -1246,7 +1246,7 @@ void menuModelPhasesAll(uint8_t event)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (s_pgOfs != MAX_PHASES-6) return;
|
||||
#endif
|
||||
|
||||
@@ -1700,7 +1700,7 @@ bool swapExpoMix(uint8_t expo, uint8_t &idx, uint8_t up)
|
||||
}
|
||||
|
||||
enum ExposFields {
|
||||
IF_PCBSKY9X(EXPO_FIELD_NAME)
|
||||
IF_CPUARM(EXPO_FIELD_NAME)
|
||||
EXPO_FIELD_WIDTH,
|
||||
EXPO_FIELD_EXPO,
|
||||
IF_CURVES(EXPO_FIELD_CURVE)
|
||||
@@ -1715,7 +1715,7 @@ void menuModelExpoOne(uint8_t event)
|
||||
ExpoData *ed = expoaddress(s_currIdx);
|
||||
putsChnRaw(7*FW+FW/2,0,ed->chn+1,0);
|
||||
|
||||
SUBMENU(STR_MENUDREXPO, EXPO_FIELD_MAX, {IF_PCBSKY9X(ZCHAR|(sizeof(ed->name)-1)) 0, 0, IF_CURVES(1) IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/});
|
||||
SUBMENU(STR_MENUDREXPO, EXPO_FIELD_MAX, {IF_CPUARM(ZCHAR|(sizeof(ed->name)-1)) 0, 0, IF_CURVES(1) IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/});
|
||||
|
||||
int8_t sub = m_posVert;
|
||||
|
||||
@@ -1725,7 +1725,7 @@ void menuModelExpoOne(uint8_t event)
|
||||
uint8_t attr = (sub==i ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0);
|
||||
switch(i)
|
||||
{
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
case EXPO_FIELD_NAME:
|
||||
editName(EXPO_ONE_2ND_COLUMN+3*FW-sizeof(ed->name)*FW, y, ed->name, sizeof(ed->name), event, attr, m_posHorz);
|
||||
break;
|
||||
@@ -1794,7 +1794,7 @@ void menuModelExpoOne(uint8_t event)
|
||||
}
|
||||
|
||||
enum MixFields {
|
||||
IF_PCBSKY9X(MIX_FIELD_NAME)
|
||||
IF_CPUARM(MIX_FIELD_NAME)
|
||||
MIX_FIELD_SOURCE,
|
||||
MIX_FIELD_WEIGHT,
|
||||
MIX_FIELD_OFFSET,
|
||||
@@ -1827,11 +1827,11 @@ void menuModelMixOne(uint8_t event)
|
||||
|
||||
#if defined(ROTARY_ENCODERS)
|
||||
if ((m_posVert == MIX_FIELD_TRIM && md2->srcRaw > NUM_STICKS) || (m_posVert == MIX_FIELD_CURVE && md2->curveMode == MODE_CURVE))
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_PCBSKY9X(ZCHAR|(sizeof(md2->name)-1)) 0, 0, 0, 0, IF_CURVES(0) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/})
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(ZCHAR|(sizeof(md2->name)-1)) 0, 0, 0, 0, IF_CURVES(0) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/})
|
||||
else
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_PCBSKY9X(ZCHAR|(sizeof(md2->name)-1)) 0, 0, 0, 1, IF_CURVES(1) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/});
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(ZCHAR|(sizeof(md2->name)-1)) 0, 0, 0, 1, IF_CURVES(1) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/});
|
||||
#else
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_PCBSKY9X(ZCHAR|(sizeof(md2->name)-1)) 0, 0, 0, 1, IF_CURVES(1) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/});
|
||||
SUBMENU_NOTITLE(MIX_FIELD_COUNT, {IF_CPUARM(ZCHAR|(sizeof(md2->name)-1)) 0, 0, 0, 1, IF_CURVES(1) 0, IF_FLIGHT_PHASES(MAX_PHASES-1) 0 /*, ...*/});
|
||||
#endif
|
||||
|
||||
int8_t sub = m_posVert;
|
||||
@@ -1842,7 +1842,7 @@ void menuModelMixOne(uint8_t event)
|
||||
int8_t i = k + s_pgOfs;
|
||||
uint8_t attr = (sub==i ? (editMode>0 ? BLINK|INVERS : INVERS) : 0);
|
||||
switch(i) {
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
case MIX_FIELD_NAME:
|
||||
editName(MIXES_2ND_COLUMN, y, md2->name, sizeof(md2->name), event, attr, m_posHorz);
|
||||
break;
|
||||
@@ -2138,7 +2138,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event)
|
||||
else
|
||||
displayGVar(EXPO_LINE_EXPO_POS, y, ed->curveParam);
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (ed->name[0]) {
|
||||
putsSwitches(11*FW, y, ed->swtch, 0);
|
||||
lcd_putsnAtt(DISPLAY_W-sizeof(ed->name)*FW-MENUS_SCROLLBAR_WIDTH, y, ed->name, sizeof(ed->name), ZCHAR | (isExpoActive(i) ? BOLD : 0));
|
||||
@@ -2160,7 +2160,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event)
|
||||
|
||||
md->weight = gvarMenuItem(11*FW+3, y, md->weight, -125, 125, attr, event);
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (md->name[0]) {
|
||||
lcd_putsnAtt(DISPLAY_W-sizeof(md->name)*FW-MENUS_SCROLLBAR_WIDTH, y, md->name, sizeof(md->name), ZCHAR | (isMixActive(i) ? BOLD : 0));
|
||||
}
|
||||
@@ -2302,7 +2302,7 @@ enum LimitsItems {
|
||||
|
||||
void menuModelLimits(uint8_t event)
|
||||
{
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
MENU(STR_MENULIMITS, menuTabModel, e_Limits, 1+NUM_CHNOUT+1, {0, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, 0});
|
||||
#else
|
||||
MENU(STR_MENULIMITS, menuTabModel, e_Limits, 1+NUM_CHNOUT+1, {0, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, ITEM_LIMITS_MAXROW, 0});
|
||||
@@ -2515,7 +2515,7 @@ void menuModelCurvesAll(uint8_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
enum CustomSwitchFields {
|
||||
CSW_FIELD_FUNCTION,
|
||||
CSW_FIELD_V1,
|
||||
@@ -2788,7 +2788,7 @@ void menuModelCustomSwitches(uint8_t event)
|
||||
|
||||
void menuModelCustomFunctions(uint8_t event)
|
||||
{
|
||||
#if defined(PCBSKY9X) && defined(SDCARD)
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
uint8_t _event = event;
|
||||
if (s_menu_count) {
|
||||
event = 0;
|
||||
@@ -2817,7 +2817,7 @@ void menuModelCustomFunctions(uint8_t event)
|
||||
}
|
||||
putsSwitches(3, y, sd->swtch, SWONOFF | attr | ((abs(sd->swtch) <= (MAX_SWITCH+1) && getSwitch(sd->swtch, 0) && (sd->func > FUNC_INSTANT_TRIM || sd->active)) ? BOLD : 0));
|
||||
if (active || AUTOSWITCH_MENU_LONG()) {
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
CHECK_INCDEC_MODELSWITCH(event, sd->swtch, SWITCH_OFF-MAX_SWITCH, SWITCH_ON+MAX_SWITCH+1+2*MAX_PSWITCH);
|
||||
#else
|
||||
CHECK_INCDEC_MODELSWITCH(event, sd->swtch, SWITCH_OFF-MAX_SWITCH, SWITCH_ON+MAX_SWITCH+1);
|
||||
@@ -2883,7 +2883,7 @@ void menuModelCustomFunctions(uint8_t event)
|
||||
lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT);
|
||||
}
|
||||
#endif
|
||||
#if defined(PCBSKY9X) && defined(SDCARD)
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
else if (sd->func == FUNC_PLAY_TRACK || sd->func == FUNC_BACKGND_MUSIC) {
|
||||
if (ZLEN(sd->param))
|
||||
lcd_putsnAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, sd->param, sizeof(sd->param), attr);
|
||||
@@ -2904,7 +2904,7 @@ void menuModelCustomFunctions(uint8_t event)
|
||||
putsChnRaw(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+1, attr);
|
||||
}
|
||||
#endif
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
else if (sd->func == FUNC_VOLUME) {
|
||||
val_max = NUM_XCHNRAW-1;
|
||||
putsChnRaw(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed+1, attr);
|
||||
@@ -2979,7 +2979,7 @@ void menuModelCustomFunctions(uint8_t event)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X) && defined(SDCARD)
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
if (s_menu_count) {
|
||||
const char * result = displayMenu(_event);
|
||||
if (result) {
|
||||
@@ -3033,7 +3033,7 @@ enum menuModelTelemetryItems {
|
||||
ITEM_TELEMETRY_SCREEN_LINE6,
|
||||
ITEM_TELEMETRY_SCREEN_LINE7,
|
||||
ITEM_TELEMETRY_SCREEN_LINE8,
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
ITEM_TELEMETRY_SCREEN_LABEL3,
|
||||
ITEM_TELEMETRY_SCREEN_LINE9,
|
||||
ITEM_TELEMETRY_SCREEN_LINE10,
|
||||
@@ -3058,7 +3058,7 @@ enum menuModelTelemetryItems {
|
||||
|
||||
void menuModelTelemetry(uint8_t event)
|
||||
{
|
||||
MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX+1, {0, (uint8_t)-1, 1, 0, 2, 2, (uint8_t)-1, 1, 0, 2, 2, (uint8_t)-1, 1, 1, USRDATA_LINES 0, 0, IF_VARIO((uint8_t)-1) IF_VARIO(0) IF_VARIO(1) 0, 2, 2, 2, 2, 0, 2, 2, 2, IF_PCBSKY9X(2) IF_PCBSKY9X(0) IF_PCBSKY9X(2) IF_PCBSKY9X(2) IF_PCBSKY9X(2) 2 });
|
||||
MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX+1, {0, (uint8_t)-1, 1, 0, 2, 2, (uint8_t)-1, 1, 0, 2, 2, (uint8_t)-1, 1, 1, USRDATA_LINES 0, 0, IF_VARIO((uint8_t)-1) IF_VARIO(0) IF_VARIO(1) 0, 2, 2, 2, 2, 0, 2, 2, 2, IF_CPUARM(2) IF_CPUARM(0) IF_CPUARM(2) IF_CPUARM(2) IF_CPUARM(2) 2 });
|
||||
|
||||
uint8_t sub = m_posVert - 1;
|
||||
|
||||
@@ -3246,7 +3246,7 @@ void menuModelTelemetry(uint8_t event)
|
||||
case ITEM_TELEMETRY_SCREEN_LABEL1:
|
||||
case ITEM_TELEMETRY_SCREEN_LABEL2:
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
case ITEM_TELEMETRY_SCREEN_LABEL3:
|
||||
{
|
||||
uint8_t screenIndex = (k < ITEM_TELEMETRY_SCREEN_LABEL2 ? 0 : (k < ITEM_TELEMETRY_SCREEN_LABEL3 ? 1 : 2));
|
||||
@@ -3276,7 +3276,7 @@ void menuModelTelemetry(uint8_t event)
|
||||
case ITEM_TELEMETRY_SCREEN_LINE7:
|
||||
case ITEM_TELEMETRY_SCREEN_LINE8:
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
case ITEM_TELEMETRY_SCREEN_LINE9:
|
||||
case ITEM_TELEMETRY_SCREEN_LINE10:
|
||||
case ITEM_TELEMETRY_SCREEN_LINE11:
|
||||
@@ -3289,7 +3289,7 @@ void menuModelTelemetry(uint8_t event)
|
||||
screenIndex = 0;
|
||||
lineIndex = k-ITEM_TELEMETRY_SCREEN_LINE1;
|
||||
}
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
else if (k >= ITEM_TELEMETRY_SCREEN_LABEL3) {
|
||||
screenIndex = 2;
|
||||
lineIndex = k-ITEM_TELEMETRY_SCREEN_LINE9;
|
||||
|
||||
+17
-15
@@ -48,7 +48,9 @@
|
||||
#define WARN_MEM (!(g_eeGeneral.warnOpts & WARN_MEM_BIT))
|
||||
#define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 )
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(PCBX9D)
|
||||
#define EEPROM_VER 213
|
||||
#elif defined(PCBSKY9X)
|
||||
#define EEPROM_VER 213
|
||||
#elif defined(PCBGRUVIN9X)
|
||||
#define EEPROM_VER 212
|
||||
@@ -99,7 +101,7 @@ enum BeeperMode {
|
||||
e_mode_all
|
||||
};
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define EXTRA_GENERAL_FIELDS \
|
||||
uint8_t speakerVolume; \
|
||||
uint8_t backlightBright; \
|
||||
@@ -195,7 +197,7 @@ PACK(typedef struct t_EEGeneral {
|
||||
#define LEN_FP_NAME 6
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
PACK(typedef struct t_ExpoData {
|
||||
uint8_t mode; // 0=end, 1=pos, 2=neg, 3=both
|
||||
uint8_t chn;
|
||||
@@ -243,7 +245,7 @@ PACK(typedef struct t_LimitData {
|
||||
#define MODE_EXPO 0
|
||||
#define MODE_CURVE 1
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define MAX_DELAY 60 /* 30 seconds */
|
||||
#define MAX_SLOW 60 /* 30 seconds */
|
||||
PACK(typedef struct t_MixData {
|
||||
@@ -290,7 +292,7 @@ PACK(typedef struct t_MixData {
|
||||
}) MixData;
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define MAX_CSW_DURATION 120 /*60s*/
|
||||
#define MAX_CSW_DELAY 120 /*60s*/
|
||||
PACK(typedef struct t_CustomSwData { // Custom Switches data
|
||||
@@ -326,11 +328,11 @@ enum Functions {
|
||||
#if !defined(PCBSTD)
|
||||
FUNC_LOGS,
|
||||
#endif
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
FUNC_VOLUME,
|
||||
#endif
|
||||
FUNC_BACKLIGHT,
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
FUNC_BACKGND_MUSIC,
|
||||
FUNC_BACKGND_MUSIC_PAUSE,
|
||||
#endif
|
||||
@@ -344,7 +346,7 @@ enum Functions {
|
||||
FUNC_MAX
|
||||
};
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
PACK(typedef struct t_FuncSwData { // Function Switches data
|
||||
int8_t swtch; //input
|
||||
uint8_t func;
|
||||
@@ -479,7 +481,7 @@ enum FrskySource {
|
||||
FRSKY_SOURCE_CELLS,
|
||||
};
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define MAX_FRSKY_SCREENS 3
|
||||
PACK(typedef struct t_FrSkyData {
|
||||
FrSkyChannelData channels[2];
|
||||
@@ -602,7 +604,7 @@ typedef char gvar_name_t[6];
|
||||
#define GVAR_VALUE(x, p) g_model.phaseData[p].gvars[x]
|
||||
#else
|
||||
#define MAX_GVARS 0
|
||||
#define MODEL_GVARS_DATA
|
||||
#define MODEL_GVARS_DATA gvar_name_t gvarsNames[5]
|
||||
#define PHASE_GVARS_DATA gvar_t gvars[5]
|
||||
#endif
|
||||
|
||||
@@ -616,7 +618,7 @@ PACK(typedef struct t_PhaseData {
|
||||
PHASE_GVARS_DATA;
|
||||
}) PhaseData;
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define MAX_MODELS 60
|
||||
#define NUM_CHNOUT 32 // number of real output channels CH1-CH32
|
||||
#define MAX_PHASES 9
|
||||
@@ -644,7 +646,7 @@ PACK(typedef struct t_PhaseData {
|
||||
|
||||
#define MAX_TIMERS 2
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define MAX_CURVES 16
|
||||
#define NUM_POINTS 512
|
||||
#define CURVTYPE int16_t
|
||||
@@ -669,7 +671,7 @@ enum MixSources {
|
||||
MIXSRC_P2,
|
||||
MIXSRC_P3,
|
||||
#endif
|
||||
#if defined(PCBSKY9X) && !defined(PCBX9D)
|
||||
#if defined(PCBSKY9X)
|
||||
MIXSRC_REa,
|
||||
#elif defined(PCBGRUVIN9X)
|
||||
MIXSRC_REa,
|
||||
@@ -743,7 +745,7 @@ enum MixSources {
|
||||
#define TMRMODE_THR_REL 3
|
||||
#define TMRMODE_THR_TRG 4
|
||||
|
||||
#if defined(PCBGRUVIN9X) || defined(PCBSKY9X)
|
||||
#if defined(PCBGRUVIN9X) || defined(CPUARM)
|
||||
PACK(typedef struct t_TimerData {
|
||||
int8_t mode; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
|
||||
uint16_t start;
|
||||
@@ -791,7 +793,7 @@ enum Dsm2Variants {
|
||||
#define TELEMETRY_DATA
|
||||
#endif
|
||||
|
||||
#if defined(PCBGRUVIN9X) || defined(PCBSKY9X)
|
||||
#if defined(PCBGRUVIN9X) || defined(CPUARM)
|
||||
#define BeepANACenter uint16_t
|
||||
#else
|
||||
#define BeepANACenter uint8_t
|
||||
|
||||
+64
-67
@@ -33,7 +33,7 @@
|
||||
|
||||
#include "open9x.h"
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define MIXER_STACK_SIZE 500
|
||||
#define MENUS_STACK_SIZE 1000
|
||||
#define AUDIO_STACK_SIZE 500
|
||||
@@ -100,7 +100,7 @@ void loadModelBitmap()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
uint8_t g_tmr1Latency_max;
|
||||
uint8_t g_tmr1Latency_min;
|
||||
#endif
|
||||
@@ -111,7 +111,7 @@ uint8_t unexpectedShutdown = 0;
|
||||
uint16_t maxMixerDuration;
|
||||
uint16_t lastMixerDuration;
|
||||
|
||||
#if defined(AUDIO) && !defined(PCBSKY9X)
|
||||
#if defined(AUDIO) && !defined(CPUARM)
|
||||
audioQueue audio;
|
||||
#endif
|
||||
|
||||
@@ -183,7 +183,7 @@ uint8_t zlen(const char *str, uint8_t size)
|
||||
|
||||
volatile tmr10ms_t g_tmr10ms;
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
volatile uint8_t rtc_count=0;
|
||||
#endif
|
||||
|
||||
@@ -200,7 +200,7 @@ void per10ms()
|
||||
AUDIO_INACTIVITY();
|
||||
}
|
||||
|
||||
#if defined (PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
Tenms |= 1 ; // 10 mS has passed
|
||||
#endif
|
||||
|
||||
@@ -208,7 +208,7 @@ void per10ms()
|
||||
/* Update global Date/Time every 100 per10ms cycles */
|
||||
if (++g_ms100 == 100) {
|
||||
g_rtcTime++; // inc global unix timestamp one second
|
||||
#if defined (PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (g_rtcTime < 60 || rtc_count<5) {
|
||||
rtc_init();
|
||||
rtc_count++;
|
||||
@@ -223,11 +223,11 @@ void per10ms()
|
||||
|
||||
readKeysAndTrims();
|
||||
|
||||
#if defined(MAVLINK) && !defined(PCBSKY9X)
|
||||
#if defined(MAVLINK) && !defined(CPUARM)
|
||||
check_mavlink();
|
||||
#endif
|
||||
|
||||
#if defined (FRSKY) && !defined(PCBSKY9X) && !(defined(PCBSTD) && (defined(AUDIO) || defined(VOICE)))
|
||||
#if defined(FRSKY) && !defined(CPUARM) && !(defined(PCBSTD) && (defined(AUDIO) || defined(VOICE)))
|
||||
check_frsky();
|
||||
#endif
|
||||
|
||||
@@ -509,7 +509,7 @@ void applyExpos(int16_t *anas)
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
int16_t calc100toRESX(int8_t x)
|
||||
{
|
||||
// return (int16_t)x*10 + x/4 - x/64;
|
||||
@@ -531,7 +531,6 @@ int16_t calcRESXto1000(int16_t x)
|
||||
// *1000/1024 = x - x/32 + x/128
|
||||
return (x - x/32 + x/128);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int16_t applyLimits(uint8_t channel, int32_t value)
|
||||
@@ -648,7 +647,7 @@ int16_t getValue(uint8_t i)
|
||||
else return 0;
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define GETSWITCH_RECURSIVE_TYPE uint32_t
|
||||
volatile bool s_default_switch_value;
|
||||
#else
|
||||
@@ -659,7 +658,7 @@ volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_used;
|
||||
volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_value;
|
||||
/* recursive function. stack as of today (16/03/2012) grows by 8bytes at each call, which is ok! */
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
uint32_t delays[NUM_CSW];
|
||||
uint32_t durations[NUM_CSW];
|
||||
#endif
|
||||
@@ -671,7 +670,7 @@ bool __getSwitch(int8_t swtch)
|
||||
bool result;
|
||||
|
||||
if (swtch == 0)
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
return s_default_switch_value;
|
||||
#else
|
||||
return s_last_switch_used & ((GETSWITCH_RECURSIVE_TYPE)1<<15);
|
||||
@@ -714,7 +713,7 @@ bool __getSwitch(int8_t swtch)
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
if (result)
|
||||
s_last_switch_value |= ((GETSWITCH_RECURSIVE_TYPE)1<<cs_idx);
|
||||
#endif
|
||||
@@ -809,7 +808,7 @@ bool __getSwitch(int8_t swtch)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (cs->delay) {
|
||||
if (result) {
|
||||
if (delays[cs_idx] > get_tmr10ms())
|
||||
@@ -842,7 +841,7 @@ bool __getSwitch(int8_t swtch)
|
||||
|
||||
bool getSwitch(int8_t swtch, bool nc)
|
||||
{
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
s_last_switch_used = 0;
|
||||
s_last_switch_value = 0;
|
||||
s_default_switch_value = nc;
|
||||
@@ -1051,7 +1050,7 @@ void setGVarValue(uint8_t idx, int8_t value, int8_t phase)
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(FRSKY) || defined(PCBSKY9X)
|
||||
#if defined(FRSKY) || defined(CPUARM)
|
||||
void putsTelemetryValue(uint8_t x, uint8_t y, int16_t val, uint8_t unit, uint8_t att)
|
||||
{
|
||||
#ifdef IMPERIAL_UNITS
|
||||
@@ -1133,7 +1132,7 @@ void doSplash()
|
||||
lcd_img(0, 0, splash_lbm, 0, 0);
|
||||
refreshDisplay();
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
AUDIO_TADA();
|
||||
#endif
|
||||
|
||||
@@ -1154,7 +1153,7 @@ void doSplash()
|
||||
{
|
||||
#if defined(SIMU)
|
||||
SIMU_SLEEP(1);
|
||||
#elif defined(PCBSKY9X)
|
||||
#elif defined(CPUARM)
|
||||
CoTickDelay(1);
|
||||
#endif
|
||||
|
||||
@@ -1189,7 +1188,7 @@ void doSplash()
|
||||
|
||||
void checkAll()
|
||||
{
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
checkLowEEPROM();
|
||||
#endif
|
||||
|
||||
@@ -1197,7 +1196,7 @@ void checkAll()
|
||||
checkSwitches();
|
||||
}
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
void checkLowEEPROM()
|
||||
{
|
||||
if (g_eeGeneral.disableMemoryWarning) return;
|
||||
@@ -1342,7 +1341,7 @@ void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SO
|
||||
int8_t trimGvar[NUM_STICKS] = { -1, -1, -1, -1 };
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
void checkTrims()
|
||||
{
|
||||
uint8_t event = getEvent(true);
|
||||
@@ -1387,7 +1386,7 @@ uint8_t checkTrim(uint8_t event)
|
||||
int8_t v = (s==0) ? min(32, abs(before)/4+1) : 1 << (s-1); // 1=>1 2=>2 3=>4 4=>8
|
||||
if (thro) v = 4; // if throttle trim and trim trottle then step=4
|
||||
int16_t after = (k&1) ? before + v : before - v; // positive = k&1
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
uint8_t beepTrim = 0;
|
||||
#else
|
||||
bool beepTrim = false;
|
||||
@@ -1448,16 +1447,16 @@ uint8_t checkTrim(uint8_t event)
|
||||
else {
|
||||
AUDIO_TRIM(event, after);
|
||||
}
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
return event;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X) && !defined(REVA)
|
||||
#if defined(CPUARM) && !defined(REVA)
|
||||
uint16_t Current_analogue;
|
||||
uint16_t Current_max;
|
||||
uint32_t Current_accumulator;
|
||||
@@ -1496,7 +1495,7 @@ uint16_t anaIn(uint8_t chan)
|
||||
// ana-in: 3 1 2 0 4 5 6 7
|
||||
//static pm_char crossAna[] PROGMEM ={4,2,3,1,5,6,7,0}; // wenn schon Tabelle, dann muss sich auch lohnen
|
||||
// Google Translate (German): // if table already, then it must also be worthwhile
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
static const uint8_t crossAna[]={1,5,7,0,4,6,2,3,8};
|
||||
#if !defined(REVA)
|
||||
if ( chan == 8 ) {
|
||||
@@ -1511,7 +1510,7 @@ uint16_t anaIn(uint8_t chan)
|
||||
return *p;
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
void getADC()
|
||||
{
|
||||
register uint32_t x;
|
||||
@@ -1547,7 +1546,7 @@ void getADC()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
void getADC_bandgap()
|
||||
{
|
||||
#if defined (PCBGRUVIN9X)
|
||||
@@ -1903,7 +1902,7 @@ PLAY_FUNCTION(playValue, uint8_t idx)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
static uint8_t currentSpeakerVolume = 255;
|
||||
uint8_t requiredSpeakerVolume;
|
||||
uint8_t fnSwitchDuration[NUM_FSW] = { 0 };
|
||||
@@ -1936,7 +1935,7 @@ void evalFunctions()
|
||||
MASK_FUNC_TYPE function_mask = (sd->func >= FUNC_TRAINER ? ((MASK_FUNC_TYPE)1 << (sd->func-FUNC_TRAINER)) : 0);
|
||||
MASK_FSW_TYPE switch_mask = ((MASK_FSW_TYPE)1 << i);
|
||||
uint8_t momentary = 0;
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
uint8_t shrt=0, lng=0;
|
||||
if (swtch > MAX_SWITCH+1+MAX_SWITCH+1+MAX_PSWITCH) {
|
||||
lng = 1;
|
||||
@@ -1956,7 +1955,7 @@ void evalFunctions()
|
||||
momentary = 1;
|
||||
swtch += MAX_SWITCH+1;
|
||||
}
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
bool sw;
|
||||
if ((sw=getSwitch(swtch, 0)) || (shrt&&fnSwitchDuration[i]>0&&fnSwitchDuration[i]<FSW_PRESSLONG_DURATION) || (lng&&fnSwitchDuration[i]>=(uint8_t)FSW_PRESSLONG_DURATION)) {
|
||||
if (shrt || lng) {
|
||||
@@ -2018,7 +2017,7 @@ void evalFunctions()
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X) && defined(SDCARD)
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
if ((shrt || lng) && (activeFunctions & function_mask)) {
|
||||
if (sd->func == FUNC_BACKGND_MUSIC) {
|
||||
STOP_PLAY(i+1);
|
||||
@@ -2038,7 +2037,7 @@ void evalFunctions()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X) && defined(SDCARD)
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
else if (sd->func == FUNC_PLAY_TRACK || sd->func == FUNC_BACKGND_MUSIC) {
|
||||
if (IS_PLAYING(i+1)) {
|
||||
switch_mask = 0;
|
||||
@@ -2124,10 +2123,10 @@ void evalFunctions()
|
||||
activeFunctionSwitches |= switch_mask;
|
||||
}
|
||||
else {
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
fnSwitchDuration[i] = 0;
|
||||
#endif
|
||||
#if defined(PCBSKY9X) && defined(SDCARD)
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
if (!COMPLEX_SWITCH && sd->func == FUNC_BACKGND_MUSIC) {
|
||||
STOP_PLAY(i+1);
|
||||
}
|
||||
@@ -2462,7 +2461,7 @@ ACTIVE_MIXES_TYPE activeMixes;
|
||||
#endif
|
||||
int32_t sum_chans512[NUM_CHNOUT] = {0};
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
FORCEINLINE bool doMixerCalculations()
|
||||
#else
|
||||
FORCEINLINE void doMixerCalculations()
|
||||
@@ -2484,7 +2483,7 @@ FORCEINLINE void doMixerCalculations()
|
||||
|
||||
getADC();
|
||||
|
||||
#if defined(PCBSKY9X) && !defined(REVA) && !defined(SIMU)
|
||||
#if defined(CPUARM) && !defined(REVA) && !defined(SIMU)
|
||||
Current_analogue = ( Current_analogue * 31 + s_anaFilt[8] ) >> 5 ;
|
||||
if (Current_analogue > Current_max)
|
||||
Current_max = Current_analogue ;
|
||||
@@ -2567,11 +2566,11 @@ FORCEINLINE void doMixerCalculations()
|
||||
#endif
|
||||
|
||||
// Bandgap has had plenty of time to settle...
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
getADC_bandgap();
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (!tick10ms) return false; //make sure the rest happen only every 10ms.
|
||||
#else
|
||||
if (!tick10ms) return; //make sure the rest happen only every 10ms.
|
||||
@@ -2769,7 +2768,7 @@ FORCEINLINE void doMixerCalculations()
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
requiredSpeakerVolume = g_eeGeneral.speakerVolume;
|
||||
#endif
|
||||
|
||||
@@ -2779,7 +2778,7 @@ FORCEINLINE void doMixerCalculations()
|
||||
if (s_rangecheck_mode) AUDIO_PLAY(AU_FRSKY_CHEEP);
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (currentSpeakerVolume != requiredSpeakerVolume) {
|
||||
setVolume(requiredSpeakerVolume);
|
||||
currentSpeakerVolume = requiredSpeakerVolume;
|
||||
@@ -2793,7 +2792,7 @@ void perMain()
|
||||
{
|
||||
#if defined(SIMU)
|
||||
doMixerCalculations();
|
||||
#elif !defined(PCBSKY9X)
|
||||
#elif !defined(CPUARM)
|
||||
uint16_t t0 = getTmr16KHz();
|
||||
int16_t delta = (nextMixerEndTime - lastMixerDuration) - t0;
|
||||
if (delta > 0 && delta < MAX_MIXER_DELTA) return;
|
||||
@@ -2808,7 +2807,7 @@ void perMain()
|
||||
#endif
|
||||
|
||||
// TODO same code here + integrate the timer which could be common
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (!Tenms) return;
|
||||
Tenms = 0 ;
|
||||
|
||||
@@ -2822,7 +2821,7 @@ void perMain()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (Eeprom32_process_state != E32_IDLE)
|
||||
ee32_process();
|
||||
else if (TIME_TO_WRITE)
|
||||
@@ -2841,11 +2840,11 @@ void perMain()
|
||||
writeLogs();
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X) && defined(SIMU)
|
||||
#if defined(CPUARM) && defined(SIMU)
|
||||
checkTrims();
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
uint8_t evt = getEvent(false);
|
||||
#else
|
||||
uint8_t evt = getEvent();
|
||||
@@ -2856,7 +2855,7 @@ void perMain()
|
||||
|
||||
checkBacklight();
|
||||
|
||||
#if defined(PCBSKY9X) && defined(FRSKY)
|
||||
#if defined(CPUARM) && defined(FRSKY)
|
||||
check_frsky();
|
||||
#endif
|
||||
|
||||
@@ -2914,7 +2913,7 @@ void perMain()
|
||||
if (g_vbat100mV <= g_eeGeneral.vBatWarn && g_vbat100mV>50) {
|
||||
AUDIO_TX_BATTERY_LOW();
|
||||
}
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
else if (g_eeGeneral.temperatureWarn && getTemperature() >= g_eeGeneral.temperatureWarn) {
|
||||
AUDIO_TX_TEMP_HIGH();
|
||||
}
|
||||
@@ -2929,7 +2928,7 @@ void perMain()
|
||||
int16_t g_ppmIns[8];
|
||||
uint8_t ppmInState = 0; //0=unsync 1..8= wait for value i-1
|
||||
|
||||
#if !defined(SIMU) && !defined(PCBSKY9X)
|
||||
#if !defined(SIMU) && !defined(CPUARM)
|
||||
|
||||
volatile uint8_t g_tmr16KHz; //continuous timer 16ms (16MHz/1024/256) -- 8-bit counter overflow
|
||||
ISR(TIMER_16KHZ_VECT, ISR_NOBLOCK)
|
||||
@@ -3096,7 +3095,7 @@ ISR(TIMER3_CAPT_vect) // G: High frequency noise can cause stack overflo with IS
|
||||
|
||||
// TODO serial_arm and serial_avr
|
||||
|
||||
#if defined (FRSKY) && !defined(PCBSKY9X)
|
||||
#if defined(FRSKY) && !defined(CPUARM)
|
||||
FORCEINLINE void FRSKY_USART0_vect()
|
||||
{
|
||||
if (frskyTxBufferCount > 0) {
|
||||
@@ -3108,7 +3107,7 @@ FORCEINLINE void FRSKY_USART0_vect()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (DSM2_SERIAL) && !defined(PCBSKY9X)
|
||||
#if defined(DSM2_SERIAL) && !defined(CPUARM)
|
||||
FORCEINLINE void DSM2_USART0_vect()
|
||||
{
|
||||
UDR0 = *((uint16_t*)pulses2MHzRPtr); // transmit next byte
|
||||
@@ -3121,7 +3120,7 @@ FORCEINLINE void DSM2_USART0_vect()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(SIMU) && !defined(PCBSKY9X)
|
||||
#if !defined(SIMU) && !defined(CPUARM)
|
||||
#if defined (FRSKY) || defined(DSM2_SERIAL)
|
||||
ISR(USART0_UDRE_vect)
|
||||
{
|
||||
@@ -3198,7 +3197,7 @@ void moveTrimsToOffsets() // copy state of 3 primary to subtrim
|
||||
AUDIO_WARNING2();
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X) || defined(PCBGRUVIN9X)
|
||||
#if defined(CPUARM) || defined(PCBGRUVIN9X)
|
||||
void saveTimers()
|
||||
{
|
||||
for (uint8_t i=0; i<MAX_TIMERS; i++) {
|
||||
@@ -3218,7 +3217,7 @@ volatile rotenc_t g_rotenc[ROTARY_ENCODERS] = {0};
|
||||
|
||||
#ifndef SIMU
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
void stack_paint()
|
||||
{
|
||||
for (uint16_t i=0; i<MENUS_STACK_SIZE; i++)
|
||||
@@ -3308,14 +3307,14 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
|
||||
{
|
||||
eeReadAll();
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
setVolume(g_eeGeneral.speakerVolume);
|
||||
PWM->PWM_CH_NUM[0].PWM_CDTYUPD = g_eeGeneral.backlightBright;
|
||||
#elif defined(VOICE)
|
||||
SET_VOLUME(g_eeGeneral.speakerVolume+7);
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X) && defined(BLUETOOTH)
|
||||
#if defined(BLUETOOTH)
|
||||
btInit();
|
||||
#endif
|
||||
|
||||
@@ -3331,7 +3330,7 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
|
||||
else {
|
||||
doSplash();
|
||||
|
||||
#if defined(PCBSKY9X) && defined(SDCARD)
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
for (int i=0; i<500 && !Card_initialized; i++) {
|
||||
CoTickDelay(1); // 2ms
|
||||
}
|
||||
@@ -3341,7 +3340,7 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
|
||||
checkAlarm();
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X) || defined(PCBGRUVIN9X)
|
||||
#if defined(CPUARM) || defined(PCBGRUVIN9X)
|
||||
if (!g_eeGeneral.unexpectedShutdown) {
|
||||
g_eeGeneral.unexpectedShutdown = 1;
|
||||
eeDirty(EE_GENERAL);
|
||||
@@ -3351,7 +3350,7 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
|
||||
lcdSetContrast();
|
||||
backlightOn();
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
start_ppm_capture();
|
||||
// TODO inside startPulses?
|
||||
s_pulses_paused = false;
|
||||
@@ -3363,7 +3362,7 @@ inline void open9xInit(OPEN9X_INIT_ARGS)
|
||||
wdt_enable(WDTO_500MS);
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
void mixerTask(void * pdata)
|
||||
{
|
||||
s_pulses_paused = true;
|
||||
@@ -3504,11 +3503,11 @@ int main(void)
|
||||
init_rotary_sw();
|
||||
#endif
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
open9xInit(mcusr);
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (BOOTLOADER_REQUEST()) {
|
||||
soft_power_off(); // Only turn power off if necessary
|
||||
|
||||
@@ -3569,14 +3568,12 @@ int main(void)
|
||||
|
||||
perMain();
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
if(heartbeat == HEART_TIMER_PULSES+HEART_TIMER10ms) {
|
||||
if (heartbeat == HEART_TIMER_PULSES+HEART_TIMER10ms) {
|
||||
wdt_reset();
|
||||
heartbeat = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // PCBSKY9X
|
||||
#endif
|
||||
|
||||
#if defined(PCBGRUVIN9X)
|
||||
// Time to switch off
|
||||
|
||||
+28
-20
@@ -54,6 +54,12 @@
|
||||
#define IF_PCBX9D(x)
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define IF_CPUARM(x) x,
|
||||
#else
|
||||
#define IF_CPUARM(x)
|
||||
#endif
|
||||
|
||||
#if defined(RTCLOCK)
|
||||
#define IF_RTCLOCK(x) x,
|
||||
#else
|
||||
@@ -147,7 +153,9 @@
|
||||
#define VARIO_VARIANT 0x0080
|
||||
#define HAPTIC_VARIANT 0x0100 */
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(PCBX9D)
|
||||
#include "board_x9d.h"
|
||||
#elif defined(PCBSKY9X)
|
||||
#include "board_sky9x.h"
|
||||
#elif defined(PCBGRUVIN9X)
|
||||
#include "board_gruvin9x.h"
|
||||
@@ -157,7 +165,7 @@
|
||||
|
||||
#if defined(SIMU)
|
||||
#include "simpgmspace.h"
|
||||
#elif defined(PCBSKY9X)
|
||||
#elif defined(CPUARM)
|
||||
typedef const unsigned char pm_uchar;
|
||||
typedef const char pm_char;
|
||||
typedef const uint16_t pm_uint16_t;
|
||||
@@ -198,7 +206,7 @@ extern void board_init();
|
||||
|
||||
#define PPM_CENTER 1500
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#include "eeprom_arm.h"
|
||||
#include "pulses_arm.h"
|
||||
#else
|
||||
@@ -240,7 +248,7 @@ extern uint8_t s_bind_allowed;
|
||||
|
||||
#if !defined(SIMU)
|
||||
#define assert(x)
|
||||
#if !defined(PCBSKY9X) || !defined(DEBUG)
|
||||
#if !defined(CPUARM) || !defined(DEBUG)
|
||||
#define printf printf_not_allowed
|
||||
#endif
|
||||
#endif
|
||||
@@ -701,7 +709,7 @@ extern char idx2char(int8_t idx);
|
||||
void clearKeyEvents();
|
||||
void pauseEvents(uint8_t enuk);
|
||||
void killEvents(uint8_t enuk);
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
uint8_t getEvent(bool trim);
|
||||
#else
|
||||
uint8_t getEvent();
|
||||
@@ -717,7 +725,7 @@ enum PowerState {
|
||||
e_power_off
|
||||
};
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
uint32_t keyState(EnumKeys enuk);
|
||||
uint32_t check_soft_power();
|
||||
#else
|
||||
@@ -863,13 +871,13 @@ extern uint8_t s_traceWr;
|
||||
extern int8_t s_traceCnt;
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
static inline uint16_t getTmr2MHz() { return TC1->TC_CHANNEL[0].TC_CV; }
|
||||
#else
|
||||
uint16_t getTmr16KHz();
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
uint16_t stack_free(uint8_t tid);
|
||||
#else
|
||||
uint16_t stack_free();
|
||||
@@ -908,7 +916,7 @@ extern uint8_t s_eeDirtyMsk;
|
||||
|
||||
extern void backlightOn();
|
||||
|
||||
#if defined (PCBSKY9X)
|
||||
#if defined (CPUARM)
|
||||
#define __BACKLIGHT_ON (PWM->PWM_CH_NUM[0].PWM_CDTY = g_eeGeneral.backlightBright)
|
||||
#define __BACKLIGHT_OFF (PWM->PWM_CH_NUM[0].PWM_CDTY = 100)
|
||||
#if defined(REVA)
|
||||
@@ -975,7 +983,7 @@ template<class t> FORCEINLINE t limit(t mi, t x, t ma) { return min(max(mi,x),ma
|
||||
uint16_t isqrt32(uint32_t n);
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#if !defined(SIMU)
|
||||
extern "C" {
|
||||
#include <CoOS.h>
|
||||
@@ -997,7 +1005,7 @@ inline void resumeMixerCalculations()
|
||||
#define resumeMixerCalculations()
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X) || defined(PCBGRUVIN9X)
|
||||
#if defined(CPUARM) || defined(PCBGRUVIN9X)
|
||||
void saveTimers();
|
||||
#else
|
||||
#define saveTimers()
|
||||
@@ -1013,7 +1021,7 @@ void eeLoadModel(uint8_t id);
|
||||
void generalDefault();
|
||||
void modelDefault(uint8_t id);
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
inline int32_t calc100toRESX(register int8_t x)
|
||||
{
|
||||
return x * 1024 / 100;
|
||||
@@ -1040,7 +1048,7 @@ extern int16_t calc1000toRESX(int16_t x);
|
||||
extern int16_t calcRESXto1000(int16_t x);
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
// This doesn't need protection on this processor
|
||||
#define tmr10ms_t uint32_t
|
||||
extern volatile tmr10ms_t g_tmr10ms;
|
||||
@@ -1114,7 +1122,7 @@ extern void incSubtrim(uint8_t idx, int16_t inc);
|
||||
extern void instantTrim();
|
||||
extern void moveTrimsToOffsets();
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define ACTIVE_EXPOS_TYPE uint32_t
|
||||
#define ACTIVE_MIXES_TYPE uint64_t
|
||||
#else
|
||||
@@ -1139,7 +1147,7 @@ inline bool isMixActive(uint8_t mix)
|
||||
#define isMixActive(x) false
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define MASK_FSW_TYPE uint32_t // current max = 32 function switches
|
||||
#define MASK_FUNC_TYPE uint32_t // current max = 32 functions
|
||||
#else
|
||||
@@ -1199,7 +1207,7 @@ extern uint16_t jeti_keys;
|
||||
enum AUDIO_SOUNDS {
|
||||
AU_INACTIVITY,
|
||||
AU_TX_BATTERY_LOW,
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
AU_TX_MAH_HIGH,
|
||||
AU_TX_TEMP_HIGH,
|
||||
#endif
|
||||
@@ -1218,7 +1226,7 @@ enum AUDIO_SOUNDS {
|
||||
AU_WARNING2,
|
||||
AU_WARNING3,
|
||||
AU_TRIM_MIDDLE,
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
AU_TRIM_END,
|
||||
#endif
|
||||
AU_TADA,
|
||||
@@ -1251,7 +1259,7 @@ enum AUDIO_SOUNDS {
|
||||
};
|
||||
|
||||
#if defined(AUDIO)
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#include "sky9x/audio.h"
|
||||
#else
|
||||
#include "stock/audio.h"
|
||||
@@ -1288,7 +1296,7 @@ union ReusableBuffer
|
||||
{
|
||||
/* 128 bytes on stock */
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
uint8_t eefs_buffer[BLOCKS]; // 128bytes used by EeFsck
|
||||
#endif
|
||||
|
||||
@@ -1327,7 +1335,7 @@ extern union ReusableBuffer reusableBuffer;
|
||||
|
||||
void checkFlashOnBeep();
|
||||
|
||||
#if defined(FRSKY) || defined(PCBSKY9X)
|
||||
#if defined(FRSKY) || defined(CPUARM)
|
||||
void putsTelemetryValue(uint8_t x, uint8_t y, int16_t val, uint8_t unit, uint8_t att);
|
||||
#endif
|
||||
|
||||
|
||||
+4
-2
@@ -78,7 +78,7 @@ inline const pm_char *SDCARD_ERROR(FRESULT result)
|
||||
extern void sdMountPoll();
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X) && !(defined(SIMU))
|
||||
#if defined(CPUARM) && !(defined(SIMU))
|
||||
extern "C" {
|
||||
extern uint32_t sd_card_ready();
|
||||
extern uint32_t sd_card_mounted();
|
||||
@@ -88,7 +88,9 @@ extern uint32_t sd_card_mounted();
|
||||
#define sd_card_mounted() (true)
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(PCBX9D)
|
||||
#define O9X_FOURCC 0x3378396F // o9x for X9D
|
||||
#elif defined(PCBSKY9X)
|
||||
#define O9X_FOURCC 0x3278396F // o9x for sky9x
|
||||
#elif defined(PCBGRUVIN9X)
|
||||
#define O9X_FOURCC 0x3178396F // o9x for gruvin9x
|
||||
|
||||
+10
-10
@@ -43,7 +43,7 @@ uint16_t dummyport16;
|
||||
const char *eepromFile = NULL;
|
||||
FILE *fp = NULL;
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
Pio Pioa, Piob, Pioc;
|
||||
Pwm pwm;
|
||||
Twi Twio;
|
||||
@@ -63,7 +63,7 @@ extern const char* eeprom_buffer_data;
|
||||
uint8_t eeprom[EESIZE];
|
||||
sem_t *eeprom_write_sem;
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define SWITCH_CASE(swtch, pin, bit) \
|
||||
case -DSW(swtch): \
|
||||
pin &= ~(1<<bit); \
|
||||
@@ -252,7 +252,7 @@ void *eeprom_write_function(void *)
|
||||
while (!sem_wait(eeprom_write_sem)) {
|
||||
if (!eeprom_thread_running)
|
||||
return NULL;
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (eeprom_read_operation) {
|
||||
assert(eeprom_buffer_size);
|
||||
eeprom_read_block(eeprom_buffer_data, (const void *)(int64_t)eeprom_pointer, eeprom_buffer_size);
|
||||
@@ -268,7 +268,7 @@ void *eeprom_write_function(void *)
|
||||
if (fp) {
|
||||
if (fwrite(eeprom_buffer_data, 1, 1, fp) != 1)
|
||||
perror("error in fwrite");
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
sleep(5/*ms*/);
|
||||
#endif
|
||||
}
|
||||
@@ -282,7 +282,7 @@ void *eeprom_write_function(void *)
|
||||
fflush(fp);
|
||||
}
|
||||
}
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
}
|
||||
Spi_complete = 1;
|
||||
#endif
|
||||
@@ -307,7 +307,7 @@ void *main_thread(void *)
|
||||
g_menuStack[0] = menuMainView;
|
||||
g_menuStack[1] = menuModelSelect;
|
||||
|
||||
#ifdef PCBSKY9X
|
||||
#if defined(CPUARM)
|
||||
eeprom_init();
|
||||
#endif
|
||||
|
||||
@@ -320,7 +320,7 @@ void *main_thread(void *)
|
||||
doSplash();
|
||||
#endif
|
||||
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
checkLowEEPROM();
|
||||
#endif
|
||||
|
||||
@@ -401,7 +401,7 @@ void eeprom_read_block (void *pointer_ram,
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
uint16_t stack_free(uint8_t)
|
||||
#else
|
||||
uint16_t stack_free()
|
||||
@@ -431,7 +431,7 @@ namespace simu {
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
FATFS g_FATFS_Obj;
|
||||
#endif
|
||||
|
||||
@@ -568,7 +568,7 @@ FRESULT f_getcwd (TCHAR *path, UINT sz_path)
|
||||
return FR_OK;
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
int32_t Card_state = SD_ST_MOUNTED;
|
||||
uint32_t Card_CSD[4]; // TODO elsewhere
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -96,7 +96,7 @@ typedef const int16_t pm_int16_t;
|
||||
typedef const int8_t pm_int8_t;
|
||||
|
||||
extern sem_t *eeprom_write_sem;
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
extern Pio Pioa, Piob, Pioc;
|
||||
extern Twi Twio;
|
||||
extern Dacc dacc;
|
||||
@@ -266,7 +266,7 @@ extern void rxPdcUsart( void (*pChProcess)(uint8_t x) );
|
||||
|
||||
#define ISR(x) void x()
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
extern volatile uint32_t Tenms;
|
||||
extern uint32_t Master_frequency;
|
||||
#define NVIC_EnableIRQ(x)
|
||||
|
||||
+6
-6
@@ -273,7 +273,7 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
PIOC->PIO_PDSR |= ERSKY9X_DOWN_MASK | ERSKY9X_UP_MASK | ERSKY9X_RIGHT_MASK | ERSKY9X_LEFT_MASK ;
|
||||
ERSKY9X_EXIT_PIO->PIO_PDSR |= ERSKY9X_EXIT_MASK;
|
||||
PIOB->PIO_PDSR |= ERSKY9X_RETURN_MASK;
|
||||
@@ -290,7 +290,7 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
|
||||
|
||||
for(unsigned i=0; i<DIM(keys1);i+=5) {
|
||||
if (getApp()->getKeyState(keys1[i])) {
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
((Pio*)keys1[i+3])->PIO_PDSR &= ~(keys1[i+4]);
|
||||
#elif defined(PCBGRUVIN9X)
|
||||
pin |= (1<<keys1[i+2]);
|
||||
@@ -300,7 +300,7 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#elif defined(PCBGRUVIN9X)
|
||||
pinl = pin;
|
||||
#else
|
||||
@@ -315,7 +315,7 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
|
||||
#else
|
||||
static FXuint keys2[]={KEY_F8, KEY_F7, KEY_F4, KEY_F3, KEY_F6, KEY_F5, KEY_F1, KEY_F2 };
|
||||
#endif
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
PIOA->PIO_PDSR |= (0x00800000 | 0x01000000 | 0x00000002 | 0x00000001);
|
||||
PIOB->PIO_PDSR |= (0x00000050);
|
||||
PIOC->PIO_PDSR |= (0x10000000 | 0x00000400 | 0x00000200);
|
||||
@@ -327,7 +327,7 @@ long Open9xSim::onTimeout(FXObject*,FXSelector,void*)
|
||||
|
||||
for(unsigned i=0; i<DIM(keys2);i++){
|
||||
if(getApp()->getKeyState(keys2[i])) {
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
switch(i) {
|
||||
case 6:
|
||||
PIOA->PIO_PDSR &= ~0x00800000;
|
||||
@@ -425,7 +425,7 @@ void Open9xSim::refreshDiplay()
|
||||
{
|
||||
if (lcd_refresh) {
|
||||
lcd_refresh = false;
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
if (PWM->PWM_CH_NUM[0].PWM_CDTY != 100)
|
||||
#elif defined(PCBGRUVIN9X)
|
||||
if (portc & 1<<OUT_C_LIGHT)
|
||||
|
||||
+31
-2
@@ -108,11 +108,13 @@ inline bool isAudioFileAvailable(uint8_t i, char * filename)
|
||||
#endif
|
||||
|
||||
uint16_t alawTable[256];
|
||||
uint16_t ulawTable[256];
|
||||
|
||||
#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */
|
||||
#define QUANT_MASK (0xf) /* Quantization field mask. */
|
||||
#define SEG_SHIFT (4) /* Left shift for segment number. */
|
||||
#define SEG_MASK (0x70) /* Segment field mask. */
|
||||
#define BIAS (0x84) /* Bias for linear code. */
|
||||
|
||||
static short alaw2linear(unsigned char a_val)
|
||||
{
|
||||
@@ -129,10 +131,29 @@ static short alaw2linear(unsigned char a_val)
|
||||
return (a_val & SIGN_BIT) ? t : -t;
|
||||
}
|
||||
|
||||
void alawInit()
|
||||
static short ulaw2linear(unsigned char u_val)
|
||||
{
|
||||
for (uint32_t i=0; i<256; i++)
|
||||
int t;
|
||||
|
||||
/* Complement to obtain normal u-law value. */
|
||||
u_val = ~u_val;
|
||||
|
||||
/*
|
||||
* Extract and bias the quantization bits. Then
|
||||
* shift up by the segment number and subtract out the bias.
|
||||
*/
|
||||
t = ((u_val & QUANT_MASK) << 3) + BIAS;
|
||||
t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT;
|
||||
|
||||
return (u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS);
|
||||
}
|
||||
|
||||
void codecsInit()
|
||||
{
|
||||
for (uint32_t i=0; i<256; i++) {
|
||||
alawTable[i] = (0x8000 + alaw2linear(i)) >> 4;
|
||||
ulawTable[i] = (0x8000 + ulaw2linear(i)) >> 4;
|
||||
}
|
||||
}
|
||||
|
||||
AudioQueue audioQueue;
|
||||
@@ -155,6 +176,7 @@ extern uint16_t Sine_values[];
|
||||
|
||||
#define CODEC_ID_PCM_S16LE 1
|
||||
#define CODEC_ID_PCM_ALAW 6
|
||||
#define CODEC_ID_PCM_MULAW 7
|
||||
|
||||
#ifndef SIMU
|
||||
void audioTask(void* pdata)
|
||||
@@ -243,6 +265,13 @@ void AudioQueue::sdWakeup(AudioContext & context)
|
||||
for (i = read; i < WAV_BUFFER_SIZE; i++)
|
||||
wavSamplesBuffer[i] = 0x8000;
|
||||
}
|
||||
else if (context.pcmCodec == CODEC_ID_PCM_MULAW) {
|
||||
int32_t i;
|
||||
for (i = read - 1; i >= 0; i--)
|
||||
wavSamplesBuffer[i] = ulawTable[((uint8_t *) wavSamplesBuffer)[i]];
|
||||
for (i = read; i < WAV_BUFFER_SIZE; i++)
|
||||
wavSamplesBuffer[i] = 0x8000;
|
||||
}
|
||||
|
||||
read /= 2;
|
||||
register Dacc *dacptr = DACC;
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ class AudioQueue {
|
||||
|
||||
extern AudioQueue audioQueue;
|
||||
|
||||
void alawInit();
|
||||
void codecsInit();
|
||||
void audioEvent(uint8_t e, uint8_t f=BEEP_DEFAULT_FREQ);
|
||||
|
||||
#define AUDIO_TADA() audioEvent(AU_TADA)
|
||||
|
||||
@@ -80,7 +80,7 @@ void menuStatisticsView(uint8_t event)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define MENU_DEBUG_COL_OFS (13*FW)
|
||||
#else
|
||||
#define MENU_DEBUG_COL_OFS (14*FW)
|
||||
@@ -92,7 +92,7 @@ void menuStatisticsDebug(uint8_t event)
|
||||
|
||||
switch(event)
|
||||
{
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
case EVT_KEY_LONG(KEY_MENU):
|
||||
g_eeGeneral.mAhUsed = 0;
|
||||
g_eeGeneral.globalTimer = 0;
|
||||
@@ -104,7 +104,7 @@ void menuStatisticsDebug(uint8_t event)
|
||||
break;
|
||||
#endif
|
||||
case EVT_KEY_FIRST(KEY_MENU):
|
||||
#if !defined(PCBSKY9X)
|
||||
#if !defined(CPUARM)
|
||||
g_tmr1Latency_min = 0xff;
|
||||
g_tmr1Latency_max = 0;
|
||||
#endif
|
||||
@@ -120,7 +120,7 @@ void menuStatisticsDebug(uint8_t event)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#if !defined(REVA)
|
||||
lcd_putsLeft(1*FH, STR_CPU_CURRENT);
|
||||
putsTelemetryValue(MENU_DEBUG_COL_OFS, 1*FH, getCurrent(), UNIT_MILLIAMPS, 0);
|
||||
|
||||
@@ -64,7 +64,7 @@ const pm_char STR_OPEN9X[] PROGMEM =
|
||||
ISTR(VFSWRESET)
|
||||
ISTR(FUNCSOUNDS)
|
||||
ISTR(VTELEMCHNS)
|
||||
#if defined(FRSKY) || defined(PCBSKY9X)
|
||||
#if defined(FRSKY) || defined(CPUARM)
|
||||
ISTR(VTELEMUNIT)
|
||||
ISTR(VALARM)
|
||||
ISTR(VALARMFN)
|
||||
@@ -87,10 +87,10 @@ const pm_char STR_OPEN9X[] PROGMEM =
|
||||
#if defined(DSM2)
|
||||
ISTR(DSM2MODE)
|
||||
#endif
|
||||
#if defined(PCBGRUVIN9X) || defined (PCBSKY9X)
|
||||
#if defined(PCBGRUVIN9X) || defined (CPUARM)
|
||||
ISTR(DATETIME)
|
||||
#endif
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
ISTR(VLCD)
|
||||
#endif
|
||||
;
|
||||
@@ -235,7 +235,7 @@ const pm_char STR_EEPROMOVERFLOW[] PROGMEM = TR_EEPROMOVERFLOW;
|
||||
const pm_char STR_TRIMS2OFFSETS[] PROGMEM = TR_TRIMS2OFFSETS;
|
||||
const pm_char STR_MENURADIOSETUP[] PROGMEM = TR_MENURADIOSETUP;
|
||||
|
||||
#if defined(PCBGRUVIN9X) || defined(PCBSKY9X)
|
||||
#if defined(PCBGRUVIN9X) || defined(CPUARM)
|
||||
const pm_char STR_MENUDATEANDTIME[] PROGMEM = TR_MENUDATEANDTIME;
|
||||
#endif
|
||||
|
||||
@@ -294,18 +294,18 @@ const pm_char STR_LATITUDE[] PROGMEM = TR_LATITUDE;
|
||||
const pm_char STR_LONGITUDE[] PROGMEM = TR_LONGITUDE;
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X) || defined(PCBGRUVIN9X)
|
||||
#if defined(CPUARM) || defined(PCBGRUVIN9X)
|
||||
const pm_char STR_SHUTDOWN[] PROGMEM = TR_SHUTDOWN;
|
||||
#endif
|
||||
|
||||
const pm_char STR_BATT_CALIB[] PROGMEM = TR_BATT_CALIB;
|
||||
|
||||
#if defined(PCBSKY9X) || defined(FRSKY)
|
||||
#if defined(CPUARM) || defined(FRSKY)
|
||||
const pm_char STR_VOLTAGE[] PROGMEM = TR_VOLTAGE;
|
||||
const pm_char STR_CURRENT[] PROGMEM = TR_CURRENT;
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
const pm_char STR_CURRENT_CALIB[] PROGMEM = TR_CURRENT_CALIB;
|
||||
#endif
|
||||
|
||||
|
||||
+9
-9
@@ -97,7 +97,7 @@ extern const pm_char STR_OPEN9X[];
|
||||
#define OFS_VFSWRESET (OFS_VFSWFUNC + sizeof(TR_VFSWFUNC))
|
||||
#define OFS_FUNCSOUNDS (OFS_VFSWRESET + sizeof(TR_VFSWRESET))
|
||||
#define OFS_VTELEMCHNS (OFS_FUNCSOUNDS + sizeof(TR_FUNCSOUNDS))
|
||||
#if defined(FRSKY) || defined(PCBSKY9X)
|
||||
#if defined(FRSKY) || defined(CPUARM)
|
||||
#define OFS_VTELEMUNIT (OFS_VTELEMCHNS + sizeof(TR_VTELEMCHNS))
|
||||
#define OFS_VALARM (OFS_VTELEMUNIT + sizeof(TR_VTELEMUNIT))
|
||||
#define OFS_VALARMFN (OFS_VALARM + sizeof(TR_VALARM))
|
||||
@@ -132,10 +132,10 @@ extern const pm_char STR_OPEN9X[];
|
||||
#else
|
||||
#define OFS_ENDDSM2 (OFS_VTMRMODES + sizeof(TR_VTMRMODES))
|
||||
#endif
|
||||
#if defined(PCBGRUVIN9X) || defined (PCBSKY9X)
|
||||
#if defined(PCBGRUVIN9X) || defined(CPUARM)
|
||||
#define OFS_DATETIME (OFS_ENDDSM2)
|
||||
#endif
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define OFS_VLCD (OFS_DATETIME + sizeof(TR_DATETIME))
|
||||
#endif
|
||||
|
||||
@@ -165,7 +165,7 @@ extern const pm_char STR_OPEN9X[];
|
||||
#define STR_FUNCSOUNDS (STR_OPEN9X + OFS_FUNCSOUNDS)
|
||||
#define STR_VTELEMCHNS (STR_OPEN9X + OFS_VTELEMCHNS)
|
||||
|
||||
#if defined(FRSKY) || defined(PCBSKY9X)
|
||||
#if defined(FRSKY) || defined(CPUARM)
|
||||
#define STR_VTELEMUNIT (STR_OPEN9X + OFS_VTELEMUNIT)
|
||||
#define STR_VALARM (STR_OPEN9X + OFS_VALARM)
|
||||
#define STR_VALARMFN (STR_OPEN9X + OFS_VALARMFN)
|
||||
@@ -199,11 +199,11 @@ extern const pm_char STR_OPEN9X[];
|
||||
#define STR_VRENCODERS (STR_OPEN9X + OFS_VRENCODERS)
|
||||
#endif
|
||||
|
||||
#if defined(PCBGRUVIN9X) || defined(PCBSKY9X)
|
||||
#if defined(PCBGRUVIN9X) || defined(CPUARM)
|
||||
#define STR_DATETIME (STR_OPEN9X + OFS_DATETIME)
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define STR_VLCD (STR_OPEN9X + OFS_VLCD)
|
||||
#endif
|
||||
|
||||
@@ -382,18 +382,18 @@ extern const pm_char STR_LATITUDE[];
|
||||
extern const pm_char STR_LONGITUDE[];
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X) || defined(PCBGRUVIN9X)
|
||||
#if defined(CPUARM) || defined(PCBGRUVIN9X)
|
||||
extern const pm_char STR_SHUTDOWN[];
|
||||
#endif
|
||||
|
||||
extern const pm_char STR_BATT_CALIB[];
|
||||
|
||||
#if defined(PCBSKY9X) || defined(FRSKY)
|
||||
#if defined(CPUARM) || defined(FRSKY)
|
||||
extern const pm_char STR_VOLTAGE[];
|
||||
extern const pm_char STR_CURRENT[];
|
||||
#endif
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
extern const pm_char STR_CURRENT_CALIB[];
|
||||
#define LEN_CALIB_FIELDS (PSIZE(TR_BATT_CALIB) > PSIZE(TR_CURRENT_CALIB) ? PSIZE(TR_BATT_CALIB) : PSIZE(TR_CURRENT_CALIB))
|
||||
#else
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
#define TR_PLAY_TRACK "[PlayTrack]"
|
||||
#define TR_PLAY_VALUE "[PlayValue]"
|
||||
#endif
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#if defined(SDCARD)
|
||||
#define TR_SDCLOGS "SD Logs\0 "
|
||||
#else
|
||||
@@ -350,7 +350,7 @@
|
||||
#define STR_US (STR_TMR1LATMAXUS+12)
|
||||
#define TR_TMR1LATMINUS "Tmr1Lat min\006us"
|
||||
#define TR_TMR1JITTERUS "Tmr1 Jitter\006us"
|
||||
#if defined(PCBSKY9X)
|
||||
#if defined(CPUARM)
|
||||
#define TR_TMIXMAXMS "Tmix max\012ms"
|
||||
#else
|
||||
#define TR_TMIXMAXMS "Tmix max\014ms"
|
||||
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/Audio/Audio.c
|
||||
* @author X9D Application Team
|
||||
* @version V 0.2
|
||||
* @date 12-JULY-2012
|
||||
* @brief This file provides drivers foe Audio module.I2S AND GPIO Included.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "stm32f2xx.h"
|
||||
#include "Audio.h"
|
||||
#include "hal.h"
|
||||
|
||||
|
||||
static
|
||||
void Audio_GPIO_Init()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
/* EnableI2C GPIO clocks */
|
||||
RCC_AHB1PeriphClockCmd(CODEC_I2S_GPIO_CLOCK, ENABLE);//GPIOA C
|
||||
|
||||
/* CODEC_I2S pins configuration: WS, SCK and SD pins -----------------------------*/
|
||||
GPIO_InitStructure.GPIO_Pin = CODEC_I2S_SCK_PIN | CODEC_I2S_SD_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(CODEC_I2S_GPIO, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = CODEC_I2S_WS_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(CODEC_I2S_WS_GPIO, &GPIO_InitStructure);
|
||||
|
||||
/* Connect pins to I2S peripheral */
|
||||
GPIO_PinAFConfig(CODEC_I2S_WS_GPIO, CODEC_I2S_WS_PINSRC, CODEC_I2S_GPIO_AF);
|
||||
GPIO_PinAFConfig(CODEC_I2S_GPIO, CODEC_I2S_SCK_PINSRC, CODEC_I2S_GPIO_AF);
|
||||
GPIO_PinAFConfig(CODEC_I2S_GPIO, CODEC_I2S_SD_PINSRC, CODEC_I2S_GPIO_AF);
|
||||
|
||||
#ifdef CODEC_MCLK_ENABLED
|
||||
/* CODEC_I2S pins configuration: MCK pin */
|
||||
GPIO_InitStructure.GPIO_Pin = CODEC_I2S_MCK_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(CODEC_I2S_MCK_GPIO, &GPIO_InitStructure);
|
||||
/* Connect pins to I2S peripheral */
|
||||
GPIO_PinAFConfig(CODEC_I2S_MCK_GPIO, CODEC_I2S_MCK_PINSRC, CODEC_I2S_GPIO_AF);
|
||||
#endif /* CODEC_MCLK_ENABLED */
|
||||
|
||||
/*CODEC_I2S_MUTE & CODEC_I2S_FLT GPIO CONFIG*/
|
||||
GPIO_InitStructure.GPIO_Pin = CODEC_I2S_MUTE;// | CODEC_I2S_FLT;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(CODEC_I2S_GPIO, &GPIO_InitStructure);
|
||||
GPIO_SetBits(CODEC_I2S_GPIO,CODEC_I2S_MUTE);
|
||||
// GPIO_SetBits(CODEC_I2S_CTL_GPIO,CODEC_I2S_FLT);
|
||||
}
|
||||
|
||||
void I2S2_Init()
|
||||
{
|
||||
I2S_InitTypeDef I2S_InitStructure;
|
||||
|
||||
Audio_GPIO_Init();
|
||||
|
||||
/*CONFIG the I2S_RCC ,MUST before enabling the I2S APB clock*/
|
||||
//PLLI2SN 302,PLLI2SR 2,I2SDIV 53,I2SODD 1,FS 44.1KHZ,16bit,Error 0.0011%
|
||||
RCC_PLLI2SConfig(302,2);
|
||||
RCC_PLLI2SCmd(ENABLE);
|
||||
RCC_I2SCLKConfig(RCC_I2S2CLKSource_PLLI2S);
|
||||
|
||||
/* Enable the CODEC_I2S peripheral clock */
|
||||
RCC_APB1PeriphClockCmd(CODEC_I2S_CLK, ENABLE);
|
||||
/* CODEC_I2S peripheral configuration */
|
||||
SPI_I2S_DeInit(CODEC_I2S);
|
||||
I2S_InitStructure.I2S_AudioFreq = AudioFreq;
|
||||
I2S_InitStructure.I2S_Standard = I2S_Standard_Phillips;
|
||||
I2S_InitStructure.I2S_DataFormat = I2S_DataFormat_16b;
|
||||
I2S_InitStructure.I2S_CPOL = I2S_CPOL_Low;//clk 0 when idle state
|
||||
I2S_InitStructure.I2S_Mode = I2S_Mode_MasterTx;
|
||||
#ifdef CODEC_MCLK_ENABLED
|
||||
I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Enable;
|
||||
#elif defined(CODEC_MCLK_DISABLED)
|
||||
I2S_InitStructure.I2S_MCLKOutput = I2S_MCLKOutput_Disable;
|
||||
#else
|
||||
#error "No selection for the MCLK output has been defined !"
|
||||
#endif /* CODEC_MCLK_ENABLED */
|
||||
|
||||
/* Initialize the I2S peripheral with the structure above */
|
||||
I2S_Init(CODEC_I2S, &I2S_InitStructure);
|
||||
I2S_Cmd(CODEC_I2S,ENABLE);
|
||||
//interrupt
|
||||
#ifdef CODEC_USE_INT
|
||||
SPI_I2S_ITConfig(CODEC_I2S,SPI_I2S_IT_TXE,ENABLE);
|
||||
#elif defined(CODEC_USE_DMA)
|
||||
#error "DMA is not initialized"
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/Audio/Audio.h
|
||||
* @author X9D Application Team
|
||||
* @version V 0.2
|
||||
* @date 12-JULY-2011
|
||||
* @brief Header for Audio.c.
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef _AUDIO_H_
|
||||
#define _AUDIO_H_
|
||||
|
||||
#include "stdint.h"
|
||||
#include "Macro_define.h"
|
||||
|
||||
extern const uint16_t AUDIO_SAMPLE[];
|
||||
//
|
||||
void I2S2_Init();
|
||||
|
||||
|
||||
typedef struct{
|
||||
uint32_t size; //number of chars per font
|
||||
uint16_t *base; //font addr
|
||||
}A_SAMPLE;
|
||||
|
||||
extern A_SAMPLE demo_sample;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/Macro_define.h
|
||||
* @author X9D Application Team
|
||||
* @Hardware version V0.2
|
||||
* @date 11-July-2012
|
||||
* @brief This file provides Macro defines for testing or working.
|
||||
* *
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef _Macro_Define_H_
|
||||
#define _Macro_Define_H_
|
||||
#include "stm32f2xx.h"
|
||||
|
||||
#define assert(x) do{ if(!(x)) while(1);}while(0);
|
||||
|
||||
#define udelay(x) do{ uint32_t temp; temp=((x+0)<<3); while(--temp);}while(0)
|
||||
#define delayUsec(x) udelay(x)
|
||||
|
||||
#define LCD_TEST
|
||||
#define AUDIO_TEST
|
||||
//#define I2C_TEST
|
||||
//#define ADC_TEST
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/adc/adc.c
|
||||
* @author X9D Application Team
|
||||
* @Hardware version V0.2
|
||||
* @date 11-July-2012
|
||||
* @brief This file provides adc Init and drivers.
|
||||
* *
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "stm32f2xx.h"
|
||||
#include "adc.h"
|
||||
#include "hal.h"
|
||||
#include "msg_que.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "item.h"
|
||||
|
||||
|
||||
|
||||
#define ADC1_DR_ADDRESS ((uint32_t)0x4001204C)
|
||||
//#define ADC2_DR_ADDRESS ((uint32_t)0x4001214C)
|
||||
//#define ADC3_DR_ADDRESS ((uint32_t)0x4001224C)
|
||||
|
||||
__IO uint16_t ADC1ConvertedValue[10] = {0};
|
||||
|
||||
|
||||
void adc_clk_init()
|
||||
{
|
||||
/* Enable peripheral clocks *************************************************/
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOADC, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void adc_gpio_init()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
//AIN state
|
||||
/* Configure ADC1 Channel5 pin as analog input ******************************/
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
|
||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
|
||||
}
|
||||
void adc_init() //one adc
|
||||
{
|
||||
ADC_InitTypeDef ADC_InitStructure;
|
||||
ADC_CommonInitTypeDef ADC_CommonInitStructure;
|
||||
DMA_InitTypeDef DMA_InitStructure;
|
||||
|
||||
adc_clk_init();//enable
|
||||
adc_gpio_init();//AIN
|
||||
|
||||
/* ADC1 regular channel configuration ************************************/
|
||||
ADC_InitStructure.ADC_Resolution = ADC_Resolution_10b;
|
||||
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
|
||||
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; //
|
||||
ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; //
|
||||
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1; //
|
||||
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
|
||||
ADC_InitStructure.ADC_NbrOfConversion = 1;//
|
||||
ADC_Init(ADC1, &ADC_InitStructure);
|
||||
|
||||
/* ADC Common configuration ********************** ***************************/
|
||||
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;//one ADC
|
||||
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_6Cycles;//6* 1/30M
|
||||
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;//
|
||||
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2; //60M/2
|
||||
ADC_CommonInit(&ADC_CommonInitStructure);
|
||||
|
||||
/* ADC1 regular channel configuration */
|
||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_15, 1, ADC_SampleTime_3Cycles);//
|
||||
|
||||
|
||||
/* DMA2 Stream0 channel0 configuration **************************************/
|
||||
DMA_InitStructure.DMA_Channel = DMA_Channel_0;
|
||||
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC1_DR_ADDRESS;
|
||||
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)ADC1ConvertedValue;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
|
||||
DMA_InitStructure.DMA_BufferSize = 1;
|
||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
|
||||
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
|
||||
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
|
||||
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
|
||||
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
|
||||
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
|
||||
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
|
||||
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
|
||||
DMA_Init(DMA2_Stream0, &DMA_InitStructure);
|
||||
DMA_Cmd(DMA2_Stream0, ENABLE);
|
||||
|
||||
/* Enable DMA request after last transfer (Single-ADC mode) */
|
||||
ADC_DMARequestAfterLastTransferCmd(ADC1, ENABLE);
|
||||
|
||||
/* Enable ADC1 DMA */
|
||||
ADC_DMACmd(ADC1, ENABLE);
|
||||
|
||||
/* Enable ADC1 */
|
||||
ADC_Cmd(ADC1, ENABLE);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/adc/adc.h
|
||||
* @author X9D Application Team
|
||||
* @Hardware version V0.2
|
||||
* @date 11-July-2012
|
||||
* @brief This file provides adc Init and drivers.
|
||||
* *
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef _ADC_INIT_H_
|
||||
#define _ADC_INIT_H_
|
||||
|
||||
|
||||
void adc_init();
|
||||
#endif
|
||||
@@ -0,0 +1,135 @@
|
||||
#include "stm32f2xx.h"
|
||||
#include "hal.h"
|
||||
#include "buttons.h"
|
||||
|
||||
|
||||
void Buttons_Init() //上拉输入状态
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
/* GPIOC GPIOD clock enable */
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBUTTON, ENABLE);
|
||||
|
||||
/* GPIO Configuration*/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_BUTTON_UP | PIN_BUTTON_ENTER | PIN_BUTTON_DOWN | PIN_TRIM3_UP | PIN_TRIM3_DN
|
||||
| PIN_TRIM4_UP |PIN_TRIM4_DN | PIN_SW_A_L | PIN_SW_D_L | PIN_SW_F_H | PIN_SW_G_H
|
||||
| PIN_SW_G_L | PIN_SW_H_L;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_Init(GPIOE, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_HOME | PIN_ESC | PIN_PAGE;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//复位状态,IN时应该忽略
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_Init(GPIOD, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_TRIM1_UP | PIN_TRIM1_DN | PIN_TRIM2_UP | PIN_TRIM2_DN;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SW_B_H | PIN_SW_B_L | PIN_SW_C_H | PIN_SW_C_L | PIN_SW_D_H | PIN_SW_E_H | PIN_SW_F_L;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_SW_E_L;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
}
|
||||
|
||||
//short pin_status=0;
|
||||
//short pin_status1=0;
|
||||
|
||||
void detect_buttons()
|
||||
{
|
||||
/*short t_pin;short t_pin1;
|
||||
static short key_down_interval;
|
||||
key_down_interval++;//计数循环多少次有键按下
|
||||
|
||||
t_pin = (~(GPIOC->IDR)) &(PIN_BUTTON_UP | PIN_BUTTON_ENTER | PIN_BUTTON_DOWN);
|
||||
t_pin1=(~(GPIOB->IDR)) &(PIN_POWER | PIN_BIND);
|
||||
|
||||
if( (t_pin1 & PIN_BIND) && (!(pin_status1 & PIN_BIND))&&(!(t_pin1 & PIN_POWER)) )
|
||||
{
|
||||
}
|
||||
if( (t_pin1 & PIN_POWER) && (!(pin_status1 & PIN_POWER)))
|
||||
{
|
||||
|
||||
}
|
||||
if( (pin_status1 & PIN_BIND) && (pin_status1 & PIN_POWER ))
|
||||
{
|
||||
static char t_pin_bind;
|
||||
t_pin_bind++;//这个变量
|
||||
if( (t_pin_bind ==39) || (t_pin_bind==69)){
|
||||
t_pin_bind =40;
|
||||
//SetIDProc(0,0,0,t_pin_bind);
|
||||
}
|
||||
}
|
||||
|
||||
if( (t_pin & PIN_BUTTON_UP) && (!(pin_status & PIN_BUTTON_UP )) )
|
||||
{
|
||||
|
||||
}
|
||||
if( (t_pin & PIN_BUTTON_ENTER) && (!(pin_status & PIN_BUTTON_ENTER )) )
|
||||
{
|
||||
|
||||
}
|
||||
if( (t_pin & PIN_BUTTON_DOWN) && (!(pin_status & PIN_BUTTON_DOWN )) )
|
||||
{
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
if( (pin_status & PIN_BUTTON_UP))
|
||||
{
|
||||
static char t_pin_up;
|
||||
t_pin_up++;//这个变量
|
||||
if( (t_pin_up ==9) || (t_pin_up==22)){
|
||||
t_pin_up =10;
|
||||
|
||||
}else if((!(t_pin & PIN_BUTTON_UP)))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if( (pin_status & PIN_BUTTON_ENTER))
|
||||
{
|
||||
static char t_pin_enter;
|
||||
t_pin_enter++;
|
||||
if( (t_pin_enter ==9) || (t_pin_enter ==22)){
|
||||
t_pin_enter =10;
|
||||
|
||||
}else if((!(t_pin & PIN_BUTTON_ENTER))){
|
||||
if(t_pin_enter<9)
|
||||
|
||||
t_pin_enter =0;
|
||||
}
|
||||
}
|
||||
|
||||
if( (pin_status & PIN_BUTTON_DOWN))
|
||||
{
|
||||
static char t_pin_down;
|
||||
t_pin_down++;
|
||||
if( (t_pin_down ==9) || (t_pin_down==22) ){
|
||||
t_pin_down =10;
|
||||
|
||||
}else if((!(t_pin & PIN_BUTTON_DOWN))){
|
||||
if(t_pin_down<9)
|
||||
|
||||
t_pin_down =0;
|
||||
}
|
||||
}
|
||||
|
||||
pin_status = t_pin;
|
||||
pin_status1=t_pin1;*/
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#ifndef _BUTTONS_H_
|
||||
#define _BUTTONS_H_
|
||||
|
||||
|
||||
#endif
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
#ifndef _HAL_
|
||||
#define _HAL_
|
||||
|
||||
/********************************
|
||||
GPIOS----所有涉及GPIO的定义
|
||||
*******************************************/
|
||||
|
||||
#define RCC_AHB1Periph_GPIOBUTTON (RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE)
|
||||
//Button
|
||||
#define PIN_BUTTON_UP GPIO_Pin_0 //SW3 PE.10
|
||||
#define PIN_BUTTON_ENTER GPIO_Pin_1 //SW2 PE.11
|
||||
#define PIN_BUTTON_DOWN GPIO_Pin_2 //SW1 PE.12
|
||||
#define PIN_HOME GPIO_Pin_11 //SW4 PD.07
|
||||
#define PIN_ESC GPIO_Pin_12 //SW5 PD.03
|
||||
#define PIN_PAGE GPIO_Pin_10 //SW6 PD.02
|
||||
|
||||
//Trim
|
||||
#define PIN_TRIM1_UP GPIO_Pin_3 //PC.03
|
||||
#define PIN_TRIM1_DN GPIO_Pin_2 //PC.02
|
||||
#define PIN_TRIM2_UP GPIO_Pin_1 //PC.01
|
||||
#define PIN_TRIM2_DN GPIO_Pin_13 //PC.13
|
||||
#define PIN_TRIM3_UP GPIO_Pin_4 //PE.04
|
||||
#define PIN_TRIM3_DN GPIO_Pin_3 //PE.03
|
||||
#define PIN_TRIM4_UP GPIO_Pin_6 //PE.06
|
||||
#define PIN_TRIM4_DN GPIO_Pin_5 //PE.05
|
||||
|
||||
//Switch
|
||||
#define PIN_SW_A_L GPIO_Pin_14 //PE.14
|
||||
#define PIN_SW_B_H GPIO_Pin_3 //PB.03
|
||||
#define PIN_SW_B_L GPIO_Pin_4 //PB.04
|
||||
#define PIN_SW_C_H GPIO_Pin_5 //PB.05
|
||||
#define PIN_SW_C_L GPIO_Pin_6 //PB.06
|
||||
#define PIN_SW_D_H GPIO_Pin_7 //PB.07
|
||||
#define PIN_SW_D_L GPIO_Pin_2 //PE.02
|
||||
#define PIN_SW_E_H GPIO_Pin_0 //PB.00
|
||||
#define PIN_SW_E_L GPIO_Pin_5 //PA.05
|
||||
#define PIN_SW_F_H GPIO_Pin_7 //PE.07
|
||||
#define PIN_SW_F_L GPIO_Pin_1 //PB.01
|
||||
#define PIN_SW_G_H GPIO_Pin_9 //PE.09
|
||||
#define PIN_SW_G_L GPIO_Pin_8 //PE.08
|
||||
#define PIN_SW_H_L GPIO_Pin_13 //PE.13
|
||||
|
||||
//ADC---8个
|
||||
#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_7 //PA.07
|
||||
#define PIN_MVOLT GPIO_Pin_0 //PC.00
|
||||
#define RCC_AHB1Periph_GPIOADC RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC
|
||||
|
||||
//DAC---1个
|
||||
#define PIN_AUDIO_DAC GPIO_Pin_4 //PA.04
|
||||
|
||||
//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
|
||||
|
||||
//Smart-Port
|
||||
#define PIN_SPORT_ON GPIO_Pin_4 //PD.04
|
||||
#define PIN_SPORT_TX GPIO_Pin_5 //PD.05
|
||||
#define PIN_SPORT_RX GPIO_Pin_6 //PD.06
|
||||
|
||||
//Trainer Port
|
||||
#define PIN_TR_PPM_IN GPIO_Pin_8 //PC.08
|
||||
#define PIN_TR_PPM_OUT GPIO_Pin_9 //PC.09
|
||||
|
||||
//Cppm
|
||||
#define RCC_AHB1Periph_GPIOCPPM RCC_AHB1Periph_GPIOA
|
||||
#define PIN_CPPM_OUT GPIO_Pin_8 //PA.08
|
||||
#define GPIOCPPM GPIOA
|
||||
#define GPIO_PinSource_CPPM GPIO_PinSource8
|
||||
//Heart Beat
|
||||
#define PIN_HEART_BEAT GPIO_Pin_7 //PC.07
|
||||
|
||||
//Update UART----RS232 ---UART3
|
||||
#define PIN_UPDATE_UART_TX GPIO_Pin_10 //PB.10
|
||||
#define PIN_UPDATE_UART_RX GPIO_Pin_11 //PB.11
|
||||
|
||||
//USB_OTG
|
||||
#define PIN_FS_VBUS GPIO_Pin_9 //PA.09
|
||||
#define PIN_FS_ID GPIO_Pin_10 //PA.10
|
||||
#define PIN_FS_DM GPIO_Pin_11 //PA.11
|
||||
#define PIN_FS_DP GPIO_Pin_12 //PA.12
|
||||
|
||||
//BackLight PB8
|
||||
#define RCC_AHB1Periph_GPIOBL RCC_AHB1Periph_GPIOB
|
||||
#define GPIO_Pin_BL GPIO_Pin_8 //PB.08
|
||||
#define GPIOBL GPIOB
|
||||
#define GPIO_PinSource_BL GPIO_PinSource8
|
||||
|
||||
//LCD GPIOD 10-14 模拟spi
|
||||
#define RCC_AHB1Periph_LCD RCC_AHB1Periph_GPIOD
|
||||
#define GPIO_LCD 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 //pd12 test //RESET occurs when powered up,but should delay before initialize
|
||||
|
||||
//Audio----I2S3
|
||||
//#define CODEC_I2S_ADDRESS 0x4000380C
|
||||
#define CODEC_I2S SPI3
|
||||
#define CODEC_I2S_CLK RCC_APB1Periph_SPI3
|
||||
#define CODEC_I2S_GPIO_AF GPIO_AF_SPI3
|
||||
#define CODEC_I2S_IRQ SPI3_IRQn
|
||||
#define CODEC_I2S_GPIO_CLOCK (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC )//| RCC_AHB1Periph_GPIOE)
|
||||
#define CODEC_I2S_WS_PIN GPIO_Pin_15 //PA.15
|
||||
#define CODEC_I2S_SCK_PIN GPIO_Pin_10 //PC.10
|
||||
#define CODEC_I2S_SD_PIN GPIO_Pin_12 //PC.12
|
||||
#define CODEC_I2S_MCK_PIN GPIO_Pin_6 //DISABLED
|
||||
#define CODEC_I2S_WS_PINSRC GPIO_PinSource15
|
||||
#define CODEC_I2S_SCK_PINSRC GPIO_PinSource10
|
||||
#define CODEC_I2S_SD_PINSRC GPIO_PinSource12
|
||||
#define CODEC_I2S_MCK_PINSRC GPIO_PinSource6
|
||||
#define CODEC_I2S_GPIO GPIOC
|
||||
#define CODEC_I2S_MCK_GPIO GPIOC
|
||||
#define CODEC_I2S_WS_GPIO GPIOA
|
||||
#define CODEC_I2S_MUTE GPIO_Pin_11 //PC.11
|
||||
//#define CODEC_I2S_FLT GPIO_Pin_ //IIR/FIR
|
||||
//#define CODEC_I2S_MODE GPIO_Pin_ //Connect to GND=I2S_STANDARD
|
||||
|
||||
//Eeprom与cat5137
|
||||
#define I2C_EE_GPIO GPIOE
|
||||
#define I2C_EE_WP_GPIO GPIOB
|
||||
#define I2C_EE_GPIO_CLK RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOE
|
||||
#define I2C_EE_SCL GPIO_Pin_1 //PE1
|
||||
#define I2C_EE_SDA GPIO_Pin_0 //PE0
|
||||
#define I2C_EE_WP GPIO_Pin_9 //PB9
|
||||
|
||||
//SD卡---spi2
|
||||
#define SPI_SD SPI2
|
||||
#define GPIO_AF_SD GPIO_AF_SPI2
|
||||
#define RCC_AHB1Periph_GPIO_CS RCC_AHB1Periph_GPIOB
|
||||
#define GPIO_SPI_SD GPIOB
|
||||
#define GPIO_Pin_SPI_SD_CS GPIO_Pin_12 //PB.12
|
||||
#define GPIO_Pin_SPI_SD_SCK GPIO_Pin_13 //PB.13
|
||||
#define GPIO_Pin_SPI_SD_MISO GPIO_Pin_14 //PB.14
|
||||
#define GPIO_Pin_SPI_SD_MOSI GPIO_Pin_15 //PB.15
|
||||
#define GPIO_PinSource_CS GPIO_PinSource12
|
||||
#define GPIO_PinSource_SCK GPIO_PinSource13
|
||||
#define GPIO_PinSource_MISO GPIO_PinSource14
|
||||
#define GPIO_PinSource_MOSI GPIO_PinSource15
|
||||
#define RCC_APBPeriphClockCmd_SPI_SD RCC_APB1PeriphClockCmd
|
||||
#define RCC_APBPeriph_SPI_SD RCC_APB1Periph_SPI2
|
||||
#define RCC_AHBxPeriph_GPIO_WP RCC_AHB1Periph_GPIOD
|
||||
#define RCC_AHBxPeriph_GPIO_CP RCC_AHB1Periph_GPIOD
|
||||
#define GPIO_Mode_WP GPIO_Mode_OUT//lock?
|
||||
#define GPIO_Mode_CP GPIO_Mode_IN //
|
||||
#define GPIO_Pin_WP GPIO_Pin_8 //PD.08
|
||||
#define GPIO_Pin_CP GPIO_Pin_9 //PD.09
|
||||
#define GPIO_CTL_SD GPIOD
|
||||
/*****************************************************************************
|
||||
**************************************************************************
|
||||
*******************************************************************************/
|
||||
|
||||
//其他接口涉及的可修改的宏定义
|
||||
/******************************
|
||||
lcd用
|
||||
**************************************/
|
||||
#define HIGHT (64)
|
||||
#define WIDTH (212)
|
||||
|
||||
/*****************************************
|
||||
Audio----I2S3-----SPI3
|
||||
***************************************************************/
|
||||
//#define CODEC_MCLK_ENABLED
|
||||
#define CODEC_MCLK_DISABLED
|
||||
#define CODEC_USE_INT
|
||||
//#define CODEC_USE_DMA
|
||||
#define AudioFreq I2S_AudioFreq_44k
|
||||
/*************************************************
|
||||
模拟I2C---EEPROM and CAT5137共用
|
||||
********************************************************/
|
||||
#define EE_M24C08 /* Support the device: M24C08. */
|
||||
//#define EE_M24C64_32 /* Support the devices: M24C32 and M24C64 */
|
||||
#define I2C_Speed 200000
|
||||
|
||||
#if defined (EE_M24C08)
|
||||
#define I2C_FLASH_PAGESIZE (16)
|
||||
#elif defined (EE_M24C64_32)
|
||||
#define I2C_FLASH_PAGESIZE (32)
|
||||
#endif
|
||||
|
||||
#ifdef EE_M24C64_32
|
||||
#define EEPROM_HW_ADDRESS 0xA0 /* E0 = E1 = E2 = 0 */
|
||||
#elif defined (EE_M24C08)
|
||||
//#define EEPROM_Block0_ADDRESS 0xA0 /* 000*/
|
||||
#define EEPROM_Block1_ADDRESS 0xA2 /* E3 E2 E1= 001 */
|
||||
//#define EEPROM_Block2_ADDRESS 0xA4 /* 010 */
|
||||
//#define EEPROM_Block3_ADDRESS 0xA6 /* 011 */
|
||||
#endif
|
||||
|
||||
#define USE_CAT5137 /*Support the Volume Control*/
|
||||
|
||||
#ifdef USE_CAT5137
|
||||
#define I2C_CAT5137_ADDRESS 0x5C//0101110
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************
|
||||
SD card----SPI2
|
||||
***************************************************************/
|
||||
// demo uses a command line option to define this (see Makefile):
|
||||
// #define STM32_SD_USE_DMA
|
||||
#ifdef STM32_SD_USE_DMA
|
||||
// #warning "Information only: using DMA"
|
||||
#pragma message "*** Using DMA ***"
|
||||
#endif
|
||||
/* set to 1 to provide a disk_ioctrl function even if not needed by the FatFs */
|
||||
#define STM32_SD_DISK_IOCTRL_FORCE (0)
|
||||
|
||||
#define CARD_SUPPLY_SWITCHABLE (0) //0,power on not depend any IO
|
||||
#define SOCKET_WP_CONNECTED (0)
|
||||
#define SOCKET_CP_CONNECTED (0)
|
||||
|
||||
#define SPI_BaudRatePrescaler_SPI_SD SPI_BaudRatePrescaler_4 // - for SPI1 and full-speed APB2: 60MHz/4 =15MHZ < 20MHZ
|
||||
|
||||
//selectable
|
||||
//DMA相关未作修改
|
||||
#define DMA_Channel_SPI_SD_RX DMA1_Channel2
|
||||
#define DMA_Channel_SPI_SD_TX DMA1_Channel3
|
||||
#define DMA_FLAG_SPI_SD_TC_RX DMA1_FLAG_TC2
|
||||
#define DMA_FLAG_SPI_SD_TC_TX DMA1_FLAG_TC3
|
||||
|
||||
/******************************************
|
||||
|
||||
***************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,426 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/ee_drivers/i2c_ee.c
|
||||
* @author X9D Application Team
|
||||
* @version V 0.2
|
||||
* @date 12-JULY-2012
|
||||
* @brief This file provides a set of functions needed to manage the
|
||||
* communication between I2C peripheral and I2C M24CXX EEPROM.
|
||||
CAT5137 added,share the I2C.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "i2c_ee.h"
|
||||
#include "hal.h"
|
||||
#include "Macro_define.h"
|
||||
|
||||
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
uint16_t EEPROM_ADDRESS;
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Configure the used I/O ports pin
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static
|
||||
void I2C_GPIO_Configuration(void)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
GPIOB->BSRRH =I2C_EE_WP; //PB9
|
||||
GPIO_InitStructure.GPIO_Pin = I2C_EE_WP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(I2C_EE_WP_GPIO, &GPIO_InitStructure);
|
||||
|
||||
/* Configure I2C_EE pins: SCL and SDA */
|
||||
GPIO_InitStructure.GPIO_Pin = I2C_EE_SCL | I2C_EE_SDA;//PE0,PE1
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
|
||||
GPIO_Init(I2C_EE_GPIO, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief I2C Configuration
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
//when use harware I2C
|
||||
void I2C_Configuration(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
short I2C_START()
|
||||
{
|
||||
SDA_H; I2C_delay();
|
||||
SCL_H; I2C_delay();
|
||||
//if(!SDA_read)return 0; //SDA线为低电平则总线忙,退出
|
||||
SDA_L; I2C_delay();
|
||||
//if(SDA_read) return 0; //SDA线为高电平则总线出错,退出
|
||||
SCL_L; I2C_delay();
|
||||
return 1;
|
||||
}
|
||||
|
||||
void I2C_STOP()
|
||||
{
|
||||
SCL_L; I2C_delay();
|
||||
SDA_L; I2C_delay();
|
||||
SCL_H; I2C_delay();
|
||||
SDA_H; I2C_delay();
|
||||
}
|
||||
|
||||
void I2C_ACK()
|
||||
{
|
||||
SCL_L; I2C_delay();
|
||||
SDA_L; I2C_delay();
|
||||
SCL_H; I2C_delay();
|
||||
SCL_L; I2C_delay();
|
||||
}
|
||||
void I2C_NO_ACK()
|
||||
{
|
||||
SCL_L; I2C_delay();
|
||||
SDA_H; I2C_delay();
|
||||
SCL_H; I2C_delay();
|
||||
SCL_L; I2C_delay();
|
||||
}
|
||||
short I2C_WAIT_ACK() //返回为:=1有ACK,=0无ACK
|
||||
{
|
||||
short i=50;
|
||||
SCL_L; I2C_delay();
|
||||
SDA_H; I2C_delay();
|
||||
SCL_H; I2C_delay();
|
||||
while(i){
|
||||
if(SDA_read)
|
||||
{
|
||||
I2C_delay();
|
||||
i--;
|
||||
}else{
|
||||
i=2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
SCL_L; I2C_delay();
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void I2C_SEND_DATA(char SendByte)
|
||||
{
|
||||
short i=8;
|
||||
while(i--)
|
||||
{
|
||||
SCL_L; I2C_delay();
|
||||
if(SendByte&0x80)
|
||||
SDA_H;
|
||||
else
|
||||
SDA_L;
|
||||
SendByte<<=1; I2C_delay();
|
||||
SCL_H; I2C_delay();
|
||||
}
|
||||
SCL_L; I2C_delay();
|
||||
}
|
||||
char I2C_READ() //数据从高位到低位//
|
||||
{
|
||||
short i=8;
|
||||
char ReceiveByte=0;
|
||||
|
||||
SDA_H;
|
||||
while(i--)
|
||||
{
|
||||
ReceiveByte<<=1;
|
||||
SCL_L; I2C_delay();
|
||||
SCL_H; I2C_delay();
|
||||
if(SDA_read)
|
||||
{
|
||||
ReceiveByte|=0x01;
|
||||
}
|
||||
}
|
||||
SCL_L;
|
||||
return ReceiveByte;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void I2C_EE_Init()
|
||||
{
|
||||
/* GPIO Periph clock enable */
|
||||
RCC_AHB1PeriphClockCmd(I2C_EE_GPIO_CLK, ENABLE);
|
||||
|
||||
/* GPIO configuration */
|
||||
I2C_GPIO_Configuration();
|
||||
|
||||
#if defined (EE_M24C64_32)
|
||||
/* Select the EEPROM address according to the state of E0, E1, E2 pins */
|
||||
EEPROM_ADDRESS = EEPROM_HW_ADDRESS;
|
||||
#elif defined (EE_M24C08)
|
||||
/* depending on the EEPROM Address selected in the i2c_ee.h file */
|
||||
#ifdef EEPROM_Block0_ADDRESS
|
||||
/* Select the EEPROM Block0 to write on */
|
||||
EEPROM_ADDRESS = EEPROM_Block0_ADDRESS;
|
||||
#endif
|
||||
|
||||
#ifdef EEPROM_Block1_ADDRESS
|
||||
/* Select the EEPROM Block1 to write on */
|
||||
EEPROM_ADDRESS = EEPROM_Block1_ADDRESS;
|
||||
#endif
|
||||
|
||||
#ifdef EEPROM_Block2_ADDRESS
|
||||
/* Select the EEPROM Block2 to write on */
|
||||
EEPROM_ADDRESS = EEPROM_Block2_ADDRESS;
|
||||
#endif
|
||||
|
||||
#ifdef EEPROM_Block3_ADDRESS
|
||||
/* Select the EEPROM Block3 to write on */
|
||||
EEPROM_ADDRESS = EEPROM_Block3_ADDRESS;
|
||||
#endif
|
||||
#endif /* EE_M24C64_32 */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Writes one byte to the I2C EEPROM.
|
||||
* @param pBuffer : pointer to the buffer containing the data to be
|
||||
* written to the EEPROM.
|
||||
* @param WriteAddr : EEPROM's internal address to write to.
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_EE_ByteWrite(uint8_t* pBuffer, uint16_t WriteAddr)
|
||||
{
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(EEPROM_ADDRESS | EE_CMD_WRITE);
|
||||
I2C_WAIT_ACK();
|
||||
#ifdef EE_M24C08
|
||||
I2C_SEND_DATA(WriteAddr);
|
||||
I2C_WAIT_ACK();
|
||||
#elif defined(EE_M24C64_32)
|
||||
I2C_SEND_DATA((uint8_t)((WriteAddr&0xFF00)>>8) );
|
||||
I2C_WAIT_ACK();
|
||||
I2C_SEND_DATA((uint8_t)(WriteAddr&0xFF));
|
||||
I2C_WAIT_ACK();
|
||||
#endif
|
||||
I2C_SEND_DATA(*pBuffer);
|
||||
I2C_WAIT_ACK();
|
||||
I2C_STOP();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads a block of data from the EEPROM.
|
||||
* @param pBuffer : pointer to the buffer that receives the data read
|
||||
* from the EEPROM.
|
||||
* @param ReadAddr : EEPROM's internal address to read from.
|
||||
* @param NumByteToRead : number of bytes to read from the EEPROM.
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_EE_BufferRead(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRead)
|
||||
{
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(EEPROM_ADDRESS |EE_CMD_WRITE);
|
||||
I2C_WAIT_ACK();
|
||||
|
||||
#ifdef EE_M24C08
|
||||
I2C_SEND_DATA(ReadAddr);
|
||||
I2C_WAIT_ACK();
|
||||
#elif defined(EE_M24C64_32)
|
||||
I2C_SEND_DATA((uint8_t)((ReadAddr & 0xFF00) >> 8));
|
||||
I2C_WAIT_ACK();
|
||||
I2C_SEND_DATA((uint8_t)(ReadAddr & 0x00FF));
|
||||
I2C_WAIT_ACK();
|
||||
#endif
|
||||
I2C_STOP();
|
||||
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(EEPROM_ADDRESS | EE_CMD_READ);
|
||||
I2C_WAIT_ACK();
|
||||
while(NumByteToRead)
|
||||
{
|
||||
if(NumByteToRead ==1){
|
||||
*pBuffer =I2C_READ();
|
||||
I2C_NO_ACK();
|
||||
I2C_STOP();
|
||||
}else{
|
||||
*pBuffer =I2C_READ();
|
||||
I2C_ACK();
|
||||
pBuffer++;
|
||||
}
|
||||
NumByteToRead--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes buffer of data to the I2C EEPROM.
|
||||
* @param pBuffer : pointer to the buffer containing the data to be
|
||||
* written to the EEPROM.
|
||||
* @param WriteAddr : EEPROM's internal address to write to.
|
||||
* @param NumByteToWrite : number of bytes to write to the EEPROM.
|
||||
* @retval None
|
||||
*/
|
||||
//整页的整页写 其他多字节写
|
||||
void I2C_EE_BufferWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite)
|
||||
{
|
||||
uint8_t NumOfPage = 0, NumOfSingle = 0, count = 0;
|
||||
uint16_t Addr = 0;
|
||||
|
||||
Addr = WriteAddr % I2C_FLASH_PAGESIZE;
|
||||
count = I2C_FLASH_PAGESIZE - Addr;
|
||||
NumOfPage = NumByteToWrite / I2C_FLASH_PAGESIZE;
|
||||
NumOfSingle = NumByteToWrite % I2C_FLASH_PAGESIZE;
|
||||
|
||||
/* If WriteAddr is I2C_FLASH_PAGESIZE aligned */
|
||||
if(Addr == 0)
|
||||
{
|
||||
/* If NumByteToWrite < I2C_FLASH_PAGESIZE */
|
||||
if(NumOfPage == 0)
|
||||
{
|
||||
I2C_EE_PageWrite(pBuffer, WriteAddr, NumOfSingle);
|
||||
I2C_EE_WaitEepromStandbyState();
|
||||
}
|
||||
/* If NumByteToWrite > I2C_FLASH_PAGESIZE */
|
||||
else
|
||||
{
|
||||
while(NumOfPage--)
|
||||
{
|
||||
I2C_EE_PageWrite(pBuffer, WriteAddr, I2C_FLASH_PAGESIZE);
|
||||
I2C_EE_WaitEepromStandbyState();
|
||||
WriteAddr += I2C_FLASH_PAGESIZE;
|
||||
pBuffer += I2C_FLASH_PAGESIZE;
|
||||
}
|
||||
|
||||
if(NumOfSingle!=0)
|
||||
{
|
||||
I2C_EE_PageWrite(pBuffer, WriteAddr, NumOfSingle);
|
||||
I2C_EE_WaitEepromStandbyState();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* If WriteAddr is not I2C_FLASH_PAGESIZE aligned */
|
||||
else
|
||||
{
|
||||
/* If NumByteToWrite < I2C_FLASH_PAGESIZE */
|
||||
if(NumOfPage== 0)
|
||||
{
|
||||
/* If the number of data to be written is more than the remaining space
|
||||
in the current page: */
|
||||
if (NumByteToWrite > count)
|
||||
{
|
||||
/* Write the data conained in same page */
|
||||
I2C_EE_PageWrite(pBuffer, WriteAddr, count);
|
||||
I2C_EE_WaitEepromStandbyState();
|
||||
|
||||
/* Write the remaining data in the following page */
|
||||
I2C_EE_PageWrite((uint8_t*)(pBuffer + count), (WriteAddr + count), (NumByteToWrite - count));
|
||||
I2C_EE_WaitEepromStandbyState();
|
||||
}
|
||||
else
|
||||
{
|
||||
I2C_EE_PageWrite(pBuffer, WriteAddr, NumOfSingle);
|
||||
I2C_EE_WaitEepromStandbyState();
|
||||
}
|
||||
}
|
||||
/* If NumByteToWrite > I2C_FLASH_PAGESIZE */
|
||||
else
|
||||
{
|
||||
NumByteToWrite -= count;
|
||||
NumOfPage = NumByteToWrite / I2C_FLASH_PAGESIZE;
|
||||
NumOfSingle = NumByteToWrite % I2C_FLASH_PAGESIZE;
|
||||
|
||||
if(count != 0)
|
||||
{
|
||||
I2C_EE_PageWrite(pBuffer, WriteAddr, count);
|
||||
I2C_EE_WaitEepromStandbyState();
|
||||
WriteAddr += count;
|
||||
pBuffer += count;
|
||||
}
|
||||
|
||||
while(NumOfPage--)
|
||||
{
|
||||
I2C_EE_PageWrite(pBuffer, WriteAddr, I2C_FLASH_PAGESIZE);
|
||||
I2C_EE_WaitEepromStandbyState();
|
||||
WriteAddr += I2C_FLASH_PAGESIZE;
|
||||
pBuffer += I2C_FLASH_PAGESIZE;
|
||||
}
|
||||
if(NumOfSingle != 0)
|
||||
{
|
||||
I2C_EE_PageWrite(pBuffer, WriteAddr, NumOfSingle);
|
||||
I2C_EE_WaitEepromStandbyState();
|
||||
}
|
||||
}
|
||||
}
|
||||
//I2C_EE_WaitEepromStandbyState();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes more than one byte to the EEPROM with a single WRITE cycle.
|
||||
* @note The number of byte can't exceed the EEPROM page size.
|
||||
* @param pBuffer : pointer to the buffer containing the data to be
|
||||
* written to the EEPROM.
|
||||
* @param WriteAddr : EEPROM's internal address to write to.
|
||||
* @param NumByteToWrite : number of bytes to write to the EEPROM.
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite)
|
||||
{
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(EEPROM_ADDRESS|EE_CMD_WRITE);
|
||||
I2C_WAIT_ACK();
|
||||
|
||||
#ifdef EE_M24C08
|
||||
I2C_SEND_DATA(WriteAddr);
|
||||
I2C_WAIT_ACK();
|
||||
#elif defined(EE_M24C64_32)
|
||||
I2C_SEND_DATA((uint8_t)((WriteAddr & 0xFF00) >> 8));
|
||||
I2C_WAIT_ACK();
|
||||
I2C_SEND_DATA((uint8_t)(WriteAddr & 0x00FF));
|
||||
I2C_WAIT_ACK();
|
||||
#endif /* EE_M24C08 */
|
||||
|
||||
/* While there is data to be written */
|
||||
while(NumByteToWrite--)
|
||||
{
|
||||
I2C_SEND_DATA(*pBuffer);
|
||||
I2C_WAIT_ACK();
|
||||
pBuffer++;
|
||||
}
|
||||
I2C_STOP();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Wait for EEPROM Standby state
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void I2C_EE_WaitEepromStandbyState(void)
|
||||
{
|
||||
/*__IO*/ volatile uint16_t SR1_Tmp = 0;
|
||||
|
||||
do
|
||||
{
|
||||
I2C_START();
|
||||
I2C_SEND_DATA(EEPROM_ADDRESS|EE_CMD_WRITE);
|
||||
|
||||
}while(0== I2C_WAIT_ACK());
|
||||
I2C_STOP();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/ee_drivers/i2c_ee.h
|
||||
* @author X9D Application Team
|
||||
* @version V 0.2
|
||||
* @date 12-JLY-2012
|
||||
* @brief Header for i2c_ee.c module
|
||||
******************************************************************************
|
||||
* @copy
|
||||
*
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
||||
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
||||
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
||||
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2009 STMicroelectronics</center></h2>
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion ------------------------------------ */
|
||||
#ifndef __I2C_EE_H
|
||||
#define __I2C_EE_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f2xx.h"
|
||||
#include "stm32f2xx_conf.h"
|
||||
#include "stdint.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
|
||||
#define EE_CMD_WRITE (0)
|
||||
#define EE_CMD_READ (1)
|
||||
#define I2C_delay() do{delayUsec(5);}while(0)
|
||||
|
||||
#define SCL_H do{GPIOB->BSRRL = I2C_EE_SCL;}while(0)
|
||||
#define SCL_L do{GPIOB->BSRRH = I2C_EE_SCL;}while(0)
|
||||
#define SDA_H do{GPIOB->BSRRL = I2C_EE_SDA;}while(0)
|
||||
#define SDA_L do{GPIOB->BSRRH = I2C_EE_SDA;}while(0)
|
||||
#define SCL_read (GPIOB->IDR & I2C_EE_SCL)
|
||||
#define SDA_read (GPIOB->IDR & I2C_EE_SDA)
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void I2C_EE_Init(void);
|
||||
void I2C_EE_ByteWrite(uint8_t* pBuffer, uint16_t WriteAddr);
|
||||
void I2C_EE_PageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite);
|
||||
void I2C_EE_BufferWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint16_t NumByteToWrite);
|
||||
void I2C_EE_BufferRead(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t NumByteToRead);
|
||||
void I2C_EE_WaitEepromStandbyState(void);
|
||||
|
||||
#endif /* __I2C_EE_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/lcd/lcd.c
|
||||
* @author X9D Application Team
|
||||
* @Hardware version V0.2
|
||||
* @date 11-July-2012
|
||||
* @brief This file provides LCD Init and botom drivers.
|
||||
* *
|
||||
******************************************************************************
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include "lcd.h"
|
||||
#include "spi.h"
|
||||
#include "hal.h"
|
||||
#include "Macro_define.h"
|
||||
|
||||
#define WriteData(x) AspiData(x)
|
||||
#define WriteCommand(x) AspiCmd(x)
|
||||
|
||||
void Set_Address(u8 x, u8 y)
|
||||
{
|
||||
WriteCommand(x&0x0F); //Set Column Address LSB CA[3:0]
|
||||
WriteCommand((x>>4)|0x10); //Set Column Address MSB CA[7:4]
|
||||
|
||||
WriteCommand((y&0x0F)|0x60); //Set Row Address LSB RA [3:0]
|
||||
WriteCommand(((y>>4)&0x0F)|0x70); //Set Row Address MSB RA [7:4]
|
||||
}
|
||||
|
||||
/**6 ponits in one line share the same address,3 bytes in the buffer.
|
||||
3 bytes wrote in one time */
|
||||
void refreshDisplay()
|
||||
{
|
||||
u8 _x1,_x0,temp_x0,temp_x00;
|
||||
|
||||
_x1 =( DISPLAY_W>>1) + 1;
|
||||
|
||||
temp_x0 = 0;
|
||||
temp_x00 = temp_x0/3;
|
||||
|
||||
for(uint32_t y0=0; y0<=y1; y0++)
|
||||
{
|
||||
Set_Address(0, y0);//change the address every column
|
||||
AspiCmd(0xAF);
|
||||
for(uint_32_t x=0; x_x0<=_x1; _x0++)
|
||||
{
|
||||
WriteData(lcd_buffer[_x0][y0]);
|
||||
//WriteData(lcd_buffer[_x0][y0]);
|
||||
//WriteData(lcd_buffer[_x0][y0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**Init the Backlight GPIO */
|
||||
static void LCD_BL_Config()
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBL, ENABLE);
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_BL;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
|
||||
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);
|
||||
}
|
||||
|
||||
/** Init the anolog spi gpio
|
||||
*/
|
||||
static void LCD_Hardware_Init()
|
||||
{
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_LCD, ENABLE);
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
/*!< Configure lcd CLK\ MOSI\ A0pin in output pushpull mode *************/
|
||||
GPIO_InitStructure.GPIO_Pin =PIN_LCD_MOSI | PIN_LCD_CLK | PIN_LCD_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, &GPIO_InitStructure);
|
||||
|
||||
/*!< Configure lcd NCS pin in output pushpull mode ,PULLUP *************/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_LCD_NCS;
|
||||
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_LCD, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void Delay(uint32_t ms);
|
||||
/* Initialize the LCD */
|
||||
#endif
|
||||
|
||||
static void LCD_Init()
|
||||
{
|
||||
/*Hardware Reset need delay*/
|
||||
/*LCD_RST_LOW();
|
||||
Delay(50);
|
||||
LCD_RST_HIGH();*/
|
||||
|
||||
AspiCmd(0x25); //Temperature compensation curve definition: 0x25 = -0.05%/oC
|
||||
AspiCmd(0x2b); //Panel loading set ,Internal VLCD.
|
||||
AspiCmd(0xEA); //set bias=1/10 :Command table NO.27
|
||||
AspiCmd(0x81); //Set Vop
|
||||
AspiCmd(50); //0--255
|
||||
AspiCmd(0xA6); //inverse display off
|
||||
AspiCmd(0xD1); //SET RGB:Command table NO.21 .SET RGB or BGR. D1=RGB
|
||||
AspiCmd(0xD5); //set color mode 4K and 12bits :Command table NO.22
|
||||
AspiCmd(0xA0); //line rates,25.2 Klps
|
||||
AspiCmd(0xC8); //SET N-LINE INVERSION
|
||||
AspiCmd(0x00); //Disable NIV
|
||||
AspiCmd(0xF1); //Set CEN
|
||||
AspiCmd(0x3F); // 1/64DUTY
|
||||
AspiCmd(0x84); //Disable Partial Display
|
||||
AspiCmd(0xC4); //MY=1,MX=0
|
||||
AspiCmd(0x89); //WA=1,column (CA) increment (+1) first until CA reaches CA boundary, then RA will increment by (+1).
|
||||
|
||||
AspiCmd(0xF8); //Set Window Program Enable ,inside modle
|
||||
AspiCmd(0xF4); //starting column address of RAM program window.
|
||||
AspiCmd(0x00);
|
||||
AspiCmd(0xF5); //starting row address of RAM program window.
|
||||
AspiCmd(0x60);
|
||||
AspiCmd(0xF6); //ending column address of RAM program window.
|
||||
AspiCmd(0x47);
|
||||
AspiCmd(0xF7); //ending row address of RAM program window.
|
||||
AspiCmd(0x9F);
|
||||
|
||||
AspiCmd(0xAF); //dc2=1,IC into exit SLEEP MODE, dc3=1 gray=ON 开灰阶 ,dc4=1 Green Enhanc mode disabled 绿色增强模式关
|
||||
|
||||
}
|
||||
|
||||
void lcd_init()
|
||||
{
|
||||
LCD_BL_Config();
|
||||
LCD_Hardware_Init();
|
||||
LCD_Init();
|
||||
}
|
||||
|
||||
#if 0
|
||||
/***************************************************************
|
||||
***********FOR Test
|
||||
**********************************************************************/
|
||||
void Delay(uint32_t ms)
|
||||
{
|
||||
u8 i;
|
||||
while(ms != 0)
|
||||
{
|
||||
for(i=0;i<250;i++) {}
|
||||
for(i=0;i<75;i++) {}
|
||||
ms--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TEST_LCD()
|
||||
{
|
||||
//static u32 cnt;
|
||||
//CC中断
|
||||
GPIO_SetBits(GPIOB,GPIO_Pin_8);//BACKLIGHT
|
||||
|
||||
//Delay(3000);
|
||||
//paintScreen();
|
||||
clearScreen();
|
||||
drawPoint(0,0,1);
|
||||
paintRect(0,0,0,0);
|
||||
reversePoint(0,0);
|
||||
paintRect(0,0,0,0);
|
||||
Delay(3000);
|
||||
drawPoint(1,0,1);
|
||||
paintRect(0,0,1,0);
|
||||
Delay(3000);
|
||||
reversePoint(1,0);
|
||||
paintRect(0,0,1,0);
|
||||
Delay(3000);
|
||||
drawPoint(0,1,1);
|
||||
paintRect(0,1,0,1);
|
||||
Delay(3000);
|
||||
reversePoint(0,1);
|
||||
paintRect(0,1,0,1);
|
||||
|
||||
drawPoint(211,0,1);
|
||||
paintRect(0,0,211,0);
|
||||
Delay(3000);
|
||||
reversePoint(211,0);
|
||||
paintRect(0,0,211,0);
|
||||
|
||||
drawPoint(211,63,1);
|
||||
paintRect(211,63,211,63);
|
||||
Delay(3000);
|
||||
reversePoint(211,63);
|
||||
paintRect(211,63,211,63);
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/main.c
|
||||
* @author X9D Application Team
|
||||
* @Hardware version V0.2
|
||||
* @date 11-July-2012
|
||||
* @brief This file provides the main fuction.
|
||||
* *
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "stm32f2xx.h"
|
||||
#include "intrinsics.h"
|
||||
#include "stdint.h"
|
||||
#include "stdio.h"
|
||||
#include "SYS_NVIC.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
#include "lcd.h"
|
||||
#include "gui_tsk.h"
|
||||
#include "item.h"
|
||||
#include "Audio.h"
|
||||
#include "sys_man.h"
|
||||
#include "Macro_define.h"
|
||||
|
||||
#ifdef I2C_TEST
|
||||
#include "i2c_ee.h"
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ADC_TEST
|
||||
#include "adc.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
Delay(10000); //delay 200+ ms
|
||||
#ifdef DEBUG
|
||||
debug();
|
||||
#endif
|
||||
__disable_interrupt();
|
||||
|
||||
/*HCLK=120M,SYSCLK=120M,PCLK1=30M,PCLK2=60M,SO APB1=60M(div=4),APB2=120M(div=2)*/
|
||||
|
||||
RCC_ClocksTypeDef RCC_Clocks;
|
||||
RCC_GetClocksFreq(&RCC_Clocks);//add to watch to see the values
|
||||
|
||||
//clock init ok ,other peripherals init code;
|
||||
|
||||
__enable_interrupt();
|
||||
|
||||
while(1)
|
||||
{
|
||||
}
|
||||
//return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "hal.h"
|
||||
#include "stm32f2xx.h"
|
||||
#include "pwr_ctrl.h"
|
||||
|
||||
void pwr_ctrl_down()
|
||||
{
|
||||
GPIO_SetBits(GPIOPWR,PIN_MCU_PWR);
|
||||
//ee_save_data();
|
||||
GPIO_ResetBits(GPIOPWR,PIN_MCU_PWR);
|
||||
}
|
||||
|
||||
void pwr_ctrl_on()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void check_pwr() //¶¨Ê±ÒÖ»òÖжϣ¬ÔÙ²âÊÔ
|
||||
{
|
||||
if( GPIO_ReadInputDataBit(GPIOPWR,PIN_PWR_STATUS) == Bit_RESET)
|
||||
{
|
||||
pwr_ctrl_down();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void pwr_io_init()
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
/* GPIOC GPIOD clock enable */
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOPWR, ENABLE);
|
||||
|
||||
/* GPIO Configuration*/
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_MCU_PWR | PIN_PWR_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_InitStructure.GPIO_Pin = PIN_PWR_STATUS;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_Init(GPIOPWR, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = PIN_PWR_LED;
|
||||
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(GPIOPWRLED, &GPIO_InitStructure);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef _PWR_CTRL_H_
|
||||
#define _PWR_CTRL_H_
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
+282
@@ -0,0 +1,282 @@
|
||||
/*-------------------------------------------------------------------------- */
|
||||
/* RTC controls for STM32 */
|
||||
/* Copyright (c) 2009, Martin Thomas 4/2009, 3BSD-license */
|
||||
/* partly based on code from STMircoelectronics, Peter Dannegger, "LaLaDumm" */
|
||||
/*-------------------------------------------------------------------------- */
|
||||
|
||||
#include <stdint.h>
|
||||
#include "stm32f10x.h"
|
||||
#include "rtc.h"
|
||||
|
||||
#define FIRSTYEAR 2000 // start year
|
||||
#define FIRSTDAY 6 // 0 = Sunday
|
||||
|
||||
static const uint8_t DaysInMonth[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : isDST
|
||||
* Description : checks if given time is in Daylight Saving time-span.
|
||||
* Input : time-struct, must be fully populated including weekday
|
||||
* Output : none
|
||||
* Return : false: no DST ("winter"), true: in DST ("summer")
|
||||
* DST according to German standard
|
||||
* Based on code from Peter Dannegger found in the microcontroller.net forum.
|
||||
*******************************************************************************/
|
||||
static bool isDST( const RTC_t *t )
|
||||
{
|
||||
uint8_t wday, month; // locals for faster access
|
||||
|
||||
month = t->month;
|
||||
|
||||
if( month < 3 || month > 10 ) { // month 1, 2, 11, 12
|
||||
return false; // -> Winter
|
||||
}
|
||||
|
||||
wday = t->wday;
|
||||
|
||||
if( t->mday - wday >= 25 && (wday || t->hour >= 2) ) { // after last Sunday 2:00
|
||||
if( month == 10 ) { // October -> Winter
|
||||
return false;
|
||||
}
|
||||
} else { // before last Sunday 2:00
|
||||
if( month == 3 ) { // March -> Winter
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : adjustDST
|
||||
* Description : adjusts time to DST if needed
|
||||
* Input : non DST time-struct, must be fully populated including weekday
|
||||
* Output : time-stuct gets modified
|
||||
* Return : false: no DST ("winter"), true: in DST ("summer")
|
||||
* DST according to German standard
|
||||
* Based on code from Peter Dannegger found in the mikrocontroller.net forum.
|
||||
*******************************************************************************/
|
||||
static bool adjustDST( RTC_t *t )
|
||||
{
|
||||
uint8_t hour, day, wday, month; // locals for faster access
|
||||
|
||||
hour = t->hour;
|
||||
day = t->mday;
|
||||
wday = t->wday;
|
||||
month = t->month;
|
||||
|
||||
if ( isDST(t) ) {
|
||||
t->dst = 1;
|
||||
hour++; // add one hour
|
||||
if( hour == 24 ){ // next day
|
||||
hour = 0;
|
||||
wday++; // next weekday
|
||||
if( wday == 7 ) {
|
||||
wday = 0;
|
||||
}
|
||||
if( day == DaysInMonth[month-1] ) { // next month
|
||||
day = 0;
|
||||
month++;
|
||||
}
|
||||
day++;
|
||||
}
|
||||
t->month = month;
|
||||
t->hour = hour;
|
||||
t->mday = day;
|
||||
t->wday = wday;
|
||||
return true;
|
||||
} else {
|
||||
t->dst = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : counter_to_struct
|
||||
* Description : populates time-struct based on counter-value
|
||||
* Input : - counter-value (unit seconds, 0 -> 1.1.2000 00:00:00),
|
||||
* - Pointer to time-struct
|
||||
* Output : time-struct gets populated, DST not taken into account here
|
||||
* Return : none
|
||||
* Based on code from Peter Dannegger found in the mikrocontroller.net forum.
|
||||
*******************************************************************************/
|
||||
static void counter_to_struct( uint32_t sec, RTC_t *t )
|
||||
{
|
||||
uint16_t day;
|
||||
uint8_t year;
|
||||
uint16_t dayofyear;
|
||||
uint8_t leap400;
|
||||
uint8_t month;
|
||||
|
||||
t->sec = sec % 60;
|
||||
sec /= 60;
|
||||
t->min = sec % 60;
|
||||
sec /= 60;
|
||||
t->hour = sec % 24;
|
||||
day = (uint16_t)(sec / 24);
|
||||
|
||||
t->wday = (day + FIRSTDAY) % 7; // weekday
|
||||
|
||||
year = FIRSTYEAR % 100; // 0..99
|
||||
leap400 = 4 - ((FIRSTYEAR - 1) / 100 & 3); // 4, 3, 2, 1
|
||||
|
||||
for(;;) {
|
||||
dayofyear = 365;
|
||||
if( (year & 3) == 0 ) {
|
||||
dayofyear = 366; // leap year
|
||||
if( year == 0 || year == 100 || year == 200 ) { // 100 year exception
|
||||
if( --leap400 ) { // 400 year exception
|
||||
dayofyear = 365;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( day < dayofyear ) {
|
||||
break;
|
||||
}
|
||||
day -= dayofyear;
|
||||
year++; // 00..136 / 99..235
|
||||
}
|
||||
t->year = year + FIRSTYEAR / 100 * 100; // + century
|
||||
|
||||
if( dayofyear & 1 && day > 58 ) { // no leap year and after 28.2.
|
||||
day++; // skip 29.2.
|
||||
}
|
||||
|
||||
for( month = 1; day >= DaysInMonth[month-1]; month++ ) {
|
||||
day -= DaysInMonth[month-1];
|
||||
}
|
||||
|
||||
t->month = month; // 1..12
|
||||
t->mday = day + 1; // 1..31
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : struct_to_counter
|
||||
* Description : calculates second-counter from populated time-struct
|
||||
* Input : Pointer to time-struct
|
||||
* Output : none
|
||||
* Return : counter-value (unit seconds, 0 -> 1.1.2000 00:00:00),
|
||||
* Based on code from "LalaDumm" found in the mikrocontroller.net forum.
|
||||
*******************************************************************************/
|
||||
static uint32_t struct_to_counter( const RTC_t *t )
|
||||
{
|
||||
uint16_t i;
|
||||
uint32_t result = 0;
|
||||
uint16_t idx, year;
|
||||
|
||||
year = t->year;
|
||||
|
||||
/* Calculate days of years before */
|
||||
result = (uint32_t)year * 365;
|
||||
if (t->year >= 1) {
|
||||
result += (year + 3) / 4;
|
||||
result -= (year - 1) / 100;
|
||||
result += (year - 1) / 400;
|
||||
}
|
||||
|
||||
/* Start with 2000 a.d. */
|
||||
result -= 730485UL;
|
||||
|
||||
/* Make month an array index */
|
||||
idx = t->month - 1;
|
||||
|
||||
/* Loop thru each month, adding the days */
|
||||
for (i = 0; i < idx; i++) {
|
||||
result += DaysInMonth[i];
|
||||
}
|
||||
|
||||
/* Leap year? adjust February */
|
||||
if (year%400 == 0 || (year%4 == 0 && year%100 !=0)) {
|
||||
;
|
||||
} else {
|
||||
if (t->month > 1) {
|
||||
result--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add remaining days */
|
||||
result += t->mday;
|
||||
|
||||
/* Convert to seconds, add all the other stuff */
|
||||
result = (result-1) * 86400L + (uint32_t)t->hour * 3600 +
|
||||
(uint32_t)t->min * 60 + t->sec;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : rtc_gettime
|
||||
* Description : populates structure from HW-RTC, takes DST into account
|
||||
* Input : None
|
||||
* Output : time-struct gets modified
|
||||
* Return : always true/not used
|
||||
*******************************************************************************/
|
||||
bool rtc_gettime (RTC_t *rtc)
|
||||
{
|
||||
uint32_t t;
|
||||
|
||||
while ( ( t = RTC_GetCounter() ) != RTC_GetCounter() ) { ; }
|
||||
counter_to_struct( t, rtc ); // get non DST time
|
||||
adjustDST( rtc );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : my_RTC_SetCounter
|
||||
* Description : sets the hardware-counter
|
||||
* Input : new counter-value
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
static void my_RTC_SetCounter(uint32_t cnt)
|
||||
{
|
||||
/* Wait until last write operation on RTC registers has finished */
|
||||
RTC_WaitForLastTask();
|
||||
/* Change the current time */
|
||||
RTC_SetCounter(cnt);
|
||||
/* Wait until last write operation on RTC registers has finished */
|
||||
RTC_WaitForLastTask();
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : rtc_settime
|
||||
* Description : sets HW-RTC with values from time-struct, takes DST into
|
||||
* account, HW-RTC always running in non-DST time
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : not used
|
||||
*******************************************************************************/
|
||||
bool rtc_settime (const RTC_t *rtc)
|
||||
{
|
||||
uint32_t cnt;
|
||||
RTC_t ts;
|
||||
|
||||
cnt = struct_to_counter( rtc ); // non-DST counter-value
|
||||
counter_to_struct( cnt, &ts ); // normalize struct (for weekday)
|
||||
if ( isDST( &ts ) ) {
|
||||
cnt -= 60*60; // Subtract one hour
|
||||
}
|
||||
PWR_BackupAccessCmd(ENABLE);
|
||||
my_RTC_SetCounter( cnt );
|
||||
PWR_BackupAccessCmd(DISABLE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : rtc_init
|
||||
* Description : initializes HW RTC,
|
||||
* sets default time-stamp if RTC has not been initialized before
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : not used
|
||||
* see STM RTC example in the StdPeriph-Library package
|
||||
*******************************************************************************/
|
||||
int rtc_init(void) //not use back_vcc
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef RTC_H_
|
||||
#define RTC_H_
|
||||
|
||||
#include <stdint.h>
|
||||
//#include "interger.h"
|
||||
//#include <stdbool.h>
|
||||
#include "stm32f2xx.h"
|
||||
#ifndef false
|
||||
#define false FALSE
|
||||
#endif
|
||||
#ifndef true
|
||||
#define true TRUE
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint16_t year; /* 1..4095 */
|
||||
uint8_t month; /* 1..12 */
|
||||
uint8_t mday; /* 1..31 */
|
||||
uint8_t wday; /* 0..6, Sunday = 0*/
|
||||
uint8_t hour; /* 0..23 */
|
||||
uint8_t min; /* 0..59 */
|
||||
uint8_t sec; /* 0..59 */
|
||||
uint8_t dst; /* 0 Winter, !=0 Summer */
|
||||
} RTC_t;
|
||||
|
||||
int rtc_init(void);
|
||||
bool rtc_gettime (RTC_t*); /* Get time */
|
||||
bool rtc_settime (const RTC_t*); /* Set time */
|
||||
|
||||
#endif
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/spi/spi.c
|
||||
* @author X9D Application Team
|
||||
* @Hardware version V0.2
|
||||
* @date 11-July-2012
|
||||
* @brief This file provides spi Init(Analog spi),read and write.
|
||||
driver for LCD.
|
||||
* *
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "spi.h"
|
||||
#include "hal.h"
|
||||
/**
|
||||
**********send command to lcd**************
|
||||
*/
|
||||
//hardware spi
|
||||
/*u16 spiCmd(u8 addr)
|
||||
{
|
||||
u8 readValue;
|
||||
|
||||
SPI_RS_LOW();
|
||||
SPI_NCS_LOW();
|
||||
|
||||
SPI_WRITE_BYTE(addr);
|
||||
SPI_WAIT_DONE();
|
||||
|
||||
readValue=SPI_READ_BYTE();
|
||||
SPI_NCS_HIGH();
|
||||
return readValue;
|
||||
}*/
|
||||
|
||||
//Anolog spi
|
||||
void AspiCmd(u8 Command_Byte)
|
||||
{
|
||||
int i=8;
|
||||
LCD_A0_LOW();
|
||||
|
||||
LCD_CLK_HIGH();
|
||||
LCD_NCS_LOW();
|
||||
|
||||
while (i--)
|
||||
{
|
||||
LCD_CLK_LOW();
|
||||
if(Command_Byte&0x80)
|
||||
{
|
||||
LCD_MOSI_HIGH();
|
||||
}
|
||||
else LCD_MOSI_LOW();
|
||||
|
||||
Command_Byte=Command_Byte<<1;
|
||||
LCD_CLK_HIGH();
|
||||
}
|
||||
LCD_NCS_HIGH();
|
||||
LCD_A0_HIGH();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
********send data to lcd**************
|
||||
|
||||
*/
|
||||
|
||||
//hardware spi
|
||||
/*
|
||||
u16 spiData(u8 addr)
|
||||
{
|
||||
u16 readValue;
|
||||
OLED_RS_HIGH();
|
||||
SPI_NCS_LOW();
|
||||
|
||||
SPI_WRITE_BYTE(addr);
|
||||
SPI_WAIT_DONE();
|
||||
|
||||
readValue=SPI_READ_BYTE();
|
||||
SPI_NCS_HIGH();
|
||||
return readValue;
|
||||
}
|
||||
*/
|
||||
|
||||
//Anolog spi
|
||||
void AspiData(u8 Para_data)
|
||||
{
|
||||
int i=8;
|
||||
LCD_CLK_HIGH();
|
||||
LCD_A0_HIGH();
|
||||
LCD_NCS_LOW();
|
||||
while (i--)
|
||||
{
|
||||
if(Para_data&0x80)
|
||||
{
|
||||
LCD_MOSI_HIGH();
|
||||
}else LCD_MOSI_LOW();
|
||||
Para_data<<=1;
|
||||
LCD_CLK_LOW();
|
||||
__no_operation();
|
||||
LCD_CLK_HIGH();
|
||||
__no_operation();
|
||||
}
|
||||
LCD_NCS_HIGH();
|
||||
LCD_A0_HIGH();
|
||||
}
|
||||
|
||||
/***
|
||||
**********read one byte in a register*******
|
||||
*/
|
||||
|
||||
/*
|
||||
u16 spiRegAccess(u8 addrByte, u8 writeValue)
|
||||
{
|
||||
u8 readValue;
|
||||
|
||||
SPI_NCS_LOW();
|
||||
|
||||
SPI_WRITE_BYTE(addrByte);
|
||||
SPI_WAIT_DONE();
|
||||
|
||||
SPI_WRITE_BYTE(writeValue);
|
||||
SPI_WAIT_DONE();
|
||||
|
||||
readValue=SPI_READ_BYTE();
|
||||
SPI_NCS_HIGH();
|
||||
return readValue;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/spi/spi.h
|
||||
* @author X9D Application Team
|
||||
* @Hardware version V0.2
|
||||
* @date 11-July-2012
|
||||
* @brief spi.c' Header file.
|
||||
* *
|
||||
******************************************************************************
|
||||
*/
|
||||
#ifndef _SPI_H_
|
||||
#define _SPI_H_
|
||||
|
||||
#include "stm32f2xx.h"
|
||||
|
||||
#define LCD_NCS_HIGH() do{GPIO_SetBits(GPIO_LCD, PIN_LCD_NCS);}while(0)
|
||||
#define LCD_NCS_LOW() do{GPIO_ResetBits(GPIO_LCD, PIN_LCD_NCS);}while(0)
|
||||
|
||||
#define LCD_A0_HIGH() do{GPIO_SetBits(GPIO_LCD, PIN_LCD_A0);}while(0)
|
||||
#define LCD_A0_LOW() do{GPIO_ResetBits(GPIO_LCD, PIN_LCD_A0);}while(0)
|
||||
|
||||
#define LCD_RST_HIGH() do{GPIO_SetBits(GPIO_LCD, PIN_LCD_RST);}while(0)
|
||||
#define LCD_RST_LOW() do{GPIO_ResetBits(GPIO_LCD, PIN_LCD_RST);}while(0)
|
||||
|
||||
#define LCD_CLK_HIGH() do{GPIO_SetBits(GPIO_LCD, PIN_LCD_CLK);}while(0)
|
||||
#define LCD_CLK_LOW() do{GPIO_ResetBits(GPIO_LCD, PIN_LCD_CLK);}while(0)
|
||||
|
||||
#define LCD_MOSI_HIGH() do{GPIO_SetBits(GPIO_LCD, PIN_LCD_MOSI);}while(0)
|
||||
#define LCD_MOSI_LOW() do{GPIO_ResetBits(GPIO_LCD, PIN_LCD_MOSI);}while(0)
|
||||
|
||||
void AspiCmd(u8 Command_Byte);
|
||||
void AspiData(u8 Para_data);
|
||||
//u16 spiRegAccess(u8 addrByte, u8 writeValue);
|
||||
|
||||
#endif
|
||||
|
||||
+6964
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,257 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/STM32F2xx_StdPeriph_Template/stm32f2xx_it.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 13-April-2012
|
||||
* @brief Main Interrupt Service Routines.
|
||||
* This file provides template for all exceptions handler and
|
||||
* peripherals interrupt service routine.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f2xx_it.h"
|
||||
#include "Macro_define.h"
|
||||
|
||||
/** @addtogroup Template_Project
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M3 Processor Exceptions Handlers */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles NMI exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void NMI_Handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Hard Fault exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Hard Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Memory Manage exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void MemManage_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Memory Manage exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Bus Fault exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void BusFault_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Bus Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Usage Fault exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void UsageFault_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Usage Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles SVCall exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
//void SVC_Handler(void)
|
||||
//{
|
||||
//}
|
||||
|
||||
/**
|
||||
* @brief This function handles Debug Monitor exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void DebugMon_Handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles PendSVC exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
//void PendSV_Handler(void)
|
||||
//{
|
||||
//}
|
||||
|
||||
/**
|
||||
* @brief This function handles SysTick Handler.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
//void SysTick_Handler(void)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
/******************************************************************************/
|
||||
/* STM32F2xx Peripherals Interrupt Handlers */
|
||||
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
|
||||
/* available peripheral interrupt handler's name please refer to the startup */
|
||||
/* file (startup_stm32f2xx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles PPP interrupt request.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
/*void PPP_IRQHandler(void)
|
||||
{
|
||||
}*/
|
||||
|
||||
#ifdef AUDIO_TEST
|
||||
#include "Audio.h"
|
||||
void SPI3_IRQHandler(void)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
//all the available peripheral interrupt handler's name are followed
|
||||
/*
|
||||
; External Interrupts
|
||||
DCD WWDG_IRQHandler ; Window WatchDog
|
||||
DCD PVD_IRQHandler ; PVD through EXTI Line detection
|
||||
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
|
||||
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
|
||||
DCD FLASH_IRQHandler ; FLASH
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line4
|
||||
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
|
||||
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
|
||||
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
|
||||
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
|
||||
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
|
||||
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
|
||||
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
|
||||
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
|
||||
DCD CAN1_TX_IRQHandler ; CAN1 TX
|
||||
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
|
||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
||||
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
|
||||
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
|
||||
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
|
||||
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
|
||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD TIM3_IRQHandler ; TIM3
|
||||
DCD TIM4_IRQHandler ; TIM4
|
||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
||||
DCD SPI1_IRQHandler ; SPI1
|
||||
DCD SPI2_IRQHandler ; SPI2
|
||||
DCD USART1_IRQHandler ; USART1
|
||||
DCD USART2_IRQHandler ; USART2
|
||||
DCD USART3_IRQHandler ; USART3
|
||||
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
|
||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
|
||||
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
|
||||
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
|
||||
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
|
||||
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
|
||||
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
|
||||
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
|
||||
DCD FSMC_IRQHandler ; FSMC
|
||||
DCD SDIO_IRQHandler ; SDIO
|
||||
DCD TIM5_IRQHandler ; TIM5
|
||||
DCD SPI3_IRQHandler ; SPI3
|
||||
DCD UART4_IRQHandler ; UART4
|
||||
DCD UART5_IRQHandler ; UART5
|
||||
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
|
||||
DCD TIM7_IRQHandler ; TIM7
|
||||
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
|
||||
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
|
||||
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
|
||||
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
|
||||
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
|
||||
DCD ETH_IRQHandler ; Ethernet
|
||||
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
|
||||
DCD CAN2_TX_IRQHandler ; CAN2 TX
|
||||
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
|
||||
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
|
||||
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
|
||||
DCD OTG_FS_IRQHandler ; USB OTG FS
|
||||
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
|
||||
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
|
||||
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
|
||||
DCD USART6_IRQHandler ; USART6
|
||||
DCD I2C3_EV_IRQHandler ; I2C3 event
|
||||
DCD I2C3_ER_IRQHandler ; I2C3 error
|
||||
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
|
||||
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
|
||||
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
|
||||
DCD OTG_HS_IRQHandler ; USB OTG HS
|
||||
DCD DCMI_IRQHandler ; DCMI
|
||||
DCD CRYP_IRQHandler ; CRYP crypto
|
||||
DCD HASH_RNG_IRQHandler ; Hash and Rng
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/STM32F2xx_StdPeriph_Template/stm32f2xx_it.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 13-April-2012
|
||||
* @brief This file contains the headers of the interrupt handlers.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F2xx_IT_H
|
||||
#define __STM32F2xx_IT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f2xx.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
void NMI_Handler(void);
|
||||
void HardFault_Handler(void);
|
||||
void MemManage_Handler(void);
|
||||
void BusFault_Handler(void);
|
||||
void UsageFault_Handler(void);
|
||||
void SVC_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32F2xx_IT_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -0,0 +1,256 @@
|
||||
#include "stm32f2xx.h"
|
||||
#include "timer_init.h"
|
||||
#include "hal.h"
|
||||
#include "msg_que.h"
|
||||
//Hardware Init Of Timer
|
||||
|
||||
//TIM10_CH1 LCD backlight
|
||||
//PWM OUTPUT MODE 500HZ,400HZ闪动。修改TIM10-> CCR1(1-4000)改变占空比,正比。
|
||||
void TIM10_CH1_BL_Init()
|
||||
{
|
||||
uint16_t PrescalerValue = 0;
|
||||
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
TIM_OCInitTypeDef TIM_OCInitStructure;
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
/* TIM10 clock enable ,GPIOBL clock enable */
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM10, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBL, ENABLE);
|
||||
|
||||
/* GPIOC Configuration: TIM10_CH1 (PB.08)*/
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL;
|
||||
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_UP ;
|
||||
GPIO_Init(GPIOBL, &GPIO_InitStructure);
|
||||
/* Connect TIM10 pins to AF3 */
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, GPIO_AF_TIM10);
|
||||
|
||||
/*
|
||||
APB2 = 120M,分频系数6,TIM10计数频率2M。TIM10频率为2M/4000=500HZ.
|
||||
so the TIM10 Channel 1 generates a PWM signal with a frequency equal to
|
||||
500Hz and a duty cycle = (TIM10_CCR1/ TIM10_ARR + 1)* 100 = 50%
|
||||
*/
|
||||
|
||||
/* Compute the prescaler value */
|
||||
PrescalerValue = (uint16_t) ((SystemCoreClock ) / 2000000) - 1;
|
||||
/* Time base configuration */
|
||||
TIM_TimeBaseStructure.TIM_Period = 3999; //ARR=19999
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||
|
||||
TIM_TimeBaseInit(TIM10, &TIM_TimeBaseStructure);
|
||||
|
||||
/* PWM1 Mode configuration: Channel1 */
|
||||
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
|
||||
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
|
||||
TIM_OCInitStructure.TIM_Pulse =2000; //TIM10-> CCR1
|
||||
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
|
||||
|
||||
TIM_OC1Init(TIM10, &TIM_OCInitStructure);
|
||||
TIM_OC1PreloadConfig(TIM10, TIM_OCPreload_Enable);
|
||||
|
||||
/* TIM10 enable counter */
|
||||
TIM_Cmd(TIM10, ENABLE);
|
||||
}
|
||||
|
||||
void TIM10_CH1_BL_Adjust(char mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case BKL_DEC:
|
||||
TIM10->CCR1 += 250;
|
||||
if(TIM10->CCR1>4000)
|
||||
TIM10->CCR1 = 4000;
|
||||
break;
|
||||
case BKL_INC:
|
||||
if(TIM10->CCR1 < 250)
|
||||
TIM10->CCR1 = 0;
|
||||
else
|
||||
TIM10->CCR1 -= 250;
|
||||
break;
|
||||
case BKL_OFF: TIM_Cmd(TIM10, DISABLE);break;
|
||||
case BKL_ON: TIM_Cmd(TIM10, ENABLE);break;
|
||||
|
||||
default:break;
|
||||
}
|
||||
}
|
||||
|
||||
//TIM1_CH1:CPPM_OUTPUT
|
||||
void TIM1_CH1_CPPM_Init()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static struct TimerStruct timer_struct[MAX_TIMER];
|
||||
char led_lights;
|
||||
|
||||
/*******************************************
|
||||
初始化应用层定时器
|
||||
*******************************************/
|
||||
static void initTimerStruct(void)
|
||||
{
|
||||
char i;
|
||||
for(i=0;i<MAX_TIMER;i++)
|
||||
{
|
||||
timer_struct[i].valid=0;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* timer hardware init
|
||||
*****************************************/
|
||||
void initTimer(void)
|
||||
{
|
||||
initTimerStruct();
|
||||
}
|
||||
/********************************************
|
||||
定时器 tick 处理
|
||||
********************************************/
|
||||
void timer_tick(void)
|
||||
{
|
||||
{
|
||||
short i;
|
||||
struct TimerStruct *p=timer_struct;
|
||||
|
||||
for(i=0;i<MAX_TIMER;i++)
|
||||
{
|
||||
if(p->valid){
|
||||
p->expires--;
|
||||
if(p->expires==0)
|
||||
{
|
||||
p->valid=0;
|
||||
//raiseEvent(p->event);
|
||||
postMessage(p->pMsg->hWnd, p->pMsg->iMsg, p->pMsg->wParam, p->pMsg->lParam);
|
||||
}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************
|
||||
* 设置定时器
|
||||
****************************************/
|
||||
void setTimer(char timerID,char expires,PMSG pMsg)
|
||||
{
|
||||
struct TimerStruct *p=&timer_struct[timerID];
|
||||
p->expires=expires;
|
||||
p->pMsg =pMsg;
|
||||
p->valid=1;
|
||||
}
|
||||
/****************************************
|
||||
* 取消定时器
|
||||
****************************************/
|
||||
void cancelTimer(char timerID)
|
||||
{
|
||||
timer_struct[timerID].valid=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
static struct TimerStruct timer_struct[MAX_TIMER];
|
||||
|
||||
/*******************************************
|
||||
初始化应用层定时器
|
||||
*******************************************/
|
||||
static void initTimerStruct(void)
|
||||
{
|
||||
char i;
|
||||
for(i=0;i<MAX_TIMER;i++)
|
||||
{
|
||||
timer_struct[i].valid=0;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* timer hardware init
|
||||
*****************************************/
|
||||
void initTimer(void)
|
||||
{
|
||||
initTimerStruct();
|
||||
}
|
||||
/********************************************
|
||||
定时器 tick 处理
|
||||
********************************************/
|
||||
void timer_tick(void)
|
||||
{
|
||||
{
|
||||
short i;
|
||||
struct TimerStruct *p=timer_struct;
|
||||
|
||||
for(i=0;i<MAX_TIMER;i++)
|
||||
{
|
||||
if(p->valid){
|
||||
p->expires--;
|
||||
if(p->expires==0)
|
||||
{
|
||||
p->valid=0;
|
||||
//raiseEvent(p->event);
|
||||
postMessage(p->pMsg->hWnd, p->pMsg->iMsg, p->pMsg->wParam, p->pMsg->lParam);
|
||||
}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************
|
||||
* 设置定时器
|
||||
****************************************/
|
||||
void setTimer(char timerID,char expires,PMSG pMsg)
|
||||
{
|
||||
struct TimerStruct *p=&timer_struct[timerID];
|
||||
p->expires=expires;
|
||||
p->pMsg =pMsg;
|
||||
p->valid=1;
|
||||
}
|
||||
/****************************************
|
||||
* 取消定时器
|
||||
****************************************/
|
||||
void cancelTimer(char timerID)
|
||||
{
|
||||
timer_struct[timerID].valid=0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef _TIMER_INIT_H_
|
||||
#define _TIMER_INIT_H_
|
||||
|
||||
#include "frgui.h"
|
||||
|
||||
#define MAX_TIMER (5) //×î´óµÄtimerID
|
||||
|
||||
#define TIMER_1 (0)
|
||||
#define TIMER_2 (1)
|
||||
#define TIMER_3 (2)
|
||||
#define TIMER_4 (3)
|
||||
#define TIMER_5 (4)
|
||||
|
||||
struct TimerStruct
|
||||
{
|
||||
char valid;
|
||||
char expires;
|
||||
PMSG pMsg;
|
||||
};
|
||||
|
||||
void initTimer(void);
|
||||
void setTimer(char timerID,char expires,PMSG pMsg);
|
||||
void cancelTimer(char timerID);
|
||||
void timer_interrupt(void);
|
||||
void timer_tick(void);
|
||||
void TIM10_CH1_BL_Init();
|
||||
|
||||
#define BKL_DEC (0)
|
||||
#define BKL_INC (1)
|
||||
#define BKL_OFF (2)
|
||||
#define BKL_ON (3)
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user