00001 /* Board specific definitions for the HLog V1.1.0 platform - external RAM */ 00002 /* Copyright (C) 2009 ThomasKlosa 00003 * (C) 2010 Holger Dietze 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) version 3. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 #ifndef EXTMEM_H 00020 #define EXTMEM_H 00021 00022 #include <stdlib.h> 00023 00024 #include "xpal_board.h" 00025 #include "xpal_power.h" 00026 #include "usb-fifo.h" 00027 00035 inline void ExtMemInit(void) 00036 { 00037 00038 HL_ADRH_PORT = 0x00; // set outside RAM area 00039 // required to have the RAM in deselected state 00040 // when mem controler is disabled for sleep. 00041 HL_ADRH_DDR = 0xFF; // set to out 00042 00043 XMCRA = HL_XMCRA; // init according to board definition 00044 XMCRB = HL_XMCRB; 00045 00046 00047 // move heap area in external RAM 00048 __malloc_heap_start = (char *)HL_EXRAM_START; 00049 __malloc_heap_end = (char *)HL_EXRAM_END; 00050 00051 }; 00052 00053 00061 inline void ExtMemDisable(void) 00062 { 00063 // disable RAM to enter data retention mode 00064 XMCRA &= ~(_BV(SRE)); 00065 00066 }; 00067 00068 00074 inline void ExtMemEnable(void) 00075 { 00076 // enable RAM to allow access 00077 XMCRA |= (_BV(SRE)); 00078 00079 }; 00080 00081 00087 inline void ExtMemReducePower(void) 00088 { 00089 // Check if USB is active 00090 //if( ! (HL_PWR_USB_ACTIVE & (hl_pwr_GetState())) ){ 00091 00092 // USB is not active 00093 // volatile char x = *((char *)HL_USB_BASE_ADR); 00094 00095 // silence compiler warning "unused variable 'x'" 00096 // __asm__ ("" : : "r" (x)); 00097 //} 00098 }; 00099 00100 00103 typedef struct hlog_extmem_info_s { 00104 void * xmem_start; 00105 void * xmem_end; 00106 } hlog_extmem_info_t; 00107 00117 hlog_extmem_info_t * extmem_test (uint8_t level); 00118 00119 #endif 00120