git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1357 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
03933a5925
commit
937efbc9b6
|
@ -44,6 +44,8 @@ LDSCRIPT= ch.ld
|
||||||
|
|
||||||
# Imported source files
|
# Imported source files
|
||||||
CHIBIOS = ../..
|
CHIBIOS = ../..
|
||||||
|
include ${CHIBIOS}/os/hal/hal.mk
|
||||||
|
include ${CHIBIOS}/os/hal/platforms/AT91SAM7/platform.mk
|
||||||
include ${CHIBIOS}/os/ports/GCC/ARM7/port.mk
|
include ${CHIBIOS}/os/ports/GCC/ARM7/port.mk
|
||||||
include ${CHIBIOS}/os/kernel/kernel.mk
|
include ${CHIBIOS}/os/kernel/kernel.mk
|
||||||
include ${CHIBIOS}/test/test.mk
|
include ${CHIBIOS}/test/test.mk
|
||||||
|
@ -53,11 +55,8 @@ include ${CHIBIOS}/test/test.mk
|
||||||
CSRC = ${PORTSRC} \
|
CSRC = ${PORTSRC} \
|
||||||
${KERNSRC} \
|
${KERNSRC} \
|
||||||
${TESTSRC} \
|
${TESTSRC} \
|
||||||
${CHIBIOS}/os/io/pal.c \
|
${HALSRC} \
|
||||||
${CHIBIOS}/os/io/serial.c \
|
${PLATFORMSRC} \
|
||||||
${CHIBIOS}/os/io/platforms/AT91SAM7/pal_lld.c \
|
|
||||||
${CHIBIOS}/os/io/platforms/AT91SAM7/serial_lld.c \
|
|
||||||
${CHIBIOS}/os/io/platforms/AT91SAM7/at91lib/aic.c \
|
|
||||||
board.c main.c
|
board.c main.c
|
||||||
|
|
||||||
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
||||||
|
@ -88,9 +87,7 @@ TCPPSRC =
|
||||||
ASMSRC = $(PORTASM) \
|
ASMSRC = $(PORTASM) \
|
||||||
${CHIBIOS}/os/ports/GCC/ARM7/AT91SAM7/vectors.s
|
${CHIBIOS}/os/ports/GCC/ARM7/AT91SAM7/vectors.s
|
||||||
|
|
||||||
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
|
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) $(HALINC) $(PLATFORMINC) \
|
||||||
${CHIBIOS}/os/io \
|
|
||||||
${CHIBIOS}/os/io/platforms/AT91SAM7 \
|
|
||||||
${CHIBIOS}/os/various \
|
${CHIBIOS}/os/various \
|
||||||
${CHIBIOS}/os/ports/GCC/ARM7/AT91SAM7
|
${CHIBIOS}/os/ports/GCC/ARM7/AT91SAM7
|
||||||
|
|
||||||
|
|
|
@ -17,26 +17,8 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ch.h>
|
#include "ch.h"
|
||||||
#include <pal.h>
|
#include "hal.h"
|
||||||
#include <serial.h>
|
|
||||||
|
|
||||||
#include "board.h"
|
|
||||||
#include "at91lib/aic.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FIQ Handler weak symbol defined in vectors.s.
|
|
||||||
*/
|
|
||||||
void FiqHandler(void);
|
|
||||||
|
|
||||||
static CH_IRQ_HANDLER(SpuriousHandler) {
|
|
||||||
|
|
||||||
CH_IRQ_PROLOGUE();
|
|
||||||
|
|
||||||
AT91C_BASE_AIC->AIC_EOICR = 0;
|
|
||||||
|
|
||||||
CH_IRQ_EPILOGUE();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SYS IRQ handling here.
|
* SYS IRQ handling here.
|
||||||
|
@ -56,61 +38,14 @@ static CH_IRQ_HANDLER(SYSIrqHandler) {
|
||||||
CH_IRQ_EPILOGUE();
|
CH_IRQ_EPILOGUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Digital I/O ports static configuration as defined in @p board.h.
|
|
||||||
*/
|
|
||||||
static const AT91SAM7PIOConfig config =
|
|
||||||
{
|
|
||||||
{VAL_PIOA_ODSR, VAL_PIOA_OSR, VAL_PIOA_PUSR},
|
|
||||||
#if defined(SAM7X128) || defined(SAM7X256) || defined(SAM7X512)
|
|
||||||
{VAL_PIOB_ODSR, VAL_PIOB_OSR, VAL_PIOB_PUSR}
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Early initialization code.
|
* Early initialization code.
|
||||||
* This initialization is performed just after reset before BSS and DATA
|
* This initialization is performed just after reset before BSS and DATA
|
||||||
* segments initialization.
|
* segments initialization.
|
||||||
*/
|
*/
|
||||||
void hwinit0(void) {
|
void hwinit0(void) {
|
||||||
/*
|
|
||||||
* Flash Memory: 1 wait state, about 50 cycles in a microsecond.
|
|
||||||
*/
|
|
||||||
AT91C_BASE_MC->MC_FMR = (AT91C_MC_FMCN & (50 << 16)) | AT91C_MC_FWS_1FWS;
|
|
||||||
|
|
||||||
/*
|
at91sam7_clock_init();
|
||||||
* Watchdog disabled.
|
|
||||||
*/
|
|
||||||
AT91C_BASE_WDTC->WDTC_WDMR = AT91C_WDTC_WDDIS;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Enables the main oscillator and waits 56 slow cycles as startup time.
|
|
||||||
*/
|
|
||||||
AT91C_BASE_PMC->PMC_MOR = (AT91C_CKGR_OSCOUNT & (7 << 8)) | AT91C_CKGR_MOSCEN;
|
|
||||||
while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MOSCS))
|
|
||||||
;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PLL setup: DIV = 14, MUL = 72, PLLCOUNT = 10
|
|
||||||
* PLLfreq = 96109714 Hz (rounded)
|
|
||||||
*/
|
|
||||||
AT91C_BASE_PMC->PMC_PLLR = (AT91C_CKGR_DIV & 14) |
|
|
||||||
(AT91C_CKGR_PLLCOUNT & (10 << 8)) |
|
|
||||||
(AT91C_CKGR_MUL & (72 << 16));
|
|
||||||
while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCK))
|
|
||||||
;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Master clock = PLLfreq / 2 = 48054858 Hz (rounded)
|
|
||||||
*/
|
|
||||||
AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_CSS_PLL_CLK | AT91C_PMC_PRES_CLK_2;
|
|
||||||
while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY))
|
|
||||||
;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PIO initialization.
|
|
||||||
*/
|
|
||||||
palInit(&config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -119,19 +54,11 @@ void hwinit0(void) {
|
||||||
* and before invoking the main() function.
|
* and before invoking the main() function.
|
||||||
*/
|
*/
|
||||||
void hwinit1(void) {
|
void hwinit1(void) {
|
||||||
int i;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default AIC setup, the device drivers will modify it as needed.
|
* HAL initialization.
|
||||||
*/
|
*/
|
||||||
AT91C_BASE_AIC->AIC_ICCR = 0xFFFFFFFF;
|
halInit();
|
||||||
AT91C_BASE_AIC->AIC_IDCR = 0xFFFFFFFF;
|
|
||||||
AT91C_BASE_AIC->AIC_SVR[0] = (AT91_REG)FiqHandler;
|
|
||||||
for (i = 1; i < 31; i++) {
|
|
||||||
AT91C_BASE_AIC->AIC_SVR[i] = (AT91_REG)NULL;
|
|
||||||
AT91C_BASE_AIC->AIC_EOICR = (AT91_REG)i;
|
|
||||||
}
|
|
||||||
AT91C_BASE_AIC->AIC_SPU = (AT91_REG)SpuriousHandler;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LCD pins setup.
|
* LCD pins setup.
|
||||||
|
@ -169,9 +96,8 @@ void hwinit1(void) {
|
||||||
AT91C_BASE_PITC->PITC_PIMR |= AT91C_PITC_PITEN | AT91C_PITC_PITIEN;
|
AT91C_BASE_PITC->PITC_PIMR |= AT91C_PITC_PITEN | AT91C_PITC_PITIEN;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Serial driver initialization, RTS/CTS pins enabled for USART0 only.
|
* RTS/CTS pins enabled for USART0 only.
|
||||||
*/
|
*/
|
||||||
sdInit();
|
|
||||||
AT91C_BASE_PIOA->PIO_PDR = AT91C_PA3_RTS0 | AT91C_PA4_CTS0;
|
AT91C_BASE_PIOA->PIO_PDR = AT91C_PA3_RTS0 | AT91C_PA4_CTS0;
|
||||||
AT91C_BASE_PIOA->PIO_ASR = AT91C_PIO_PA3 | AT91C_PIO_PA4;
|
AT91C_BASE_PIOA->PIO_ASR = AT91C_PIO_PA3 | AT91C_PIO_PA4;
|
||||||
AT91C_BASE_PIOA->PIO_PPUDR = AT91C_PIO_PA3 | AT91C_PIO_PA4;
|
AT91C_BASE_PIOA->PIO_PPUDR = AT91C_PIO_PA3 | AT91C_PIO_PA4;
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT 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.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file templates/halconf.h
|
||||||
|
* @brief HAL configuration header.
|
||||||
|
* @addtogroup HAL
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _HALCONF_H_
|
||||||
|
#define _HALCONF_H_
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the PAL subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_HAL_USE_PAL) || defined(__DOXYGEN__)
|
||||||
|
#define CH_HAL_USE_PAL TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the ADC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_HAL_USE_ADC) || defined(__DOXYGEN__)
|
||||||
|
#define CH_HAL_USE_ADC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the CAN subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_HAL_USE_CAN) || defined(__DOXYGEN__)
|
||||||
|
#define CH_HAL_USE_CAN FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the MAC subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_HAL_USE_MAC) || defined(__DOXYGEN__)
|
||||||
|
#define CH_HAL_USE_MAC FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the MII subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_HAL_USE_MII) || defined(__DOXYGEN__)
|
||||||
|
#define CH_HAL_USE_MII FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SERIAL subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_HAL_USE_SERIAL) || defined(__DOXYGEN__)
|
||||||
|
#define CH_HAL_USE_SERIAL TRUE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the SPI subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_HAL_USE_SPI) || defined(__DOXYGEN__)
|
||||||
|
#define CH_HAL_USE_SPI FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enables the MMC_SPI subsystem.
|
||||||
|
*/
|
||||||
|
#if !defined(CH_HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
|
||||||
|
#define CH_HAL_USE_MMC_SPI FALSE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _HALCONF_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -17,12 +17,9 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ch.h>
|
#include "ch.h"
|
||||||
#include <pal.h>
|
#include "hal.h"
|
||||||
#include <serial.h>
|
#include "test.h"
|
||||||
#include <test.h>
|
|
||||||
|
|
||||||
#include "board.h"
|
|
||||||
|
|
||||||
static WORKING_AREA(waThread1, 64);
|
static WORKING_AREA(waThread1, 64);
|
||||||
static msg_t Thread1(void *p) {
|
static msg_t Thread1(void *p) {
|
||||||
|
|
|
@ -44,8 +44,6 @@
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
extern const STM32GPIOConfig pal_default_config;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,125 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT 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.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file AT91SAM7/hal_lld.c
|
||||||
|
* @brief AT91SAM7 HAL subsystem low level driver source
|
||||||
|
* @addtogroup AT91SAM7_HAL
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ch.h"
|
||||||
|
#include "hal.h"
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Low Level Driver exported variables. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Low Level Driver local variables. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Digital I/O ports static configuration as defined in @p board.h.
|
||||||
|
*/
|
||||||
|
const AT91SAM7PIOConfig pal_default_config =
|
||||||
|
{
|
||||||
|
{VAL_PIOA_ODSR, VAL_PIOA_OSR, VAL_PIOA_PUSR},
|
||||||
|
#if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \
|
||||||
|
(SAM7_PLATFORM == SAM7X512)
|
||||||
|
{VAL_PIOB_ODSR, VAL_PIOB_OSR, VAL_PIOB_PUSR}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Low Level Driver local functions. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Low Level Driver interrupt handlers. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
static CH_IRQ_HANDLER(spurious_handler) {
|
||||||
|
|
||||||
|
CH_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
AT91SAM7_SPURIOUS_HANDLER_HOOK();
|
||||||
|
|
||||||
|
AT91C_BASE_AIC->AIC_EOICR = 0;
|
||||||
|
|
||||||
|
CH_IRQ_EPILOGUE();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Low Level Driver exported functions. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Low level HAL driver initialization.
|
||||||
|
*/
|
||||||
|
void hal_lld_init(void) {
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
/* FIQ Handler weak symbol defined in vectors.s.*/
|
||||||
|
void FiqHandler(void);
|
||||||
|
|
||||||
|
/* Default AIC setup, the device drivers will modify it as needed.*/
|
||||||
|
AT91C_BASE_AIC->AIC_ICCR = 0xFFFFFFFF;
|
||||||
|
AT91C_BASE_AIC->AIC_IDCR = 0xFFFFFFFF;
|
||||||
|
AT91C_BASE_AIC->AIC_SVR[0] = (AT91_REG)FiqHandler;
|
||||||
|
for (i = 1; i < 31; i++) {
|
||||||
|
AT91C_BASE_AIC->AIC_SVR[i] = (AT91_REG)NULL;
|
||||||
|
AT91C_BASE_AIC->AIC_EOICR = (AT91_REG)i;
|
||||||
|
}
|
||||||
|
AT91C_BASE_AIC->AIC_SPU = (AT91_REG)spurious_handler;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief AT91SAM7 clocks and PLL initialization.
|
||||||
|
* @note All the involved constants come from the file @p board.h.
|
||||||
|
*/
|
||||||
|
void at91sam7_clock_init(void) {
|
||||||
|
|
||||||
|
/* Flash Memory: 1 wait state, about 50 cycles in a microsecond.*/
|
||||||
|
AT91C_BASE_MC->MC_FMR = (AT91C_MC_FMCN & (50 << 16)) | AT91C_MC_FWS_1FWS;
|
||||||
|
|
||||||
|
/* Watchdog disabled.*/
|
||||||
|
AT91C_BASE_WDTC->WDTC_WDMR = AT91C_WDTC_WDDIS;
|
||||||
|
|
||||||
|
/* Enables the main oscillator and waits 56 slow cycles as startup time.*/
|
||||||
|
AT91C_BASE_PMC->PMC_MOR = (AT91C_CKGR_OSCOUNT & (7 << 8)) | AT91C_CKGR_MOSCEN;
|
||||||
|
while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MOSCS))
|
||||||
|
;
|
||||||
|
|
||||||
|
/* PLL setup: DIV = 14, MUL = 72, PLLCOUNT = 10
|
||||||
|
PLLfreq = 96109714 Hz (rounded).*/
|
||||||
|
AT91C_BASE_PMC->PMC_PLLR = (AT91C_CKGR_DIV & 14) |
|
||||||
|
(AT91C_CKGR_PLLCOUNT & (10 << 8)) |
|
||||||
|
(AT91C_CKGR_MUL & (72 << 16));
|
||||||
|
while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCK))
|
||||||
|
;
|
||||||
|
|
||||||
|
/* Master clock = PLLfreq / 2 = 48054858 Hz (rounded).*/
|
||||||
|
AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_CSS_PLL_CLK | AT91C_PMC_PRES_CLK_2;
|
||||||
|
while (!(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT 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.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file AT91SAM7/hal_lld.h
|
||||||
|
* @brief AT91SAM7 HAL subsystem low level driver header
|
||||||
|
* @addtogroup AT91SAM7_HAL
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _HAL_LLD_H_
|
||||||
|
#define _HAL_LLD_H_
|
||||||
|
|
||||||
|
#include "at91sam7.h"
|
||||||
|
#include "at91lib/aic.h"
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver pre-compile time settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Default action for the spurious handler, nothing.
|
||||||
|
*/
|
||||||
|
#if !defined(AT91SAM7_SPURIOUS_HANDLER_HOOK) || defined(__DOXYGEN__)
|
||||||
|
#define AT91SAM7_SPURIOUS_HANDLER_HOOK()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver constants. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver data structures and types. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* External declarations. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
void hal_lld_init(void);
|
||||||
|
void at91sam7_clock_init(void);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _HAL_LLD_H_ */
|
||||||
|
|
||||||
|
/** @} */
|
|
@ -26,11 +26,10 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <ch.h>
|
#include "ch.h"
|
||||||
#include <mac.h>
|
#include "mac.h"
|
||||||
#include <mii.h>
|
|
||||||
|
|
||||||
#include "at91lib/aic.h"
|
#if CH_HAL_USE_MAC || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Ethernet driver 1.
|
* @brief Ethernet driver 1.
|
||||||
|
@ -481,4 +480,6 @@ bool_t mac_lld_poll_link_status(MACDriver *macp) {
|
||||||
return link_up = TRUE;
|
return link_up = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* CH_HAL_USE_MAC */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#ifndef _MAC_LLD_H_
|
#ifndef _MAC_LLD_H_
|
||||||
#define _MAC_LLD_H_
|
#define _MAC_LLD_H_
|
||||||
|
|
||||||
|
#if CH_HAL_USE_MAC || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver pre-compile time settings. */
|
/* Driver pre-compile time settings. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -187,6 +189,8 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
/** @endcond*/
|
/** @endcond*/
|
||||||
|
|
||||||
|
#endif /* CH_HAL_USE_MAC */
|
||||||
|
|
||||||
#endif /* _MAC_LLD_H_ */
|
#endif /* _MAC_LLD_H_ */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -24,10 +24,10 @@
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ch.h>
|
#include "ch.h"
|
||||||
#include <pal.h>
|
#include "hal.h"
|
||||||
|
|
||||||
#include "board.h"
|
#if CH_HAL_USE_PAL || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AT91SAM7 I/O ports configuration.
|
* @brief AT91SAM7 I/O ports configuration.
|
||||||
|
@ -37,9 +37,9 @@
|
||||||
*/
|
*/
|
||||||
void _pal_lld_init(const AT91SAM7PIOConfig *config) {
|
void _pal_lld_init(const AT91SAM7PIOConfig *config) {
|
||||||
|
|
||||||
unsigned int ports = (1 << AT91C_ID_PIOA);
|
uint32_t ports = (1 << AT91C_ID_PIOA);
|
||||||
#if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \
|
#if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \
|
||||||
(SAM7_PLATFORM == SAM7X256)
|
(SAM7_PLATFORM == SAM7X512)
|
||||||
ports |= (1 << AT91C_ID_PIOB);
|
ports |= (1 << AT91C_ID_PIOB);
|
||||||
#endif
|
#endif
|
||||||
AT91C_BASE_PMC->PMC_PCER = ports;
|
AT91C_BASE_PMC->PMC_PCER = ports;
|
||||||
|
@ -63,7 +63,7 @@ void _pal_lld_init(const AT91SAM7PIOConfig *config) {
|
||||||
* PIOB setup.
|
* PIOB setup.
|
||||||
*/
|
*/
|
||||||
#if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \
|
#if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \
|
||||||
(SAM7_PLATFORM == SAM7X256)
|
(SAM7_PLATFORM == SAM7X512)
|
||||||
AT91C_BASE_PIOB->PIO_PPUER = config->P1Data.pusr; /* Pull-up as spec.*/
|
AT91C_BASE_PIOB->PIO_PPUER = config->P1Data.pusr; /* Pull-up as spec.*/
|
||||||
AT91C_BASE_PIOB->PIO_PPUDR = ~config->P1Data.pusr;
|
AT91C_BASE_PIOB->PIO_PPUDR = ~config->P1Data.pusr;
|
||||||
AT91C_BASE_PIOB->PIO_PER = 0xFFFFFFFF; /* PIO enabled.*/
|
AT91C_BASE_PIOB->PIO_PER = 0xFFFFFFFF; /* PIO enabled.*/
|
||||||
|
@ -124,4 +124,6 @@ void _pal_lld_setgroupmode(ioportid_t port,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* CH_HAL_USE_PAL */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#ifndef _PAL_LLD_H_
|
#ifndef _PAL_LLD_H_
|
||||||
#define _PAL_LLD_H_
|
#define _PAL_LLD_H_
|
||||||
|
|
||||||
#include "board.h"
|
#if CH_HAL_USE_PAL || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Unsupported modes and specific modes */
|
/* Unsupported modes and specific modes */
|
||||||
|
@ -62,7 +62,7 @@ typedef struct {
|
||||||
/** @brief Port 0 setup data.*/
|
/** @brief Port 0 setup data.*/
|
||||||
at91sam7_pio_setup_t P0Data;
|
at91sam7_pio_setup_t P0Data;
|
||||||
#if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \
|
#if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \
|
||||||
(SAM7_PLATFORM == SAM7X256) || defined(__DOXYGEN__)
|
(SAM7_PLATFORM == SAM7X512) || defined(__DOXYGEN__)
|
||||||
/** @brief Port 1 setup data.*/
|
/** @brief Port 1 setup data.*/
|
||||||
at91sam7_pio_setup_t P1Data;
|
at91sam7_pio_setup_t P1Data;
|
||||||
#endif
|
#endif
|
||||||
|
@ -99,7 +99,7 @@ typedef AT91PS_PIO ioportid_t;
|
||||||
* @brief PIO port B identifier.
|
* @brief PIO port B identifier.
|
||||||
*/
|
*/
|
||||||
#if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \
|
#if (SAM7_PLATFORM == SAM7X128) || (SAM7_PLATFORM == SAM7X256) || \
|
||||||
(SAM7_PLATFORM == SAM7X256) || defined(__DOXYGEN__)
|
(SAM7_PLATFORM == SAM7X512) || defined(__DOXYGEN__)
|
||||||
#define IOPORT2 AT91C_BASE_PIOB
|
#define IOPORT2 AT91C_BASE_PIOB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -235,6 +235,8 @@ typedef AT91PS_PIO ioportid_t;
|
||||||
*/
|
*/
|
||||||
#define pal_lld_writepad(port, pad, bit) pal_lld_writegroup(port, 1, pad, bit)
|
#define pal_lld_writepad(port, pad, bit) pal_lld_writegroup(port, 1, pad, bit)
|
||||||
|
|
||||||
|
extern const AT91SAM7PIOConfig pal_default_config;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -246,6 +248,8 @@ extern "C" {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* CH_HAL_USE_PAL */
|
||||||
|
|
||||||
#endif /* _PAL_LLD_H_ */
|
#endif /* _PAL_LLD_H_ */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
# List of all the AT91SAM7 platform files.
|
||||||
|
PLATFORMSRC = ${CHIBIOS}/os/hal/platforms/AT91SAM7/hal_lld.c \
|
||||||
|
${CHIBIOS}/os/hal/platforms/AT91SAM7/pal_lld.c \
|
||||||
|
${CHIBIOS}/os/hal/platforms/AT91SAM7/serial_lld.c \
|
||||||
|
${CHIBIOS}/os/hal/platforms/AT91SAM7/mac_lld.c \
|
||||||
|
${CHIBIOS}/os/hal/platforms/AT91SAM7/at91lib/aic.c
|
||||||
|
|
||||||
|
# Required include directories
|
||||||
|
PLATFORMINC = ${CHIBIOS}/os/hal/platforms/AT91SAM7
|
|
@ -24,11 +24,10 @@
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ch.h>
|
#include "ch.h"
|
||||||
#include <serial.h>
|
#include "hal.h"
|
||||||
|
|
||||||
#include "at91lib/aic.h"
|
#if CH_HAL_USE_SERIAL || defined(__DOXYGEN__)
|
||||||
#include "at91sam7.h"
|
|
||||||
|
|
||||||
#if SAM7_PLATFORM == SAM7S256
|
#if SAM7_PLATFORM == SAM7S256
|
||||||
|
|
||||||
|
@ -295,4 +294,6 @@ void sd_lld_stop(SerialDriver *sdp) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* CH_HAL_USE_SPI */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#ifndef _SERIAL_LLD_H_
|
#ifndef _SERIAL_LLD_H_
|
||||||
#define _SERIAL_LLD_H_
|
#define _SERIAL_LLD_H_
|
||||||
|
|
||||||
|
#if CH_HAL_USE_SERIAL || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver pre-compile time settings. */
|
/* Driver pre-compile time settings. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -152,6 +154,8 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
/** @endcond*/
|
/** @endcond*/
|
||||||
|
|
||||||
|
#endif /* CH_HAL_USE_SPI */
|
||||||
|
|
||||||
#endif /* _SERIAL_LLD_H_ */
|
#endif /* _SERIAL_LLD_H_ */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ch.h>
|
#include "ch.h"
|
||||||
#include <hal.h>
|
#include "hal.h"
|
||||||
|
|
||||||
#define AIRCR_VECTKEY 0x05FA0000
|
#define AIRCR_VECTKEY 0x05FA0000
|
||||||
|
|
||||||
|
|
|
@ -281,6 +281,8 @@ typedef GPIO_TypeDef * ioportid_t;
|
||||||
*/
|
*/
|
||||||
#define pal_lld_writepad(port, pad, bit) pal_lld_writegroup(port, 1, pad, bit)
|
#define pal_lld_writepad(port, pad, bit) pal_lld_writegroup(port, 1, pad, bit)
|
||||||
|
|
||||||
|
extern const STM32GPIOConfig pal_default_config;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue