jtagprog fixed. (to be checked by reading back the CPLD to be sure of the programming).
This commit is contained in:
@ -57,12 +57,16 @@ void cpld_jtag_release(void) {
|
|||||||
GPIO_DIR(PORT_CPLD_TDI) &= ~PIN_CPLD_TDI;
|
GPIO_DIR(PORT_CPLD_TDI) &= ~PIN_CPLD_TDI;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpld_jtag_program(const uint32_t len, unsigned char* const data) {
|
/* return 0 if success else return error code see xsvfExecute() */
|
||||||
|
int cpld_jtag_program(const uint32_t len, unsigned char* const data) {
|
||||||
|
int error;
|
||||||
cpld_jtag_setup();
|
cpld_jtag_setup();
|
||||||
xsvf_data = data;
|
xsvf_data = data;
|
||||||
xsvf_len = len;
|
xsvf_len = len;
|
||||||
xsvfExecute();
|
error = xsvfExecute();
|
||||||
cpld_jtag_release();
|
cpld_jtag_release();
|
||||||
|
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this gets called by the XAPP058 code */
|
/* this gets called by the XAPP058 code */
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void cpld_jtag_release(void);
|
void cpld_jtag_release(void);
|
||||||
void cpld_jtag_program(const uint32_t len, unsigned char* const data);
|
/* return 0 if success else return error code see xsvfExecute() see micro.h */
|
||||||
|
int cpld_jtag_program(const uint32_t len, unsigned char* const data);
|
||||||
unsigned char cpld_jtag_get_next_byte(void);
|
unsigned char cpld_jtag_get_next_byte(void);
|
||||||
|
|
||||||
#endif//__CPLD_JTAG_H__
|
#endif//__CPLD_JTAG_H__
|
||||||
|
@ -22,6 +22,28 @@
|
|||||||
//static int g_iTMS = 0; /* For xapp058_example .exe */
|
//static int g_iTMS = 0; /* For xapp058_example .exe */
|
||||||
//static int g_iTDI = 0; /* For xapp058_example .exe */
|
//static int g_iTDI = 0; /* For xapp058_example .exe */
|
||||||
|
|
||||||
|
void delay_jtag(uint32_t duration)
|
||||||
|
{
|
||||||
|
#define DIVISOR (1024)
|
||||||
|
#define MIN_NOP (8)
|
||||||
|
|
||||||
|
uint32_t i;
|
||||||
|
uint32_t delay_nop;
|
||||||
|
|
||||||
|
/* @204Mhz duration of about 400ns for delay_nop=20 */
|
||||||
|
if(duration < DIVISOR)
|
||||||
|
{
|
||||||
|
delay_nop = MIN_NOP;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
delay_nop = (duration / DIVISOR) + MIN_NOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < delay_nop; i++)
|
||||||
|
__asm__("nop");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN95PP
|
#ifdef WIN95PP
|
||||||
#include "conio.h"
|
#include "conio.h"
|
||||||
|
|
||||||
@ -127,7 +149,7 @@ void setPort(short p,short val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* conservative delay */
|
/* conservative delay */
|
||||||
delay(20000);
|
delay_jtag(20000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -135,9 +157,9 @@ void setPort(short p,short val)
|
|||||||
void pulseClock()
|
void pulseClock()
|
||||||
{
|
{
|
||||||
setPort(TCK,0); /* set the TCK port to low */
|
setPort(TCK,0); /* set the TCK port to low */
|
||||||
delay(200);
|
delay_jtag(200);
|
||||||
setPort(TCK,1); /* set the TCK port to high */
|
setPort(TCK,1); /* set the TCK port to high */
|
||||||
delay(200);
|
delay_jtag(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -169,7 +191,7 @@ unsigned char readTDOBit()
|
|||||||
/* You must return the current value of the JTAG TDO signal. */
|
/* You must return the current value of the JTAG TDO signal. */
|
||||||
//return( (unsigned char) 0 );
|
//return( (unsigned char) 0 );
|
||||||
|
|
||||||
delay(2000);
|
delay_jtag(2000);
|
||||||
return CPLD_TDO_STATE;
|
return CPLD_TDO_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,26 +26,45 @@
|
|||||||
#include "cpld_jtag.h"
|
#include "cpld_jtag.h"
|
||||||
#include "sgpio_if_xsvf.h"
|
#include "sgpio_if_xsvf.h"
|
||||||
|
|
||||||
|
#define WAIT_LOOP_DELAY (6000000)
|
||||||
|
|
||||||
|
#define ALL_LEDS (PIN_LED1|PIN_LED2|PIN_LED3)
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
int error;
|
||||||
|
int LED;
|
||||||
|
|
||||||
pin_setup();
|
pin_setup();
|
||||||
|
|
||||||
/* Set 1V8 */
|
/* Set 1V8 */
|
||||||
gpio_set(PORT_EN1V8, PIN_EN1V8);
|
gpio_set(PORT_EN1V8, PIN_EN1V8);
|
||||||
|
|
||||||
/* program test bitstream to CPLD */
|
cpu_clock_init();
|
||||||
cpld_jtag_program(sgpio_if_xsvf_len, &sgpio_if_xsvf[0]);
|
|
||||||
|
/* program test bitstream to CPLD */
|
||||||
|
error = cpld_jtag_program(sgpio_if_xsvf_len, &sgpio_if_xsvf[0]);
|
||||||
|
|
||||||
|
if(error == 0)
|
||||||
|
{
|
||||||
|
/* blink only LED1 (Green) on success */
|
||||||
|
LED = PIN_LED1;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
/* blink LED3 (Red) on error */
|
||||||
|
LED = PIN_LED3;
|
||||||
|
}
|
||||||
|
|
||||||
|
gpio_clear(PORT_LED1_3, ALL_LEDS); /* All LEDs off */
|
||||||
|
|
||||||
/* blink LED1 and LED3 */
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
gpio_set(PORT_LED1_3, (PIN_LED1|PIN_LED3)); /* LEDs on */
|
gpio_set(PORT_LED1_3, LED); /* LEDs on */
|
||||||
for (i = 0; i < 2000000; i++) /* Wait a bit. */
|
for (i = 0; i < WAIT_LOOP_DELAY; i++) /* Wait a bit. */
|
||||||
__asm__("nop");
|
__asm__("nop");
|
||||||
gpio_clear(PORT_LED1_3, (PIN_LED1|PIN_LED3)); /* LED off */
|
gpio_clear(PORT_LED1_3, LED); /* LED off */
|
||||||
for (i = 0; i < 2000000; i++) /* Wait a bit. */
|
for (i = 0; i < WAIT_LOOP_DELAY; i++) /* Wait a bit. */
|
||||||
__asm__("nop");
|
__asm__("nop");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
firmware/cpldjtagprog_rom_to_ram/Makefile
Normal file
36
firmware/cpldjtagprog_rom_to_ram/Makefile
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Hey Emacs, this is a -*- makefile -*-
|
||||||
|
#
|
||||||
|
# Copyright 2012 Michael Ossmann <mike@ossmann.com>
|
||||||
|
# Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||||
|
#
|
||||||
|
# This file is part of HackRF.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
# any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; see the file COPYING. If not, write to
|
||||||
|
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
# Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
|
||||||
|
BINARY = cpldjtagprog_rom_to_ram
|
||||||
|
|
||||||
|
SRC = $(BINARY).c \
|
||||||
|
../common/hackrf_core.c \
|
||||||
|
../common/si5351c.c \
|
||||||
|
../common/max2837.c \
|
||||||
|
../common/cpld_jtag.c \
|
||||||
|
../common/xapp058/lenval.c \
|
||||||
|
../common/xapp058/micro.c \
|
||||||
|
../common/xapp058/ports.c
|
||||||
|
|
||||||
|
LDSCRIPT = ../common/LPC4330_M4_rom_to_ram.ld
|
||||||
|
include ../common/Makefile_inc.mk
|
1
firmware/cpldjtagprog_rom_to_ram/README
Normal file
1
firmware/cpldjtagprog_rom_to_ram/README
Normal file
@ -0,0 +1 @@
|
|||||||
|
This is a test program for CPLD JTAG programming.
|
72
firmware/cpldjtagprog_rom_to_ram/cpldjtagprog_rom_to_ram.c
Normal file
72
firmware/cpldjtagprog_rom_to_ram/cpldjtagprog_rom_to_ram.c
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010 - 2013 Michael Ossmann
|
||||||
|
*
|
||||||
|
* This file is part of HackRF.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <libopencm3/lpc43xx/gpio.h>
|
||||||
|
#include <libopencm3/lpc43xx/scu.h>
|
||||||
|
|
||||||
|
#include "hackrf_core.h"
|
||||||
|
#include "cpld_jtag.h"
|
||||||
|
#include "../cpldjtagprog/sgpio_if_xsvf.h"
|
||||||
|
|
||||||
|
#define WAIT_LOOP_DELAY (6000000)
|
||||||
|
|
||||||
|
#define ALL_LEDS (PIN_LED1|PIN_LED2|PIN_LED3)
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int error;
|
||||||
|
int LED;
|
||||||
|
|
||||||
|
pin_setup();
|
||||||
|
|
||||||
|
/* Set 1V8 */
|
||||||
|
gpio_set(PORT_EN1V8, PIN_EN1V8);
|
||||||
|
|
||||||
|
cpu_clock_init();
|
||||||
|
|
||||||
|
/* program test bitstream to CPLD */
|
||||||
|
error = cpld_jtag_program(sgpio_if_xsvf_len, &sgpio_if_xsvf[0]);
|
||||||
|
|
||||||
|
if(error == 0)
|
||||||
|
{
|
||||||
|
/* blink only LED1 (Green) on success */
|
||||||
|
LED = PIN_LED1;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
/* blink LED3 (Red) on error */
|
||||||
|
LED = PIN_LED3;
|
||||||
|
}
|
||||||
|
|
||||||
|
gpio_clear(PORT_LED1_3, ALL_LEDS); /* All LEDs off */
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
gpio_set(PORT_LED1_3, LED); /* LEDs on */
|
||||||
|
for (i = 0; i < WAIT_LOOP_DELAY; i++) /* Wait a bit. */
|
||||||
|
__asm__("nop");
|
||||||
|
gpio_clear(PORT_LED1_3, LED); /* LED off */
|
||||||
|
for (i = 0; i < WAIT_LOOP_DELAY; i++) /* Wait a bit. */
|
||||||
|
__asm__("nop");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user