selftest working now
This commit is contained in:
parent
54538e7e77
commit
7077bfbd57
|
|
@ -82,7 +82,7 @@ OUTPUT_FILE_DEP:= ./makedep.mk
|
|||
./%.o: .././%.c
|
||||
@echo Building file: $<
|
||||
@echo Invoking: AVR/GNU C Compiler : (AVR_8_bit_GNU_Toolchain_3.4.0_663) 4.6.2
|
||||
$(QUOTE)C:\Program Files (x86)\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\3.4.0.65\AVRToolchain\bin\avr-gcc.exe$(QUOTE) -funsigned-char -funsigned-bitfields -O1 -fpack-struct -fshort-enums -g2 -Wall -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -mmcu=atmega1284p -o"$@" "$<"
|
||||
$(QUOTE)C:\Program Files (x86)\Atmel\Atmel Studio 6.0\extensions\Atmel\AVRGCC\3.4.0.65\AVRToolchain\bin\avr-gcc.exe$(QUOTE) -funsigned-char -funsigned-bitfields -O1 -fpack-struct -fshort-enums -g2 -Wall -Werror -pedantic -pedantic-errors -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -mmcu=atmega1284p -o"$@" "$<"
|
||||
@echo Finished building: $<
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
BODLEVEL = 4V3
|
||||
OCDEN = [ ]
|
||||
JTAGEN = [ ]
|
||||
SPIEN = [X]
|
||||
WDTON = [ ]
|
||||
EESAVE = [ ]
|
||||
BOOTSZ = 4096W_F000
|
||||
BOOTRST = [ ]
|
||||
CKDIV8 = [ ]
|
||||
CKOUT = [ ]
|
||||
SUT_CKSEL = FSOSC_16KCK_65MS_XOSC_SLOWPWR
|
||||
|
||||
EXTENDED = 0xFC (valid)
|
||||
HIGH = 0xD9 (valid)
|
||||
LOW = 0xF7 (valid)
|
||||
|
|
@ -25,21 +25,21 @@
|
|||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<ToolchainSettings>
|
||||
<AvrGcc>
|
||||
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
|
||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>m</Value>
|
||||
</ListValues>
|
||||
</avrgcc.linker.libraries.Libraries>
|
||||
</AvrGcc>
|
||||
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
|
||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>m</Value>
|
||||
</ListValues>
|
||||
</avrgcc.linker.libraries.Libraries>
|
||||
</AvrGcc>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
|
|
@ -55,6 +55,9 @@
|
|||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcc.compiler.warnings.WarningsAsErrors>True</avrgcc.compiler.warnings.WarningsAsErrors>
|
||||
<avrgcc.compiler.warnings.Pedantic>True</avrgcc.compiler.warnings.Pedantic>
|
||||
<avrgcc.compiler.warnings.PedanticWarningsAsErrors>True</avrgcc.compiler.warnings.PedanticWarningsAsErrors>
|
||||
<avrgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>m</Value>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include <avr/sleep.h>
|
||||
|
||||
#include "uart.h"
|
||||
#include "config.h"
|
||||
|
||||
/* some mcus have multiple uarts */
|
||||
#ifdef UDR0
|
||||
|
|
@ -58,9 +59,7 @@
|
|||
#endif
|
||||
|
||||
#define BAUD 9600UL
|
||||
#warning "CPU frequency hardcoded here"
|
||||
#define UBRRVAL (18432000UL/(BAUD*16)-1)
|
||||
/*define UBRRVAL (2304000UL/(BAUD*16)-1) mit 8er Teiler */
|
||||
#define UBRRVAL (CPU_FREQ/(BAUD*16)-1)
|
||||
#define USE_SLEEP 1
|
||||
|
||||
void uart_init()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* P8000 WDC Emulator
|
||||
*
|
||||
* $Id: wdc_config.h,v 1.2 2012/05/29 20:23:09 olivleh1 Exp $
|
||||
* $Id: wdc_config.h,v 1.3 2012/05/30 16:41:00 olivleh1 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -9,6 +9,8 @@
|
|||
#ifndef CONFIG_H_
|
||||
#define CONFIG_H_
|
||||
|
||||
#define CPU_FREQ 18432000UL
|
||||
|
||||
#define PORT_DATA PORTA
|
||||
#define PIN_DATA PINA
|
||||
#define DDR_DATA DDRA
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* P8000 WDC Emulator
|
||||
*
|
||||
* $Id: wdc_main.c,v 1.2 2012/05/29 20:23:09 olivleh1 Exp $
|
||||
* $Id: wdc_main.c,v 1.3 2012/05/30 16:41:00 olivleh1 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -11,8 +11,9 @@
|
|||
#include <avr/sleep.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "uart.h"
|
||||
#include "config.h"
|
||||
#include "main.h"
|
||||
#include "uart.h"
|
||||
|
||||
void atmega_setup(void);
|
||||
|
||||
|
|
@ -20,10 +21,14 @@ int main(void)
|
|||
{
|
||||
uint8_t cmdbuffer[9];
|
||||
uint8_t cmdcnt;
|
||||
uint8_t buffer[9];
|
||||
uint8_t datacnt;
|
||||
uint16_t data_counter;
|
||||
uint16_t data_address;
|
||||
|
||||
atmega_setup();
|
||||
|
||||
uart_puts_p(PSTR("P8000 WDC Emulator 1.0\n"));
|
||||
uart_puts_p(PSTR("P8000 WDC Emulator 0.01\n"));
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
|
@ -49,8 +54,105 @@ int main(void)
|
|||
while ( !isset_info_wdardy() );
|
||||
cmdcnt++;
|
||||
}
|
||||
port_info_set( INFO_CLEAR );
|
||||
|
||||
uart_puts_p(PSTR("CMD Buffer:"));
|
||||
switch( cmdbuffer[0] )
|
||||
{
|
||||
case CMD_WR_WDC_RAM:
|
||||
|
||||
for(data_counter=1000;data_counter>0;data_counter--) asm("nop");
|
||||
|
||||
data_counter = (cmdbuffer[7]<<8)|cmdbuffer[6];
|
||||
|
||||
configure_port_data_read();
|
||||
datacnt = 0;
|
||||
port_info_set( INFO_STAT_RDATA );
|
||||
while ( !isset_info_te() );
|
||||
while ( !isset_info_wdardy() );
|
||||
while ( datacnt < data_counter )
|
||||
{
|
||||
while ( isset_info_wdardy() );
|
||||
port_info_set( INFO_ASTB | INFO_STAT_RDATA );
|
||||
buffer[datacnt] = port_data_get();
|
||||
port_info_set( INFO_STAT_RDATA );
|
||||
while ( !isset_info_wdardy() );
|
||||
|
||||
datacnt++;
|
||||
}
|
||||
|
||||
port_info_set( INFO_CLEAR );
|
||||
|
||||
data_address = convert_ram_address((cmdbuffer[2]<<8)+cmdbuffer[1]);
|
||||
do
|
||||
{
|
||||
data_counter--;
|
||||
wdc_ram[data_address+data_counter] = buffer[+data_counter];
|
||||
} while (data_counter > 0);
|
||||
|
||||
uart_puts_p(PSTR("DATA Buffer:"));
|
||||
uart_putc_hex(wdc_ram[data_address+0]);
|
||||
uart_putc_hex(wdc_ram[data_address+1]);
|
||||
break;
|
||||
|
||||
case CMD_RD_WDC_RAM:
|
||||
|
||||
data_counter = (cmdbuffer[7]<<8)|cmdbuffer[6];
|
||||
data_address = convert_ram_address((cmdbuffer[2]<<8)+cmdbuffer[1]);
|
||||
do
|
||||
{
|
||||
data_counter--;
|
||||
buffer[+data_counter] = wdc_ram[data_address+data_counter];
|
||||
} while (data_counter > 0);
|
||||
|
||||
for(data_counter=1000;data_counter>0;data_counter--) asm("nop");
|
||||
|
||||
data_counter = (cmdbuffer[7]<<8)|cmdbuffer[6];
|
||||
datacnt = 0;
|
||||
|
||||
port_info_set( INFO_TR |INFO_STAT_WDATA );
|
||||
while ( isset_info_te() );
|
||||
configure_port_data_write();
|
||||
while ( !isset_info_wdardy() );
|
||||
while ( datacnt < data_counter )
|
||||
{
|
||||
while ( isset_info_wdardy() );
|
||||
port_info_set( INFO_TR | INFO_ASTB | INFO_STAT_WDATA );
|
||||
port_data_set(buffer[datacnt]);
|
||||
port_info_set( INFO_TR |INFO_STAT_WDATA );
|
||||
while ( !isset_info_wdardy() );
|
||||
|
||||
datacnt++;
|
||||
}
|
||||
while ( isset_info_wdardy() );
|
||||
port_info_set( INFO_TR | INFO_ASTB | INFO_STAT_WDATA );
|
||||
asm("nop");
|
||||
port_info_set( INFO_TR |INFO_STAT_WDATA );
|
||||
configure_port_data_read();
|
||||
port_info_set( INFO_CLEAR );
|
||||
break;
|
||||
default:
|
||||
for(data_counter=1000;data_counter>0;data_counter--) asm("nop");
|
||||
port_info_set( INFO_TR | INFO_STAT_ERROR );
|
||||
while ( isset_info_te() );
|
||||
configure_port_data_write();
|
||||
while ( !isset_info_wdardy() );
|
||||
while ( isset_info_wdardy() );
|
||||
port_info_set( INFO_TR | INFO_ASTB | INFO_STAT_ERROR );
|
||||
port_data_set(0x01);
|
||||
port_info_set( INFO_TR | INFO_STAT_ERROR );
|
||||
while ( !isset_info_wdardy() );
|
||||
while ( isset_info_wdardy() );
|
||||
port_info_set( INFO_TR | INFO_ASTB | INFO_STAT_ERROR );
|
||||
asm("nop");
|
||||
asm("nop");
|
||||
port_info_set( INFO_TR | INFO_STAT_ERROR );
|
||||
configure_port_data_read();
|
||||
while ( !isset_info_wdardy() );
|
||||
port_info_set( INFO_CLEAR );
|
||||
break;
|
||||
}
|
||||
|
||||
uart_puts_p(PSTR(" CMD Buffer:"));
|
||||
uart_putc_hex(cmdbuffer[0]);
|
||||
uart_putc_hex(cmdbuffer[1]);
|
||||
uart_putc_hex(cmdbuffer[2]);
|
||||
|
|
@ -61,6 +163,7 @@ int main(void)
|
|||
uart_putc_hex(cmdbuffer[7]);
|
||||
uart_putc_hex(cmdbuffer[8]);
|
||||
uart_putc('\n');
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* P8000 WDC Emulator
|
||||
*
|
||||
* $Id: wdc_main.h,v 1.3 2012/05/29 20:23:59 olivleh1 Exp $
|
||||
* $Id: wdc_main.h,v 1.4 2012/05/30 16:41:00 olivleh1 Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -9,9 +9,6 @@
|
|||
#ifndef MAIN_H_
|
||||
#define MAIN_H_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#define configure_port_data_read() DDR_DATA = 0x00 /* programs the DATA-Port as Input-only for reading from the P8000*/
|
||||
#define configure_port_data_write() DDR_DATA = 0xff /* programs the DATA-Port as Out-only for writing to the P8000*/
|
||||
|
||||
|
|
@ -43,5 +40,12 @@
|
|||
#define INFO_STAT_RDATA (1 << PIN_INFO_STATUS1) /* 0x02 */
|
||||
#define INFO_STAT_WDATA ((1 << PIN_INFO_STATUS0) | (1 << PIN_INFO_STATUS1)) /* 0x03 */
|
||||
#define INFO_STAT_ERROR ((1 << PIN_INFO_STATUS0) | (1 << PIN_INFO_STATUS1) | (1 << PIN_INFO_STATUS2)) /* 0x07 */
|
||||
#define INFO_TR 0x40
|
||||
|
||||
#define CMD_WR_WDC_RAM 0x18 /* P8000 Command: write data to WDC RAM */
|
||||
#define CMD_RD_WDC_RAM 0x08 /* P8000 Command: read data from WDC RAM */
|
||||
|
||||
unsigned char wdc_ram[2048];
|
||||
#define convert_ram_address(x) ((x) - 0x2000) /* The S-RAM of the original WDC hardware starts at 0x2000.
|
||||
We use an array as RAM here and no direct RAM access */
|
||||
#endif /* MAIN_H_ */
|
||||
|
|
|
|||
Loading…
Reference in New Issue