mirror of
https://github.com/dougg3/mac-rom-simm-programmer.git
synced 2024-06-13 02:29:32 +00:00
Added LED toggle to write/read modes.
Read is so fast that you can't even see the blinking, but oh well. I also added an "led.h" header file that I should have done long ago.
This commit is contained in:
parent
4b2533b69f
commit
533813e949
19
led.h
Normal file
19
led.h
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* led.h
|
||||||
|
*
|
||||||
|
* Created on: May 27, 2012
|
||||||
|
* Author: Doug
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LED_H_
|
||||||
|
#define LED_H_
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#define PIN_MASK (1 << 7)
|
||||||
|
|
||||||
|
#define LED_Init() do { DDRD |= PIN_MASK; LED_Off(); } while (0)
|
||||||
|
#define LED_On() PORTD |= PIN_MASK
|
||||||
|
#define LED_Off() PORTD &= ~PIN_MASK
|
||||||
|
#define LED_Toggle() PIND = PIN_MASK
|
||||||
|
|
||||||
|
#endif /* LED_H_ */
|
8
main.c
8
main.c
|
@ -28,21 +28,21 @@
|
||||||
#include "external_mem.h"
|
#include "external_mem.h"
|
||||||
#include "tests/simm_electrical_test.h"
|
#include "tests/simm_electrical_test.h"
|
||||||
#include "usb_serial/usb_serial.h"
|
#include "usb_serial/usb_serial.h"
|
||||||
|
#include "led.h"
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
cli();
|
cli();
|
||||||
|
|
||||||
DDRD |= (1 << 7);
|
LED_Init();
|
||||||
PORTD &= ~(1 << 7);
|
|
||||||
|
|
||||||
// If there was a brownout detected, turn on the LED momentarily
|
// If there was a brownout detected, turn on the LED momentarily
|
||||||
if (MCUSR & (1 << BORF))
|
if (MCUSR & (1 << BORF))
|
||||||
{
|
{
|
||||||
MCUSR = 0;
|
MCUSR = 0;
|
||||||
PORTD |= (1 << 7);
|
LED_On();
|
||||||
_delay_ms(500);
|
_delay_ms(500);
|
||||||
PORTD &= ~(1 << 7);
|
LED_Off();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalMem_Init();
|
ExternalMem_Init();
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "../external_mem.h"
|
#include "../external_mem.h"
|
||||||
#include "../tests/simm_electrical_test.h"
|
#include "../tests/simm_electrical_test.h"
|
||||||
#include "../programmer_protocol.h"
|
#include "../programmer_protocol.h"
|
||||||
|
#include "../led.h"
|
||||||
|
|
||||||
#define MAX_CHIP_SIZE (512UL * 1024UL)
|
#define MAX_CHIP_SIZE (512UL * 1024UL)
|
||||||
#define READ_CHUNK_SIZE_BYTES 1024UL
|
#define READ_CHUNK_SIZE_BYTES 1024UL
|
||||||
|
@ -228,11 +229,13 @@ void USBSerial_HandleReadingChipsByte(uint8_t byte)
|
||||||
// that they have finished, and enter command state.
|
// that they have finished, and enter command state.
|
||||||
if (curReadIndex >= readLength)
|
if (curReadIndex >= readLength)
|
||||||
{
|
{
|
||||||
|
LED_Off();
|
||||||
SendByte(ProgrammerReadFinished);
|
SendByte(ProgrammerReadFinished);
|
||||||
curCommandState = WaitingForCommand;
|
curCommandState = WaitingForCommand;
|
||||||
}
|
}
|
||||||
else // There's more data left to read, so read it and send it to them!
|
else // There's more data left to read, so read it and send it to them!
|
||||||
{
|
{
|
||||||
|
LED_Toggle();
|
||||||
SendByte(ProgrammerReadMoreData);
|
SendByte(ProgrammerReadMoreData);
|
||||||
USBSerial_SendReadDataChunk();
|
USBSerial_SendReadDataChunk();
|
||||||
}
|
}
|
||||||
|
@ -341,11 +344,13 @@ void USBSerial_HandleWritingChipsByte(uint8_t byte)
|
||||||
break;
|
break;
|
||||||
// The computer said that it's done writing.
|
// The computer said that it's done writing.
|
||||||
case ComputerWriteFinish:
|
case ComputerWriteFinish:
|
||||||
|
LED_Off();
|
||||||
SendByte(ProgrammerWriteOK);
|
SendByte(ProgrammerWriteOK);
|
||||||
curCommandState = WaitingForCommand;
|
curCommandState = WaitingForCommand;
|
||||||
break;
|
break;
|
||||||
// The computer asked to cancel.
|
// The computer asked to cancel.
|
||||||
case ComputerWriteCancel:
|
case ComputerWriteCancel:
|
||||||
|
LED_Off();
|
||||||
SendByte(ProgrammerWriteConfirmCancel);
|
SendByte(ProgrammerWriteConfirmCancel);
|
||||||
curCommandState = WaitingForCommand;
|
curCommandState = WaitingForCommand;
|
||||||
break;
|
break;
|
||||||
|
@ -364,6 +369,7 @@ void USBSerial_HandleWritingChipsByte(uint8_t byte)
|
||||||
SendByte(ProgrammerWriteOK);
|
SendByte(ProgrammerWriteOK);
|
||||||
curWriteIndex++;
|
curWriteIndex++;
|
||||||
writePosInChunk = -1;
|
writePosInChunk = -1;
|
||||||
|
LED_Toggle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user