mirror of
https://github.com/dougg3/mac-rom-simm-programmer.git
synced 2024-11-22 06:32:23 +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 "tests/simm_electrical_test.h"
|
||||
#include "usb_serial/usb_serial.h"
|
||||
#include "led.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
cli();
|
||||
|
||||
DDRD |= (1 << 7);
|
||||
PORTD &= ~(1 << 7);
|
||||
LED_Init();
|
||||
|
||||
// If there was a brownout detected, turn on the LED momentarily
|
||||
if (MCUSR & (1 << BORF))
|
||||
{
|
||||
MCUSR = 0;
|
||||
PORTD |= (1 << 7);
|
||||
LED_On();
|
||||
_delay_ms(500);
|
||||
PORTD &= ~(1 << 7);
|
||||
LED_Off();
|
||||
}
|
||||
|
||||
ExternalMem_Init();
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "../external_mem.h"
|
||||
#include "../tests/simm_electrical_test.h"
|
||||
#include "../programmer_protocol.h"
|
||||
#include "../led.h"
|
||||
|
||||
#define MAX_CHIP_SIZE (512UL * 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.
|
||||
if (curReadIndex >= readLength)
|
||||
{
|
||||
LED_Off();
|
||||
SendByte(ProgrammerReadFinished);
|
||||
curCommandState = WaitingForCommand;
|
||||
}
|
||||
else // There's more data left to read, so read it and send it to them!
|
||||
{
|
||||
LED_Toggle();
|
||||
SendByte(ProgrammerReadMoreData);
|
||||
USBSerial_SendReadDataChunk();
|
||||
}
|
||||
@ -341,11 +344,13 @@ void USBSerial_HandleWritingChipsByte(uint8_t byte)
|
||||
break;
|
||||
// The computer said that it's done writing.
|
||||
case ComputerWriteFinish:
|
||||
LED_Off();
|
||||
SendByte(ProgrammerWriteOK);
|
||||
curCommandState = WaitingForCommand;
|
||||
break;
|
||||
// The computer asked to cancel.
|
||||
case ComputerWriteCancel:
|
||||
LED_Off();
|
||||
SendByte(ProgrammerWriteConfirmCancel);
|
||||
curCommandState = WaitingForCommand;
|
||||
break;
|
||||
@ -364,6 +369,7 @@ void USBSerial_HandleWritingChipsByte(uint8_t byte)
|
||||
SendByte(ProgrammerWriteOK);
|
||||
curWriteIndex++;
|
||||
writePosInChunk = -1;
|
||||
LED_Toggle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user