Small mods

This commit is contained in:
Pascal Langer 2017-12-11 18:49:50 +01:00
parent 1d9c052c01
commit f46b8366b0
5 changed files with 45 additions and 70 deletions

View File

@ -216,7 +216,7 @@ static void __attribute__((unused)) frskyX_data_frame()
idxs++; idxs++;
} }
packet[22]= idxs; packet[22]= idxs;
#ifdef SERIAL_DEBUG #ifdef DEBUG_SERIAL
for(uint8_t i=0;i<idxs;i++) for(uint8_t i=0;i<idxs;i++)
{ {
Serial.print(packet[23+i],HEX); Serial.print(packet[23+i],HEX);

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 1 #define VERSION_MINOR 1
#define VERSION_REVISION 6 #define VERSION_REVISION 6
#define VERSION_PATCH_LEVEL 40 #define VERSION_PATCH_LEVEL 41
//****************** //******************
// Protocols // Protocols
//****************** //******************
@ -325,13 +325,13 @@ enum MultiPacketTypes {
#define FAILSAFE_CHANNEL_NOPULSES 0 #define FAILSAFE_CHANNEL_NOPULSES 0
//Debug messages //Debug messages
#if defined(STM32_BOARD) && defined (SERIAL_DEBUG) #if defined(STM32_BOARD) && defined (DEBUG_SERIAL)
#define debug(msg, ...) {char buf[64]; sprintf(buf, msg, ##__VA_ARGS__); Serial.write(buf);} #define debug(msg, ...) {char buf[64]; sprintf(buf, msg, ##__VA_ARGS__); Serial.write(buf);}
#define debugln(msg, ...) {char buf[64]; sprintf(buf, msg "\r\n", ##__VA_ARGS__); Serial.write(buf);} #define debugln(msg, ...) {char buf[64]; sprintf(buf, msg "\r\n", ##__VA_ARGS__); Serial.write(buf);}
#else #else
#define debug(...) { } #define debug(...) { }
#define debugln(...) { } #define debugln(...) { }
#undef SERIAL_DEBUG #undef DEBUG_SERIAL
#endif #endif
//******************** //********************
@ -411,16 +411,16 @@ enum NRF_POWER
// The numbers do not take into account any outside amplifier // The numbers do not take into account any outside amplifier
enum CC2500_POWER enum CC2500_POWER
{ {
CC2500_POWER_0 = 0x00, // 55dbm or less CC2500_POWER_0 = 0x00, // -55dbm or less
CC2500_POWER_1 = 0x50, // -30dbm CC2500_POWER_1 = 0x50, // -30dbm
CC2500_POWER_2 = 0x44, // 28dbm CC2500_POWER_2 = 0x44, // -28dbm
CC2500_POWER_3 = 0xC0, // 26dbm CC2500_POWER_3 = 0xC0, // -26dbm
CC2500_POWER_4 = 0x84, // 24dbm CC2500_POWER_4 = 0x84, // -24dbm
CC2500_POWER_5 = 0x81, // 22dbm CC2500_POWER_5 = 0x81, // -22dbm
CC2500_POWER_6 = 0x46, // 20dbm CC2500_POWER_6 = 0x46, // -20dbm
CC2500_POWER_7 = 0x93, // 18dbm CC2500_POWER_7 = 0x93, // -18dbm
CC2500_POWER_8 = 0x55, // 16dbm CC2500_POWER_8 = 0x55, // -16dbm
CC2500_POWER_9 = 0x8D, // 14dbm CC2500_POWER_9 = 0x8D, // -14dbm
CC2500_POWER_10 = 0xC6, // -12dbm CC2500_POWER_10 = 0xC6, // -12dbm
CC2500_POWER_11 = 0x97, // -10dbm CC2500_POWER_11 = 0x97, // -10dbm
CC2500_POWER_12 = 0x6E, // -8dbm CC2500_POWER_12 = 0x6E, // -8dbm

View File

@ -22,8 +22,8 @@
*/ */
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
//#define DEBUG_TX //#define DEBUG_PIN // Use pin TX for AVR and SPI_CS for STM32 => DEBUG_PIN_on, DEBUG_PIN_off, DEBUG_PIN_toggle
//#define SERIAL_DEBUG // Only for STM32_BOARD compiled with Upload method "Serial"->usart1, "STM32duino bootloader"->USB serial //#define DEBUG_SERIAL // Only for STM32_BOARD compiled with Upload method "Serial"->usart1, "STM32duino bootloader"->USB serial
#ifdef __arm__ // Let's automatically select the board if arm is selected #ifdef __arm__ // Let's automatically select the board if arm is selected
#define STM32_BOARD #define STM32_BOARD
@ -215,7 +215,7 @@ void_function_t remote_callback = 0;
void setup() void setup()
{ {
// Setup diagnostic uart before anything else // Setup diagnostic uart before anything else
#ifdef SERIAL_DEBUG #ifdef DEBUG_SERIAL
Serial.begin(115200,SERIAL_8N1); Serial.begin(115200,SERIAL_8N1);
while (!Serial); // Wait for ever for the serial port to connect... while (!Serial); // Wait for ever for the serial port to connect...
debugln("Multiprotocol version: %d.%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_PATCH_LEVEL); debugln("Multiprotocol version: %d.%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_PATCH_LEVEL);
@ -469,6 +469,7 @@ void loop()
#else #else
if((TIMER2_BASE->SR & TIMER_SR_CC1IF)!=0) if((TIMER2_BASE->SR & TIMER_SR_CC1IF)!=0)
{ {
debugln("Callback miss");
cli(); cli();
OCR1A = TCNT1; OCR1A = TCNT1;
sei(); sei();
@ -1247,11 +1248,11 @@ void modules_reset()
UDR0; UDR0;
//enable reception and RC complete interrupt //enable reception and RC complete interrupt
UCSR0B = _BV(RXEN0)|_BV(RXCIE0);//rx enable and interrupt UCSR0B = _BV(RXEN0)|_BV(RXCIE0);//rx enable and interrupt
#ifndef DEBUG_TX #ifndef DEBUG_PIN
#if defined(TELEMETRY) #if defined(TELEMETRY)
initTXSerial( SPEED_100K ) ; initTXSerial( SPEED_100K ) ;
#endif //TELEMETRY #endif //TELEMETRY
#endif //DEBUG_TX #endif //DEBUG_PIN
#ifdef CHECK_FOR_BOOTLOADER #ifdef CHECK_FOR_BOOTLOADER
if ( boot ) if ( boot )
{ {
@ -1331,44 +1332,7 @@ void pollBoot()
else if ( lState == BOOT_READY ) else if ( lState == BOOT_READY )
{ {
#ifdef STM32_BOARD #ifdef STM32_BOARD
#define SCS_BASE (0xE000E000) /*!< System Control Space Base Address */ nvic_sys_reset();
#define SCB_BASE (SCS_BASE + 0x0D00) /*!< System Control Block Base Address */
#define SCB ((SCB_Type *) SCB_BASE) /*!< SCB configuration struct */
#define __I volatile /*!< defines 'read only' permissions */
#define __IO volatile /*!< defines 'read / write' permissions */
typedef struct
{
__I uint32_t CPUID; /*!< Offset: 0x00 CPU ID Base Register */
__IO uint32_t ICSR; /*!< Offset: 0x04 Interrupt Control State Register */
__IO uint32_t VTOR; /*!< Offset: 0x08 Vector Table Offset Register */
__IO uint32_t AIRCR; /*!< Offset: 0x0C Application Interrupt / Reset Control Register */
__IO uint32_t SCR; /*!< Offset: 0x10 System Control Register */
__IO uint32_t CCR; /*!< Offset: 0x14 Configuration Control Register */
__IO uint8_t SHP[12]; /*!< Offset: 0x18 System Handlers Priority Registers (4-7, 8-11, 12-15) */
__IO uint32_t SHCSR; /*!< Offset: 0x24 System Handler Control and State Register */
__IO uint32_t CFSR; /*!< Offset: 0x28 Configurable Fault Status Register */
__IO uint32_t HFSR; /*!< Offset: 0x2C Hard Fault Status Register */
__IO uint32_t DFSR; /*!< Offset: 0x30 Debug Fault Status Register */
__IO uint32_t MMFAR; /*!< Offset: 0x34 Mem Manage Address Register */
__IO uint32_t BFAR; /*!< Offset: 0x38 Bus Fault Address Register */
__IO uint32_t AFSR; /*!< Offset: 0x3C Auxiliary Fault Status Register */
__I uint32_t PFR[2]; /*!< Offset: 0x40 Processor Feature Register */
__I uint32_t DFR; /*!< Offset: 0x48 Debug Feature Register */
__I uint32_t ADR; /*!< Offset: 0x4C Auxiliary Feature Register */
__I uint32_t MMFR[4]; /*!< Offset: 0x50 Memory Model Feature Register */
__I uint32_t ISAR[5]; /*!< Offset: 0x60 ISA Feature Register */
} SCB_Type;
#define SCB_AIRCR_VECTKEY_Pos 16 /*!< SCB AIRCR: VECTKEY Position */
#define SCB_AIRCR_SYSRESETREQ_Pos 2 /*!< SCB AIRCR: SYSRESETREQ Position */
#define SCB_AIRCR_PRIGROUP_Pos 8 /*!< SCB AIRCR: PRIGROUP Position */
#define SCB_AIRCR_PRIGROUP_Msk (7ul << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */
#define SCB_AIRCR_SYSRESETREQ_Msk (1ul << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
// NVIC_SystemReset
SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
(SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
SCB_AIRCR_SYSRESETREQ_Msk); /* Keep priority group unchanged */
asm("dsb");
while(1); /* wait until reset */ while(1); /* wait until reset */
#else #else
cli(); // Disable global int due to RW of 16 bits registers cli(); // Disable global int due to RW of 16 bits registers
@ -1569,6 +1533,7 @@ static uint32_t random_id(uint16_t address, uint8_t create_new)
{ {
idx=UDR0; // Dummy read idx=UDR0; // Dummy read
discard_frame=1; // Error encountered discard full frame... discard_frame=1; // Error encountered discard full frame...
debugln("Bad frame");
} }
if(discard_frame==1) if(discard_frame==1)
{ {

View File

@ -21,14 +21,14 @@
#define SERIAL_TX_output SERIAL_TX_ddr |= _BV(SERIAL_TX_pin) #define SERIAL_TX_output SERIAL_TX_ddr |= _BV(SERIAL_TX_pin)
#define SERIAL_TX_on SERIAL_TX_port |= _BV(SERIAL_TX_pin) #define SERIAL_TX_on SERIAL_TX_port |= _BV(SERIAL_TX_pin)
#define SERIAL_TX_off SERIAL_TX_port &= ~_BV(SERIAL_TX_pin) #define SERIAL_TX_off SERIAL_TX_port &= ~_BV(SERIAL_TX_pin)
#ifdef DEBUG_TX #ifdef DEBUG_PIN
#define DEBUG_TX_on SERIAL_TX_on #define DEBUG_PIN_on SERIAL_TX_on
#define DEBUG_TX_off SERIAL_TX_off #define DEBUG_PIN_off SERIAL_TX_off
#define DEBUG_TX_toggle SERIAL_TX_port ^= _BV(SERIAL_TX_pin) #define DEBUG_PIN_toggle SERIAL_TX_port ^= _BV(SERIAL_TX_pin)
#else #else
#define DEBUG_TX_on #define DEBUG_PIN_on
#define DEBUG_TX_off #define DEBUG_PIN_off
#define DEBUG_TX_toggle #define DEBUG_PIN_toggle
#endif #endif
// Dial // Dial
@ -289,6 +289,16 @@
#define BIND_SET_OUTPUT pinMode(BIND_pin,OUTPUT) #define BIND_SET_OUTPUT pinMode(BIND_pin,OUTPUT)
#define IS_BIND_BUTTON_on (digitalRead(BIND_pin)==LOW) #define IS_BIND_BUTTON_on (digitalRead(BIND_pin)==LOW)
#ifdef DEBUG_PIN
#define DEBUG_PIN_on digitalWrite(SPI_CSN_pin,HIGH)
#define DEBUG_PIN_off digitalWrite(SPI_CSN_pin,LOW)
#define DEBUG_PIN_toggle digitalWrite(SPI_CSN_pin,!digitalRead(SPI_CSN_pin))
#else
#define DEBUG_PIN_on
#define DEBUG_PIN_off
#define DEBUG_PIN_toggle
#endif
#define cli() noInterrupts() #define cli() noInterrupts()
#define sei() interrupts() #define sei() interrupts()
#define delayMilliseconds(x) delay(x) #define delayMilliseconds(x) delay(x)

View File

@ -237,15 +237,15 @@
//It is important for the module to know the endpoints of your radio. //It is important for the module to know the endpoints of your radio.
//Below are some standard transmitters already preconfigured. //Below are some standard transmitters already preconfigured.
//Uncomment only the one which matches your transmitter. //Uncomment only the one which matches your transmitter.
#define TX_ER9X //ER9X/ERSKY9X/OpenTX ( 988<->2012µs) #define TX_ER9X //ER9X/ERSKY9X/OpenTX ( 988<->2012 microseconds)
//#define TX_DEVO7 //DEVO (1120<->1920µs) //#define TX_DEVO7 //DEVO (1120<->1920 microseconds)
//#define TX_SPEKTRUM //Spektrum (1100<->1900µs) //#define TX_SPEKTRUM //Spektrum (1100<->1900 microseconds)
//#define TX_HISKY //HISKY (1120<->1920µs) //#define TX_HISKY //HISKY (1120<->1920 microseconds)
//#define TX_MPX //Multiplex MC2020 (1250<->1950µs) //#define TX_MPX //Multiplex MC2020 (1250<->1950 microseconds)
//#define TX_WALKERA //Walkera PL0811-01H (1000<->1800µs) //#define TX_WALKERA //Walkera PL0811-01H (1000<->1800 microseconds)
//#define TX_CUSTOM //Custom //#define TX_CUSTOM //Custom
// The lines below are used to set the end points in microseconds (µs) if you have selected TX_CUSTOM. // The lines below are used to set the end points in microseconds if you have selected TX_CUSTOM.
// A few things to consider: // A few things to consider:
// - If you put too big values compared to your TX you won't be able to reach the extremes which is bad for throttle as an example // - If you put too big values compared to your TX you won't be able to reach the extremes which is bad for throttle as an example
// - If you put too low values you won't be able to use your full stick range, it will be maxed out before reaching the ends // - If you put too low values you won't be able to use your full stick range, it will be maxed out before reaching the ends