Commit b070258e authored by afas1995's avatar afas1995

added main

parent 83c75012
......@@ -23,20 +23,21 @@ void JTAGPort::reset() {
}
void JTAGPort::clockPulse() {
// pulse high
PORTB |= _BV(TCK);
delayMicroseconds(10);
// pulse low
PORTB &= ~_BV(TCK);
delayMicroseconds(10);
}
void JTAGPort::sendBits(uint8_t tms, uint8_t tdi) {
PORTB = tms ? PORTB | _BV(TMS) : PORTB & ~_BV(TMS);
PORTB = tdi ? PORTB | _BV(TDI) : PORTB & ~_BV(TDI);
this->clockPulse();
}
void JTAGPort::sendBits(uint8_t tms, uint8_t tdi, uint8_t size) {
for(int i = 0; i < size; i++) {
PORTB = (tms & _BV(i)) ? PORTB | _BV(TMS) : PORTB & ~_BV(TMS);
PORTB = (tdi & _BV(i)) ? PORTB | _BV(TDI) : PORTB & ~_BV(TDI);
this->clockPulse();
}
for(int i = 0; i < size; i++)
this->sendBits((tms && _BV(i)), (tms && _BV(i)));
}
void JTAGPort::setDR() {
......@@ -53,10 +54,10 @@ void JTAGPort::sendData(uint8_t tdi_pos, uint8_t value) {
this->reset();
this->setDR();
this->sendBits(0, 1, 1);
this->sendBits(0, 1);
for(int i = 0; i < tdi_pos - 2; i++)
this->sendBits(0, 0, 1);
this->sendBits(0, 0);
this->sendBits(EXIT_SHIFT_TMS, EXIT_SHIFT_TDI, EXIT_SHIFT_SIZE);
......@@ -78,7 +79,7 @@ uint8_t JTAGPort::readData(uint8_t tdi_pos) {
this->setDR();
for(int i = 0; i < (BOUNDARY_SIZE - tdi_pos); i++)
this->sendBits(0, 0, 1);
this->sendBits(0, 0);
value = PORTB && _BV(TDO);
......
......@@ -31,6 +31,7 @@ class JTAGPort {
void begin();
void reset();
void clockPulse();
void sendBits(uint8_t tms, uint8_t tdi);
void sendBits(uint8_t tms, uint8_t tdi, uint8_t size);
void setDR();
void setIR();
......
#include <Arduino.h>
#include <jtag.h>
#define BAUD 9600
void print_commands() {
Serial.println("Command list");
Serial.println("d - get ID CODE in hex");
Serial.println("1 - turn on LED");
Serial.println("0 - turn off LED");
Serial.println("b - get state of button in pin 29");
Serial.println("i - print command list");
}
void setup() {
JTAG.begin();
Serial.begin(BAUD);
Serial.println("Welcome\n\n");
print_commands();
}
void loop() {
if(Serial.available()){
switch(Serial.read()) {
case 'd':
break;
case '1':
break;
case '0':
break;
case 'b':
break;
case 'i':
print_commands();
break;
default:
Serial.println("Command not available!");
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment