mendel.c: move CPU initialisation to cpu.c (cpu-avr.c).

No functional change, but more code separated by architecture.
This commit is contained in:
Markus Hitter 2015-07-24 14:29:16 +02:00
parent 083f8f9b22
commit d337fd18ad
5 changed files with 44 additions and 30 deletions

View File

@ -7,6 +7,7 @@
#if defined TEACUP_C_INCLUDE && defined __ARMEL__ #if defined TEACUP_C_INCLUDE && defined __ARMEL__
/* Nothing yet. */ void cpu_init() {
}
#endif /* defined TEACUP_C_INCLUDE && defined __ARMEL__ */ #endif /* defined TEACUP_C_INCLUDE && defined __ARMEL__ */

View File

@ -7,6 +7,38 @@
#if defined TEACUP_C_INCLUDE && defined __AVR__ #if defined TEACUP_C_INCLUDE && defined __AVR__
/* Nothing yet. */ #include <avr/io.h>
#include "pinio.h"
/** Initialise the CPU.
This sets up the CPU the way we need it. It disables modules we don't use,
so they don't mess on the I/O pins they're connected to.
*/
void cpu_init() {
#ifdef PRR
#if defined TEMP_MAX6675 || defined SD
PRR = MASK(PRTWI) | MASK(PRADC);
#else
PRR = MASK(PRTWI) | MASK(PRADC) | MASK(PRSPI);
#endif
#elif defined PRR0
#if defined TEMP_MAX6675 || defined SD
PRR0 = MASK(PRTWI) | MASK(PRADC);
#else
PRR0 = MASK(PRTWI) | MASK(PRADC) | MASK(PRSPI);
#endif
#if defined(PRUSART3)
// Don't use USART2 or USART3. Leave USART1 for GEN3 and derivatives.
PRR1 |= MASK(PRUSART3) | MASK(PRUSART2);
#endif
#if defined(PRUSART2)
// Don't use USART2 or USART3. Leave USART1 for GEN3 and derivatives.
PRR1 |= MASK(PRUSART2);
#endif
#endif
ACSR = MASK(ACD);
}
#endif /* defined TEACUP_C_INCLUDE && defined __AVR__ */ #endif /* defined TEACUP_C_INCLUDE && defined __AVR__ */

2
cpu.h
View File

@ -2,6 +2,6 @@
#ifndef _CPU_H #ifndef _CPU_H
#define _CPU_H #define _CPU_H
/* Nothing yet. */ void cpu_init(void);
#endif /* _CPU_H */ #endif /* _CPU_H */

View File

@ -32,6 +32,7 @@
#include "config_wrapper.h" #include "config_wrapper.h"
#endif /* __ARMEL_NOTYET__ */ #endif /* __ARMEL_NOTYET__ */
#include "cpu.h"
#include "serial.h" #include "serial.h"
#ifndef __ARMEL_NOTYET__ #ifndef __ARMEL_NOTYET__
#include "dda_queue.h" #include "dda_queue.h"
@ -69,31 +70,6 @@
/// initialise all I/O - set pins as input or output, turn off unused subsystems, etc /// initialise all I/O - set pins as input or output, turn off unused subsystems, etc
void io_init(void) { void io_init(void) {
#ifndef __ARMEL_NOTYET__ #ifndef __ARMEL_NOTYET__
// disable modules we don't use
#ifdef PRR
#if defined TEMP_MAX6675 || defined SD
PRR = MASK(PRTWI) | MASK(PRADC);
#else
PRR = MASK(PRTWI) | MASK(PRADC) | MASK(PRSPI);
#endif
#elif defined PRR0
#if defined TEMP_MAX6675 || defined SD
PRR0 = MASK(PRTWI) | MASK(PRADC);
#else
PRR0 = MASK(PRTWI) | MASK(PRADC) | MASK(PRSPI);
#endif
#if defined(PRUSART3)
// don't use USART2 or USART3- leave USART1 for GEN3 and derivatives
PRR1 |= MASK(PRUSART3) | MASK(PRUSART2);
#endif
#if defined(PRUSART2)
// don't use USART2 or USART3- leave USART1 for GEN3 and derivatives
PRR1 |= MASK(PRUSART2);
#endif
#endif
ACSR = MASK(ACD);
// setup I/O pins
// X Stepper // X Stepper
WRITE(X_STEP_PIN, 0); SET_OUTPUT(X_STEP_PIN); WRITE(X_STEP_PIN, 0); SET_OUTPUT(X_STEP_PIN);
@ -206,6 +182,9 @@ void io_init(void) {
investigated). investigated).
*/ */
void init(void) { void init(void) {
cpu_init();
#ifndef __ARMEL_NOTYET__ #ifndef __ARMEL_NOTYET__
// set up watchdog // set up watchdog
wd_init(); wd_init();

View File

@ -10,7 +10,9 @@
#include "simulator.h" #include "simulator.h"
#include "data_recorder.h" #include "data_recorder.h"
uint8_t ACSR; void cpu_init(void) {
}
uint8_t TIMSK1; uint8_t TIMSK1;
uint16_t uint16_t
TCCR0A, TCCR0A,
@ -205,7 +207,7 @@ void sim_tick(char ch) {
fflush(stdout); fflush(stdout);
} }
static char gcode_buffer[300]; static char gcode_buffer[300];
static int gcode_buffer_index; static int gcode_buffer_index;
void sim_gcode_ch(char ch) { void sim_gcode_ch(char ch) {
// Got CR, LF or buffer full // Got CR, LF or buffer full