[all] Many little fixes
[X9D] RxNum for PXX
This commit is contained in:
+5
-6
@@ -512,9 +512,8 @@ ifeq ($(PCB), X9D)
|
||||
EXTRAINCDIRS += x9d/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/msc/inc x9d/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/hid/inc
|
||||
BOARDSRC = x9d/board_x9d.cpp
|
||||
EXTRABOARDSRC += x9d/lcd_driver.cpp x9d/aspi.cpp x9d/i2c.c
|
||||
EXTRABOARDSRC += x9d/lcd_driver.cpp x9d/aspi.cpp x9d/i2c.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
|
||||
EEPROMSRC = eeprom_avr.cpp # TODO later eeprom_conversions.cpp
|
||||
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp # TODO later eeprom_conversions.cpp
|
||||
PULSESSRC = pulses_arm.cpp
|
||||
CPPSRC += audio_arm.cpp
|
||||
CPPSRC += x9d/pwr_driver.cpp x9d/pulses_driver.cpp x9d/keys_driver.cpp x9d/adc_driver.cpp x9d/trainer_driver.cpp x9d/audio_driver.cpp x9d/delays.cpp x9d/uart_driver.cpp x9d/sport_driver.cpp
|
||||
@@ -572,7 +571,7 @@ ifeq ($(PCB), SKY9X)
|
||||
SRC += sky9x/usb/device/massstorage/MSDDriver.c sky9x/usb/device/massstorage/MSDDStateMachine.c sky9x/usb/device/massstorage/MSDLun.c sky9x/usb/device/massstorage/MSDDriverDescriptors.c sky9x/usb/device/massstorage/SBCMethods.c
|
||||
SRC += sky9x/usb/common/core/USBEndpointDescriptor.c sky9x/usb/common/core/USBGenericRequest.c sky9x/usb/common/core/USBFeatureRequest.c sky9x/usb/common/core/USBInterfaceRequest.c sky9x/usb/common/core/USBGetDescriptorRequest.c sky9x/usb/common/core/USBSetAddressRequest.c sky9x/usb/common/core/USBSetConfigurationRequest.c sky9x/usb/common/core/USBConfigurationDescriptor.c sky9x/usb/common/core/USBGenericDescriptor.c
|
||||
SRC += sky9x/MEDSdcard.c
|
||||
EEPROMSRC = eeprom_arm.cpp eeprom_conversions.cpp
|
||||
EEPROMSRC = eeprom_common.cpp eeprom_raw.cpp eeprom_conversions.cpp
|
||||
PULSESSRC = pulses_arm.cpp
|
||||
CPPSRC += audio_arm.cpp haptic.cpp
|
||||
CPPSRC += sky9x/pwr_driver.cpp sky9x/adc_driver.cpp sky9x/coproc_driver.cpp sky9x/rotenc_driver.cpp sky9x/eeprom_driver.cpp sky9x/pulses_driver.cpp sky9x/keys_driver.cpp sky9x/audio_driver.cpp sky9x/buzzer_driver.cpp sky9x/haptic_driver.cpp sky9x/sdcard_driver.cpp sky9x/massstorage.cpp
|
||||
@@ -607,7 +606,7 @@ ifeq ($(PCB), GRUVIN9X)
|
||||
EXTRAINCDIRS += gruvin9x stock FatFs FatFs/option
|
||||
BOARDSRC += gruvin9x/board_gruvin9x.cpp
|
||||
EXTRABOARDSRC += stock/lcd_driver.cpp
|
||||
EEPROMSRC = eeprom_avr.cpp
|
||||
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
||||
PULSESSRC = pulses_avr.cpp
|
||||
CPPSRC += audio_avr.cpp haptic.cpp
|
||||
|
||||
@@ -635,7 +634,7 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128))
|
||||
EXTRAINCDIRS += stock
|
||||
BOARDSRC = stock/board_stock.cpp
|
||||
EXTRABOARDSRC += stock/lcd_driver.cpp
|
||||
EEPROMSRC = eeprom_avr.cpp
|
||||
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
||||
PULSESSRC = pulses_avr.cpp
|
||||
|
||||
ifeq ($(PCB), 9XR128)
|
||||
@@ -681,7 +680,7 @@ ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR))
|
||||
CPPDEFS += -DPCBSTD -DCPUM64 -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc)
|
||||
BOARDSRC = stock/board_stock.cpp
|
||||
EXTRABOARDSRC += stock/lcd_driver.cpp
|
||||
EEPROMSRC = eeprom_avr.cpp
|
||||
EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp
|
||||
PULSESSRC = pulses_avr.cpp
|
||||
|
||||
ifeq ($(PCB), 9XR)
|
||||
|
||||
+17
-17
@@ -40,8 +40,8 @@
|
||||
|
||||
#if !defined(SIMU)
|
||||
|
||||
Fifo512 debugRxFifo;
|
||||
Fifo512 debugTxFifo;
|
||||
Fifo<512> debugRxFifo;
|
||||
Fifo<512> debugTxFifo;
|
||||
|
||||
// Outputs a string to the UART
|
||||
void debugPuts(const char *format, ...)
|
||||
@@ -61,17 +61,17 @@ void debugPuts(const char *format, ...)
|
||||
|
||||
void dump(unsigned char *data, unsigned int size)
|
||||
{
|
||||
debugPuts("DUMP %d bytes ...\n\r", size);
|
||||
unsigned int i = 0, j=0;
|
||||
while (i*32+j < size) {
|
||||
debugPuts("%.2X ", data[i*32+j]);
|
||||
j++;
|
||||
if (j==32) {
|
||||
i++; j=0;
|
||||
debugPuts("\n\r");
|
||||
}
|
||||
}
|
||||
debugPuts("\n\r");
|
||||
debugPuts("DUMP %d bytes ...\n\r", size);
|
||||
unsigned int i = 0, j=0;
|
||||
while (i*32+j < size) {
|
||||
debugPuts("%.2X ", data[i*32+j]);
|
||||
j++;
|
||||
if (j==32) {
|
||||
i++; j=0;
|
||||
debugPuts("\n\r");
|
||||
}
|
||||
}
|
||||
debugPuts("\n\r");
|
||||
}
|
||||
|
||||
void debugTask(void* pdata)
|
||||
@@ -87,9 +87,9 @@ void debugTask(void* pdata)
|
||||
|
||||
void debugTx(void)
|
||||
{
|
||||
uint8_t txchar;
|
||||
|
||||
if(debugTxFifo.pop(txchar))
|
||||
debugPutc(txchar);
|
||||
uint8_t txchar;
|
||||
|
||||
if (debugTxFifo.pop(txchar))
|
||||
debugPutc(txchar);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "open9x.h"
|
||||
#include "inttypes.h"
|
||||
#include "string.h"
|
||||
|
||||
uint8_t s_eeDirtyMsk;
|
||||
tmr10ms_t s_eeDirtyTime10ms;
|
||||
|
||||
void eeDirty(uint8_t msk)
|
||||
{
|
||||
s_eeDirtyMsk |= msk;
|
||||
s_eeDirtyTime10ms = get_tmr10ms() ;
|
||||
}
|
||||
|
||||
#if defined(CPUARM)
|
||||
|
||||
char modelNames[MAX_MODELS][sizeof(g_model.name)];
|
||||
|
||||
#if defined(PXX)
|
||||
uint8_t modelIds[MAX_MODELS];
|
||||
#endif
|
||||
|
||||
void eeLoadModelNames()
|
||||
{
|
||||
for (uint32_t i=0; i<MAX_MODELS; i++) {
|
||||
eeLoadModelName(i, modelNames[i]);
|
||||
#if defined(PXX)
|
||||
modelIds[i] = eeLoadModelId(i);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(SIMU)
|
||||
#define WRITE_DELAY_10MS 200
|
||||
#elif defined(PCBX9D)
|
||||
#define WRITE_DELAY_10MS 500
|
||||
#elif defined(PCBSKY9X) && !defined(REV0)
|
||||
#define WRITE_DELAY_10MS 500
|
||||
#elif defined(PCBGRUVIN9X) && !defined(REV0)
|
||||
#define WRITE_DELAY_10MS 500
|
||||
#else
|
||||
#define WRITE_DELAY_10MS 200
|
||||
#endif
|
||||
|
||||
extern uint8_t s_eeDirtyMsk;
|
||||
extern tmr10ms_t s_eeDirtyTime10ms;
|
||||
|
||||
void eeDirty(uint8_t msk);
|
||||
void eeCheck(bool immediately=false);
|
||||
void eeReadAll();
|
||||
bool eeModelExists(uint8_t id);
|
||||
void eeLoadModelName(uint8_t id, char *name);
|
||||
void eeLoadModel(uint8_t id);
|
||||
|
||||
#if defined(CPUARM)
|
||||
|
||||
extern char modelNames[MAX_MODELS][sizeof(g_model.name)];
|
||||
void eeLoadModelNames();
|
||||
|
||||
#if defined(PXX)
|
||||
extern uint8_t modelIds[MAX_MODELS];
|
||||
#endif
|
||||
|
||||
#else // defined(CPUARM)
|
||||
|
||||
#define eeLoadModelNames()
|
||||
|
||||
#endif
|
||||
@@ -40,8 +40,6 @@
|
||||
#include "string.h"
|
||||
|
||||
volatile uint32_t Spi_complete; // TODO in the driver ?
|
||||
uint8_t s_eeDirtyMsk;
|
||||
tmr10ms_t s_eeDirtyTime10ms;
|
||||
|
||||
// Logic for storing to EEPROM/loading from EEPROM
|
||||
// If main needs to wait for the eeprom, call mainsequence without actioning menus
|
||||
@@ -78,15 +76,8 @@ uint32_t Eeprom32_data_size ;
|
||||
|
||||
#define EE_NOWAIT 1
|
||||
|
||||
void eeDirty(uint8_t msk)
|
||||
{
|
||||
s_eeDirtyMsk |= msk;
|
||||
s_eeDirtyTime10ms = get_tmr10ms() ;
|
||||
}
|
||||
|
||||
uint32_t get_current_block_number( uint32_t block_no, uint16_t *p_size, uint32_t *p_seq ) ;
|
||||
void write32_eeprom_block( uint32_t eeAddress, register uint8_t *buffer, uint32_t size, uint32_t immediate=0 ) ;
|
||||
void eeLoadModelNames( void ) ;
|
||||
|
||||
// New file system
|
||||
|
||||
@@ -360,8 +351,6 @@ bool eeLoadGeneral()
|
||||
|
||||
void eeLoadModel(uint8_t id)
|
||||
{
|
||||
uint16_t size;
|
||||
|
||||
if (id<MAX_MODELS) {
|
||||
|
||||
#if defined(SDCARD)
|
||||
@@ -374,7 +363,7 @@ void eeLoadModel(uint8_t id)
|
||||
|
||||
pauseMixerCalculations();
|
||||
|
||||
size = File_system[id+1].size ;
|
||||
uint16_t size = File_system[id+1].size ;
|
||||
|
||||
memset(&g_model, 0, sizeof(g_model));
|
||||
|
||||
@@ -387,7 +376,7 @@ void eeLoadModel(uint8_t id)
|
||||
if (size > sizeof(g_model)) {
|
||||
size = sizeof(g_model) ;
|
||||
}
|
||||
|
||||
|
||||
if(size < 256) { // if not loaded a fair amount
|
||||
modelDefault(id) ;
|
||||
eeCheck(true);
|
||||
@@ -445,12 +434,19 @@ void eeLoadModelName(uint8_t id, char *name)
|
||||
}
|
||||
}
|
||||
|
||||
void eeLoadModelNames()
|
||||
#if defined(PXX)
|
||||
uint8_t eeLoadModelId(uint8_t id)
|
||||
{
|
||||
for (uint32_t i=0; i<MAX_MODELS; i++) {
|
||||
eeLoadModelName(i, modelNames[i]);
|
||||
uint8_t modelId = 0;
|
||||
if (id < MAX_MODELS) {
|
||||
id += 1;
|
||||
if (File_system[id].size > sizeof(g_model.name) + 1) {
|
||||
read32_eeprom_data( ( File_system[id].block_no << 12) + 8 + sizeof(g_model.name), &modelId, 1);
|
||||
}
|
||||
}
|
||||
return modelId;
|
||||
}
|
||||
#endif
|
||||
|
||||
void fill_file_index()
|
||||
{
|
||||
@@ -40,17 +40,6 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(SIMU)
|
||||
#define WRITE_DELAY_10MS 200
|
||||
#elif defined(PCBSKY9X) && defined(REV0)
|
||||
#define WRITE_DELAY_10MS 200
|
||||
#else
|
||||
#define WRITE_DELAY_10MS 500
|
||||
#endif
|
||||
|
||||
extern uint8_t s_eeDirtyMsk;
|
||||
extern tmr10ms_t s_eeDirtyTime10ms;
|
||||
|
||||
// States in Eeprom32_process_state
|
||||
#define E32_IDLE 1
|
||||
#define E32_ERASESENDING 2
|
||||
@@ -77,6 +66,10 @@ extern bool eeModelExists(uint8_t id) ;
|
||||
extern bool eeCopyModel(uint8_t dst, uint8_t src);
|
||||
extern void eeSwapModels(uint8_t id1, uint8_t id2);
|
||||
|
||||
#if defined(PXX)
|
||||
uint8_t eeLoadModelId(uint8_t id);
|
||||
#endif
|
||||
|
||||
#define DISPLAY_PROGRESS_BAR(x)
|
||||
|
||||
struct t_file_entry
|
||||
@@ -40,18 +40,10 @@
|
||||
#include "string.h"
|
||||
|
||||
uint8_t s_write_err = 0; // error reasons
|
||||
uint8_t s_eeDirtyMsk;
|
||||
tmr10ms_t s_eeDirtyTime10ms;
|
||||
|
||||
RlcFile theFile; //used for any file operation
|
||||
EeFs eeFs;
|
||||
|
||||
void eeDirty(uint8_t msk)
|
||||
{
|
||||
s_eeDirtyMsk |= msk;
|
||||
s_eeDirtyTime10ms = get_tmr10ms();
|
||||
}
|
||||
|
||||
#if !defined(CPUARM)
|
||||
uint8_t s_sync_write = false;
|
||||
uint16_t eeprom_pointer;
|
||||
@@ -837,7 +829,6 @@ bool eeLoadGeneral()
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void eeLoadModelName(uint8_t id, char *name)
|
||||
{
|
||||
memclear(name, sizeof(g_model.name));
|
||||
@@ -847,16 +838,14 @@ void eeLoadModelName(uint8_t id, char *name)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CPUARM)
|
||||
// TODO same function in eeprom_arm.cpp
|
||||
void eeLoadModelNames()
|
||||
#if defined(PXX)
|
||||
// must be called just after eeLoadModelName!
|
||||
uint8_t eeLoadModelIdAfterName()
|
||||
{
|
||||
for (uint32_t i=0; i<MAX_MODELS; i++) {
|
||||
eeLoadModelName(i, modelNames[i]);
|
||||
}
|
||||
uint8_t modelId = 0;
|
||||
theFile.readRlc(&modelId, sizeof(modelId));
|
||||
return modelId;
|
||||
}
|
||||
#else
|
||||
#define eeLoadModelNames()
|
||||
#endif
|
||||
|
||||
bool eeModelExists(uint8_t id)
|
||||
@@ -864,7 +853,7 @@ bool eeModelExists(uint8_t id)
|
||||
return EFile::exists(FILE_MODEL(id));
|
||||
}
|
||||
|
||||
// TODO Now the 2 functions in eeprom_avr.cpp and eeprom_arm.cpp are really close, should be merged.
|
||||
// TODO Now the 2 functions in eeprom_rlc.cpp and eeprom_raw.cpp are really close, should be merged.
|
||||
void eeLoadModel(uint8_t id)
|
||||
{
|
||||
if (id<MAX_MODELS) {
|
||||
@@ -39,19 +39,6 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#if defined(SIMU)
|
||||
#define WRITE_DELAY_10MS 200
|
||||
#elif defined(PCBX9D)
|
||||
#define WRITE_DELAY_10MS 1000
|
||||
#elif defined(PCBGRUVIN9X) && !defined(REV0)
|
||||
#define WRITE_DELAY_10MS 500
|
||||
#else
|
||||
#define WRITE_DELAY_10MS 200
|
||||
#endif
|
||||
|
||||
extern uint8_t s_eeDirtyMsk;
|
||||
extern tmr10ms_t s_eeDirtyTime10ms;
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define blkid_t uint16_t
|
||||
#define EESIZE (32*1024)
|
||||
@@ -153,6 +140,11 @@ class EFile
|
||||
#define eeFileSize(f) eeFs.files[f].size
|
||||
#define eeModelSize(id) eeFileSize(FILE_MODEL(id))
|
||||
|
||||
#if defined(PXX)
|
||||
uint8_t eeLoadModelIdAfterName();
|
||||
#define eeLoadModelId(id) eeLoadModelIdAfterName()
|
||||
#endif
|
||||
|
||||
#define ERR_NONE 0
|
||||
#define ERR_FULL 1
|
||||
extern uint8_t s_write_err; // error reasons
|
||||
+6
-5
@@ -37,17 +37,18 @@
|
||||
#ifndef fifo_h
|
||||
#define fifo_h
|
||||
|
||||
class Fifo512
|
||||
template <int N>
|
||||
class Fifo
|
||||
{
|
||||
public:
|
||||
Fifo512():
|
||||
Fifo():
|
||||
widx(0),
|
||||
ridx(0)
|
||||
{
|
||||
}
|
||||
|
||||
void push(uint8_t byte) {
|
||||
uint32_t next = (widx+1) & 0x1ff;
|
||||
uint32_t next = (widx+1) & (N-1);
|
||||
if (next != ridx) {
|
||||
fifo[widx] = byte;
|
||||
widx = next;
|
||||
@@ -60,13 +61,13 @@ class Fifo512
|
||||
}
|
||||
else {
|
||||
byte = fifo[ridx];
|
||||
ridx = (ridx+1) & 0x1ff;
|
||||
ridx = (ridx+1) & (N-1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
uint8_t fifo[512];
|
||||
uint8_t fifo[N];
|
||||
volatile uint32_t widx;
|
||||
volatile uint32_t ridx;
|
||||
};
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
#define TIMER_16KHZ_VECT TIMER2_OVF_vect
|
||||
#define COUNTER_16KHZ TCNT2
|
||||
#define TIMER_10MS_VECT TIMER2_COMPA_vect
|
||||
#define TIMER_10MS_COMPVAL OCR2A
|
||||
#define PAUSE_10MS_INTERRUPT() TIMSK2 &= ~(1<<OCIE2A)
|
||||
#define RESUME_10MS_INTERRUPT() TIMSK2 |= (1<<OCIE2A)
|
||||
#define PAUSE_PULSES_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
|
||||
|
||||
+11
-1
@@ -1073,11 +1073,21 @@ void menuModelSetup(uint8_t event)
|
||||
|
||||
lcd_putsLeft(y, STR_RXNUM);
|
||||
lcd_outdezNAtt(MODEL_SETUP_2ND_COLUMN-3*FW, y, g_model.modelId, (m_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2);
|
||||
if (attr && (m_posHorz==0 && (editMode>0 || p1valdiff)))
|
||||
if (attr && (m_posHorz==0 && (editMode>0 || p1valdiff))) {
|
||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.modelId, 99);
|
||||
#if defined(CPUARM)
|
||||
if (checkIncDec_Ret)
|
||||
modelIds[g_eeGeneral.currModel] = g_model.modelId;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(PXX)
|
||||
if (protocol == PROTO_PXX) {
|
||||
#if defined(CPUARM)
|
||||
if (attr && m_posHorz==0 && editMode==0 && event==EVT_KEY_BREAK(KEY_ENTER))
|
||||
checkModelIdUnique(g_eeGeneral.currModel);
|
||||
#endif
|
||||
|
||||
lcd_putsAtt(MODEL_SETUP_2ND_COLUMN, y, STR_SYNCMENU, (m_posHorz==1 ? attr : 0));
|
||||
if (attr && m_posHorz==1) {
|
||||
s_editMode = 0;
|
||||
|
||||
+1
-1
@@ -1104,6 +1104,7 @@ enum Protocols {
|
||||
|
||||
PACK(typedef struct t_ModelData {
|
||||
char name[LEN_MODEL_NAME]; // must be first for eeLoadModelName
|
||||
uint8_t modelId;
|
||||
TimerData timers[MAX_TIMERS];
|
||||
uint8_t protocol:3;
|
||||
uint8_t thrTrim:1; // Enable Throttle Trim
|
||||
@@ -1130,7 +1131,6 @@ PACK(typedef struct t_ModelData {
|
||||
|
||||
int8_t ppmFrameLength; // 0=22.5ms (10ms-30ms) 0.5ms increments
|
||||
uint8_t thrTraceSrc;
|
||||
uint8_t modelId;
|
||||
|
||||
swstate_t switchWarningStates;
|
||||
|
||||
|
||||
+47
-81
@@ -68,8 +68,6 @@ OS_FlagID audioFlag;
|
||||
OS_MutexID audioMutex;
|
||||
OS_MutexID mixerMutex;
|
||||
|
||||
char modelNames[MAX_MODELS][sizeof(g_model.name)];
|
||||
|
||||
#endif // defined(CPUARM)
|
||||
|
||||
#if defined(SPLASH)
|
||||
@@ -284,7 +282,7 @@ void per10ms()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined(FRSKY) || defined(MAVLINK) || defined(JETI)) && !defined(CPUARM) && !(defined(PCBSTD) && (defined(AUDIO) || defined(VOICE)))
|
||||
#if (defined(FRSKY) || defined(MAVLINK) || defined(JETI)) && !defined(CPUARM)
|
||||
if (!IS_DSM2_SERIAL_PROTOCOL(s_current_protocol))
|
||||
telemetryPoll10ms();
|
||||
#endif
|
||||
@@ -384,7 +382,7 @@ uint16_t evalChkSum()
|
||||
return sum;
|
||||
}
|
||||
|
||||
#ifndef TEMPLATES
|
||||
#if !defined(TEMPLATES)
|
||||
inline void applyDefaultTemplate()
|
||||
{
|
||||
for (int i=0; i<NUM_STICKS; i++) {
|
||||
@@ -398,10 +396,27 @@ inline void applyDefaultTemplate()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PXX) && defined(CPUARM)
|
||||
void checkModelIdUnique(uint8_t id)
|
||||
{
|
||||
for (uint8_t i=0; i<MAX_MODELS; i++) {
|
||||
if (i != id && g_model.modelId!=0 && g_model.modelId == modelIds[i]) {
|
||||
s_warning = PSTR("Model ID already used");
|
||||
s_warning_type = WARNING_TYPE_ASTERISK;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void modelDefault(uint8_t id)
|
||||
{
|
||||
memset(&g_model, 0, sizeof(g_model));
|
||||
applyDefaultTemplate();
|
||||
|
||||
#if defined(PXX) && defined(CPUARM)
|
||||
modelIds[id] = g_model.modelId = id+1;
|
||||
checkModelIdUnique(id);
|
||||
#endif
|
||||
}
|
||||
|
||||
int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0, 25 ,50, 75, 100
|
||||
@@ -769,15 +784,13 @@ int16_t applyLimits(uint8_t channel, int32_t value)
|
||||
if (ofs > lim_p) ofs = lim_p;
|
||||
if (ofs < lim_n) ofs = lim_n;
|
||||
|
||||
// because the recaling optimization would reduce the calculation reserve we activate this for all builds
|
||||
// it increases the caculation reserve from factor 20,25x to 32x, which it slightly better as original
|
||||
// without it we would only have 16x which is slightly worse as original, we should not do this
|
||||
// #ifdef PREVENT_ARITHMETIC_OVERFLOW
|
||||
// because the rescaling optimization would reduce the calculation reserve we activate this for all builds
|
||||
// it increases the calculation reserve from factor 20,25x to 32x, which it slightly better as original
|
||||
// without it we would only have 16x which is slightly worse as original, we should not do this
|
||||
|
||||
// thanks to gbirkus, he motivated this change, which greatly reduces overruns
|
||||
// unfortunately the constants and 32bit compares generates about 50 bytes codes; didn't find a way to get it down.
|
||||
|
||||
value = limit(int32_t(-RESXl*256),value,int32_t(RESXl*256)); // saves 2 bytes compared to other solutions up to now
|
||||
// #endif
|
||||
value = limit(int32_t(-RESXl*256), value, int32_t(RESXl*256)); // saves 2 bytes compared to other solutions up to now
|
||||
|
||||
#if defined(PPM_LIMITS_SYMETRICAL)
|
||||
if (value) {
|
||||
@@ -1996,7 +2009,11 @@ uint16_t inacSum = 0;
|
||||
BeepANACenter bpanaCenter = 0;
|
||||
|
||||
uint16_t sDelay[MAX_MIXERS] = {0};
|
||||
#if defined(CPUARM)
|
||||
int32_t act [MAX_MIXERS] = {0};
|
||||
#else
|
||||
__int24 act [MAX_MIXERS] = {0};
|
||||
#endif
|
||||
uint8_t swOn [MAX_MIXERS] = {0};
|
||||
uint8_t mixWarning;
|
||||
|
||||
@@ -3524,24 +3541,13 @@ uint16_t getTmr16KHz()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// new implementation
|
||||
|
||||
// This ISR is only called if timer matches OCR0. We updated OCR0 on each call to make ISR happen.
|
||||
// If we do not do this, we have 16,385msec time before overflow causes an IRQ
|
||||
// So it's so easy instead of preventing IRQ we
|
||||
//just do not cause it! It's enough not to write to OCR0. This gives plenty of time to finish ISR.
|
||||
// So instead of masking we write OCR0 at the end. Max would be ISR is caused here immediately, which would not do anything,
|
||||
// because all critical pfathes are finished. It also would give us the chance to measure if we passed the next tick and count it.
|
||||
// It's already implemented but commented out, because of code cost.
|
||||
|
||||
ISR(TIMER_10MS_VECT, ISR_NOBLOCK)
|
||||
// 10ms timer
|
||||
{
|
||||
static uint8_t accuracyWarble; // because 16M / 1024 / 100 = 156.25. we need to correct the fault; no start value needed
|
||||
|
||||
#if defined(PCBSTD) && (defined(AUDIO) || defined(VOICE))
|
||||
// Clocks every 128 uS
|
||||
ISR(TIMER2_OVF_vect, ISR_NOBLOCK)
|
||||
{
|
||||
cli();
|
||||
TIMSK &= ~ (1<<TOIE2) ; // stop reentrance
|
||||
sei();
|
||||
|
||||
#if defined(AUDIO)
|
||||
AUDIO_DRIVER();
|
||||
@@ -3551,70 +3557,30 @@ ISR(TIMER_10MS_VECT, ISR_NOBLOCK)
|
||||
VOICE_DRIVER();
|
||||
#endif
|
||||
|
||||
static uint8_t cnt10ms; // no initialization needed here; execute 10ms code once every 78 ISRs; takes 16.38msec to overrun for first round --> no problem
|
||||
|
||||
#if defined(FRSKY) || defined(MAVLINK) || defined(JETI)
|
||||
if (cnt10ms == 30) {
|
||||
if (!IS_DSM2_SERIAL_PROTOCOL(s_current_protocol))
|
||||
telemetryPoll10ms();
|
||||
}
|
||||
cli();
|
||||
TIMSK |= (1<<TOIE2) ;
|
||||
sei();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (--cnt10ms == 0) { // BEGIN { ... every 10ms ... }
|
||||
// Begin 10ms event
|
||||
// cnt10ms = 78;
|
||||
cnt10ms = (!(++accuracyWarble &0x07)) ? 79 : 78; // instead of assigning we add to take missed ISRs into account
|
||||
// each per10ms() we are 0,016msec too fast
|
||||
// one tick more means 0,112 msec too slow = 7*0,016msec --> in sum we are correct!!!
|
||||
// therefore every 8. round we need to slow down one tick
|
||||
|
||||
#endif
|
||||
// Clocks every 10ms
|
||||
ISR(TIMER_10MS_VECT, ISR_NOBLOCK)
|
||||
{
|
||||
// without correction we are 0,16% too fast; that mean in one hour we are 5,76Sek too fast; we do not like that
|
||||
static uint8_t accuracyWarble; // because 16M / 1024 / 100 = 156.25. we need to correct the fault; no start value needed
|
||||
|
||||
AUDIO_HEARTBEAT();
|
||||
AUDIO_HEARTBEAT();
|
||||
|
||||
#if defined(HAPTIC)
|
||||
HAPTIC_HEARTBEAT();
|
||||
HAPTIC_HEARTBEAT();
|
||||
#endif
|
||||
|
||||
per10ms();
|
||||
per10ms();
|
||||
|
||||
#if defined(PCBSTD) && (defined(AUDIO) || defined(VOICE))
|
||||
} // end 10ms event
|
||||
#endif
|
||||
|
||||
// without correction we are 0,16% too fast; that mean in one hour we are 5,76Sek too fast; we do not like that
|
||||
#if defined(PCBGRUVIN9X)
|
||||
// static uint8_t accuracyWarble; // because 16M / 1024 / 100 = 156.25. we need to correct the fault; not start value needed
|
||||
uint8_t bump = (!(++accuracyWarble & 0x03)) ? 157 : 156;
|
||||
OCR2A += bump;
|
||||
#elif defined(AUDIO) || defined(VOICE)
|
||||
// simple solution; if ISR tooks longer this round is just ignored; The problem in this case is, it takes 16msec for the next ISR --> big gap in AUDIO, VOICE and a big fault in time calculaiton if it happens
|
||||
// cnt10ms--;
|
||||
OCR0 += 2; // interrupt every 128us
|
||||
/*
|
||||
// needs to change cnt10ms to int instead uint to allow cnt10ms to be negative
|
||||
// also remove cnt10ms-- in if statement above, because substraction is done here
|
||||
// code oost: 34 bytes
|
||||
// this solutions all missed ISRs are counted and next ISR is in about 128usec (exception is wrap around)
|
||||
cli();
|
||||
do {
|
||||
cnt10ms--;
|
||||
OCR0 += 2; // interrupt every 128us
|
||||
} while ((OCR0<TCNT0) && (OCR0>=2)); // loop in case ISR tooks too long; If it laps around, ignore additional calcuation and stop anyway
|
||||
// sei(); will be done anyway if ISR is left
|
||||
*/
|
||||
#else
|
||||
// static uint8_t accuracyWarble; // because 16M / 1024 / 100 = 156.25. we need to correct the fault; not start value needed
|
||||
// each tick we are 0,016msec too fast
|
||||
// one tick more means 0,048 msec too slow = 3*0,016msec --> in sum we are correct!!!
|
||||
// therefore every 4 round we need to slow down one tick
|
||||
uint8_t bump = (!(++accuracyWarble & 0x03)) ? 157 : 156;
|
||||
OCR0 += bump;
|
||||
#endif
|
||||
|
||||
TIMER_10MS_COMPVAL += bump;
|
||||
}
|
||||
|
||||
|
||||
// Timer3 used for PPM_IN pulse width capture. Counter running at 16MHz / 8 = 2MHz
|
||||
// equating to one count every half millisecond. (2 counts = 1ms). Control channel
|
||||
// count delta values thus can range from about 1600 to 4400 counts (800us to 2200us),
|
||||
|
||||
+7
-13
@@ -362,10 +362,6 @@ enum EnumKeys {
|
||||
#define PPM_CH_CENTER(ch) (PPM_CENTER)
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
extern char modelNames[MAX_MODELS][sizeof(g_model.name)];
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
// This doesn't need protection on this processor
|
||||
#define tmr10ms_t uint32_t
|
||||
@@ -384,11 +380,11 @@ extern inline uint16_t get_tmr10ms()
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO try to merge the 2 include files
|
||||
#include "eeprom_common.h"
|
||||
#if defined(PCBSKY9X)
|
||||
#include "eeprom_arm.h"
|
||||
#include "eeprom_raw.h"
|
||||
#else
|
||||
#include "eeprom_avr.h"
|
||||
#include "eeprom_rlc.h"
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
@@ -951,15 +947,13 @@ void saveTimers();
|
||||
#define saveTimers()
|
||||
#endif
|
||||
|
||||
void eeDirty(uint8_t msk);
|
||||
void eeCheck(bool immediately=false);
|
||||
void eeReadAll();
|
||||
bool eeModelExists(uint8_t id);
|
||||
void eeLoadModelName(uint8_t id, char *name);
|
||||
void eeLoadModel(uint8_t id);
|
||||
void generalDefault();
|
||||
void modelDefault(uint8_t id);
|
||||
|
||||
#if defined(PXX) && defined(CPUARM)
|
||||
void checkModelIdUnique(uint8_t id);
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
inline int16_t calc100to256_16Bits(register int16_t x) // @@@2 open.20.fsguruh: return x*2.56
|
||||
{
|
||||
|
||||
@@ -49,8 +49,8 @@ void btInit()
|
||||
}
|
||||
|
||||
OS_FlagID btFlag;
|
||||
Fifo32 btTxFifo;
|
||||
Fifo32 btRxFifo;
|
||||
Fifo<32> btTxFifo;
|
||||
Fifo<32> btRxFifo;
|
||||
|
||||
struct t_serial_tx btTx ;
|
||||
uint8_t btTxBuffer[32] ;
|
||||
|
||||
@@ -98,6 +98,8 @@
|
||||
#define PIN_TRIM_RH_R 0x00000200
|
||||
#endif
|
||||
|
||||
void usbMassStorage();
|
||||
|
||||
#define PIN_ENABLE 0x001
|
||||
#define PIN_PERIPHERAL 0x000
|
||||
#define PIN_INPUT 0x002
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
#if !defined(SIMU)
|
||||
|
||||
extern Fifo512 debugRxFifo;
|
||||
extern Fifo<512> debugRxFifo;
|
||||
|
||||
/*
|
||||
* Outputs a character on the UART line.
|
||||
|
||||
@@ -102,29 +102,22 @@ inline void boardInit()
|
||||
DDRB = 0x81; PORTB = 0x7e; //pullups keys+nc
|
||||
DDRC = 0x3e; PORTC = 0xc1; //pullups nc
|
||||
DDRD = 0x00; PORTD = 0xff; //pullups keys
|
||||
DDRE = (1<<OUT_E_BUZZER); PORTE = 0xff-(1<<OUT_E_BUZZER); //pullups + buzzer 0
|
||||
DDRE = (1<<OUT_E_BUZZER); PORTE = 0xff-(1<<OUT_E_BUZZER); //pullups + buzzer 0
|
||||
DDRF = 0x00; PORTF = 0x00; //anain
|
||||
DDRG = 0x14; PORTG = 0xfb; //pullups + SIM_CTL=1 = phonejack = ppm_in, Haptic output and off (0)
|
||||
|
||||
ADMUX=ADC_VREF_TYPE;
|
||||
ADCSRA=0x85; // ADC enabled, pre-scaler division=32 (no interrupt, no auto-triggering)
|
||||
|
||||
/**** Set up timer/counter 0 ****/
|
||||
#if defined (AUDIO)
|
||||
// TCNT0 10ms = 16MHz/1024/2(/78) periodic timer (for speaker tone generation)
|
||||
// Capture ISR 7812.5/second -- runs per-10ms code segment once every 78
|
||||
// cycles (9.984ms). Timer overflows at about 61Hz or once every 16ms.
|
||||
TCCR0 = (0b111 << CS00);// Norm mode, clk/1024
|
||||
OCR0 = 2;
|
||||
#else
|
||||
// TCNT0 10ms = 16MHz/1024/156 periodic timer (9.984ms)
|
||||
// (with 1:4 duty at 157 to average 10.0ms)
|
||||
// Timer overflows at about 61Hz or once every 16ms.
|
||||
TCCR0 = (0b111 << CS00);// Norm mode, clk/1024
|
||||
TCCR0 = (0b111 << CS00); // Norm mode, clk/1024
|
||||
OCR0 = 156;
|
||||
#endif
|
||||
|
||||
#if defined(PWM_BACKLIGHT)
|
||||
#if defined(AUDIO) || defined(VOICE)
|
||||
TCCR2 = (0b010 << CS00); // Norm mode, clk/8
|
||||
#elif defined(PWM_BACKLIGHT)
|
||||
/** Smartieparts LED Backlight is connected to PORTB/pin7, which can be used as pwm output of timer2 **/
|
||||
#if defined(SP22)
|
||||
TCCR2 = (0b011 << CS20)|(1<<WGM20)|(1<<COM21)|(1<<COM20); // inv. pwm mode, clk/64
|
||||
@@ -133,8 +126,7 @@ inline void boardInit()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TIMSK |= (1<<OCIE0) | (1<<TOIE0); // Enable Output-Compare and Overflow interrrupts
|
||||
/********************************/
|
||||
TIMSK |= (1<<OCIE0) | (1<<TOIE0) | (1<<TOIE2); // Enable Output-Compare and Overflow interrrupts
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
#define COUNTER_16KHZ TCNT0
|
||||
|
||||
#define TIMER_10MS_VECT TIMER0_COMP_vect
|
||||
#define TIMER_10MS_COMPVAL OCR0
|
||||
#define PAUSE_10MS_INTERRUPT() TIMSK &= ~(1<<OCIE0)
|
||||
#define RESUME_10MS_INTERRUPT() TIMSK |= (1<<OCIE0)
|
||||
|
||||
|
||||
@@ -333,7 +333,7 @@
|
||||
#endif
|
||||
|
||||
#define TR_POPUPS TR_ENTER"\010[EXIT]"
|
||||
#define OFS_EXIT 7
|
||||
#define OFS_EXIT sizeof(TR_ENTER)
|
||||
|
||||
#define TR_MENUWHENDONE CENTER"\006"TR_ENTER" WHEN DONE"
|
||||
#define TR_FREE "free"
|
||||
|
||||
+6
-6
@@ -266,9 +266,9 @@ static int8_t SCSI_ReadCapacity10(uint8_t lun, uint8_t *params)
|
||||
else
|
||||
{
|
||||
|
||||
MSC_BOT_Data[0] = (uint8_t)(SCSI_blk_nbr - 1 >> 24);
|
||||
MSC_BOT_Data[1] = (uint8_t)(SCSI_blk_nbr - 1 >> 16);
|
||||
MSC_BOT_Data[2] = (uint8_t)(SCSI_blk_nbr - 1 >> 8);
|
||||
MSC_BOT_Data[0] = (uint8_t)((SCSI_blk_nbr - 1) >> 24);
|
||||
MSC_BOT_Data[1] = (uint8_t)((SCSI_blk_nbr - 1) >> 16);
|
||||
MSC_BOT_Data[2] = (uint8_t)((SCSI_blk_nbr - 1) >> 8);
|
||||
MSC_BOT_Data[3] = (uint8_t)(SCSI_blk_nbr - 1);
|
||||
|
||||
MSC_BOT_Data[4] = (uint8_t)(SCSI_blk_size >> 24);
|
||||
@@ -309,9 +309,9 @@ static int8_t SCSI_ReadFormatCapacity(uint8_t lun, uint8_t *params)
|
||||
else
|
||||
{
|
||||
MSC_BOT_Data[3] = 0x08;
|
||||
MSC_BOT_Data[4] = (uint8_t)(blk_nbr - 1 >> 24);
|
||||
MSC_BOT_Data[5] = (uint8_t)(blk_nbr - 1 >> 16);
|
||||
MSC_BOT_Data[6] = (uint8_t)(blk_nbr - 1 >> 8);
|
||||
MSC_BOT_Data[4] = (uint8_t)((blk_nbr - 1) >> 24);
|
||||
MSC_BOT_Data[5] = (uint8_t)((blk_nbr - 1) >> 16);
|
||||
MSC_BOT_Data[6] = (uint8_t)((blk_nbr - 1) >> 8);
|
||||
MSC_BOT_Data[7] = (uint8_t)(blk_nbr - 1);
|
||||
|
||||
MSC_BOT_Data[8] = 0x02;
|
||||
|
||||
@@ -63,8 +63,6 @@ extern "C" {
|
||||
#define TIMER_MULT_APB1 2
|
||||
#define TIMER_MULT_APB2 1
|
||||
|
||||
void usbMassStorage();
|
||||
|
||||
#define JACK_PPM_OUT()
|
||||
#define JACK_PPM_IN()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user