[sky9x + gruvin9x] Remanent timers

[sky9x] Timer since last charge
[sky9x] Massstorage (not working at this moment)
[sky9x] Debug Thread
[stock] Flash saving
This commit is contained in:
bsongis
2012-09-08 13:49:51 +00:00
parent fdb2b937f1
commit 03a1517531
21 changed files with 591 additions and 362 deletions
+1 -34
View File
@@ -32,6 +32,7 @@
*/
#include "../open9x.h"
#include "fifo.h"
void btSetBaudrate(uint32_t index)
{
@@ -44,40 +45,6 @@ void btInit()
btSetBaudrate(g_eeGeneral.btBaudrate);
}
class Fifo32
{
public:
Fifo32():
widx(0),
ridx(0)
{
}
void push(uint8_t byte) {
uint32_t next = (widx+1) & 0x1f;
if (next != ridx) {
fifo[widx] = byte;
widx = next;
}
}
bool pop(uint8_t & byte) {
if (ridx == widx) {
return false;
}
else {
byte = fifo[ridx];
ridx = (ridx+1) & 0x1f;
return true;
}
}
protected:
uint8_t fifo[32];
volatile uint32_t widx;
volatile uint32_t ridx;
};
OS_FlagID btFlag;
Fifo32 btTxFifo;
Fifo32 btRxFifo;
+88
View File
@@ -0,0 +1,88 @@
/*
* 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.
*
*/
#include "../open9x.h"
#include <stdio.h>
#include <stdarg.h>
/*
* Outputs a character on the UART line.
*
* This function is synchronous (i.e. uses polling).
* c Character to send.
*/
void debugPutc(const uint8_t c)
{
Uart *pUart = CONSOLE_USART;
/* Wait for the transmitter to be ready */
while ( (pUart->UART_SR & UART_SR_TXEMPTY) == 0 ) ;
/* Send character */
pUart->UART_THR = c;
}
// Outputs a string to the UART
void debugPuts(const char *format, ...)
{
va_list arglist;
char tmp[256];
va_start(arglist, format);
vsnprintf(tmp, 256, format, arglist);
va_end(arglist);
const char *t = tmp;
while (*t) {
debugPutc(*t++);
}
}
Fifo32 debugFifo;
extern "C" void UART0_IRQHandler()
{
debugFifo.push(CONSOLE_USART->UART_RHR);
}
void debugTask(void* pdata)
{
uint8_t rxchar ;
for (;;) {
while (!debugFifo.pop(rxchar))
CoTickDelay(5); // 10ms
}
}
+48
View File
@@ -0,0 +1,48 @@
/*
* 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 debug_h
#define debug_h
#if defined(DEBUG)
void debugPutc(const uint8_t c);
void debugPuts(const char *string, ...);
void debugTask(void* pdata);
#else
#define debugPutc(...)
#define debugPuts(...)
#define debugTask(...)
#endif
#endif
+71
View File
@@ -0,0 +1,71 @@
/*
* 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 fifo_h
#define fifo_h
class Fifo32
{
public:
Fifo32():
widx(0),
ridx(0)
{
}
void push(uint8_t byte) {
uint32_t next = (widx+1) & 0x1f;
if (next != ridx) {
fifo[widx] = byte;
widx = next;
}
}
bool pop(uint8_t & byte) {
if (ridx == widx) {
return false;
}
else {
byte = fifo[ridx];
ridx = (ridx+1) & 0x1f;
return true;
}
}
protected:
uint8_t fifo[32];
volatile uint32_t widx;
volatile uint32_t ridx;
};
#endif
+4 -2
View File
@@ -128,9 +128,11 @@ SECTIONS
*(.bss.*)
. = ALIGN(4); /* Align the end of the section */
*(.ram.b)
_end = .;
__end = .;
} > RAM
_ebss = .; /* Provide the name for the end of this section */
_ebss = .; /* Provide the name for the end of this section */
/*
* The ".stack" section is our stack.
+3 -3
View File
@@ -84,7 +84,7 @@ void DAC_IRQHandler (void) __attribute__((weak));
void PWM_IRQHandler (void) __attribute__((weak));
void CRCCU_IRQHandler (void) __attribute__((weak));
void ACC_IRQHandler (void) __attribute__((weak));
void USBD_IRQHandler (void) __attribute__((weak));
extern void USBD_IRQHandler (void);// __attribute__((weak));
/*=========================================================================*/
/* DEFINE: All code exported */
@@ -164,7 +164,7 @@ void RTT_IRQHandler (void) { while(1); }
void WDT_IRQHandler (void) { while(1); }
void PMC_IRQHandler (void) { while(1); }
void EEFC_IRQHandler (void) { while(1); }
void UART0_IRQHandler (void) { while(1); }
//void UART0_IRQHandler (void) { while(1); }
void UART1_IRQHandler (void) { while(1); }
void SMC_IRQHandler (void) { while(1); }
void PIOA_IRQHandler (void) { while(1); }
@@ -188,6 +188,6 @@ void ADC_IRQHandler (void) { while(1); }
// void PWM_IRQHandler (void) { while(1); }
void CRCCU_IRQHandler (void) { while(1); }
void ACC_IRQHandler (void) { while(1); }
void USBD_IRQHandler (void) { while(1); }
// void USBD_IRQHandler (void) { while(1); }
/*** EOF ***/