mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 19:54:39 +00:00
CPLD: Introduce Config type to clean up programming interface.
Hide the details of how the CPLD data is stored.
This commit is contained in:
parent
76c2cc77af
commit
a3483a8394
@ -27,11 +27,11 @@
|
|||||||
#include "jtag_target_gpio.hpp"
|
#include "jtag_target_gpio.hpp"
|
||||||
#include "cpld_max5.hpp"
|
#include "cpld_max5.hpp"
|
||||||
#include "cpld_xilinx.hpp"
|
#include "cpld_xilinx.hpp"
|
||||||
|
#include "portapack_cpld_data.hpp"
|
||||||
#include "hackrf_cpld_data.hpp"
|
#include "hackrf_cpld_data.hpp"
|
||||||
|
|
||||||
bool cpld_update_if_necessary(
|
bool cpld_update_if_necessary(
|
||||||
const std::array<uint16_t, 3328>& block_0,
|
const portapack::cpld::Config config
|
||||||
const std::array<uint16_t, 512>& block_1
|
|
||||||
) {
|
) {
|
||||||
jtag::GPIOTarget target {
|
jtag::GPIOTarget target {
|
||||||
portapack::gpio_cpld_tck,
|
portapack::gpio_cpld_tck,
|
||||||
@ -65,11 +65,11 @@ bool cpld_update_if_necessary(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Verify CPLD contents against current bitstream. */
|
/* Verify CPLD contents against current bitstream. */
|
||||||
auto ok = cpld.verify(block_0, block_1);
|
auto ok = cpld.verify(config.block_0, config.block_1);
|
||||||
|
|
||||||
/* CPLD verifies incorrectly. Erase and program with current bitstream. */
|
/* CPLD verifies incorrectly. Erase and program with current bitstream. */
|
||||||
if( !ok ) {
|
if( !ok ) {
|
||||||
ok = cpld.program(block_0, block_1);
|
ok = cpld.program(config.block_0, config.block_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If programming OK, reset CPLD to user mode. Otherwise leave it in
|
/* If programming OK, reset CPLD to user mode. Otherwise leave it in
|
||||||
|
@ -22,12 +22,10 @@
|
|||||||
#ifndef __CPLD_UPDATE_H__
|
#ifndef __CPLD_UPDATE_H__
|
||||||
#define __CPLD_UPDATE_H__
|
#define __CPLD_UPDATE_H__
|
||||||
|
|
||||||
#include <cstdint>
|
#include "portapack_cpld_data.hpp"
|
||||||
#include <array>
|
|
||||||
|
|
||||||
bool cpld_update_if_necessary(
|
bool cpld_update_if_necessary(
|
||||||
const std::array<uint16_t, 3328>& block_0,
|
const portapack::cpld::Config config
|
||||||
const std::array<uint16_t, 512>& block_1
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bool cpld_hackrf_load_sram();
|
bool cpld_hackrf_load_sram();
|
||||||
|
@ -176,11 +176,11 @@ void init() {
|
|||||||
clock_manager.run_at_full_speed();
|
clock_manager.run_at_full_speed();
|
||||||
|
|
||||||
if( portapack_model() == PortaPackModel::R2_20170522 ) {
|
if( portapack_model() == PortaPackModel::R2_20170522 ) {
|
||||||
if( !cpld_update_if_necessary(portapack::cpld::rev_20170522::block_0, portapack::cpld::rev_20170522::block_1) ) {
|
if( !cpld_update_if_necessary(portapack::cpld::rev_20170522::config) ) {
|
||||||
chSysHalt();
|
chSysHalt();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if( !cpld_update_if_necessary(portapack::cpld::rev_20150901::block_0, portapack::cpld::rev_20150901::block_1) ) {
|
if( !cpld_update_if_necessary(portapack::cpld::rev_20150901::config) ) {
|
||||||
chSysHalt();
|
chSysHalt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,14 +28,27 @@
|
|||||||
namespace portapack {
|
namespace portapack {
|
||||||
namespace cpld {
|
namespace cpld {
|
||||||
|
|
||||||
|
struct Config {
|
||||||
|
const std::array<uint16_t, 3328>& block_0;
|
||||||
|
const std::array<uint16_t, 512>& block_1;
|
||||||
|
};
|
||||||
|
|
||||||
namespace rev_20150901 {
|
namespace rev_20150901 {
|
||||||
|
|
||||||
extern const std::array<uint16_t, 3328> block_0;
|
extern const std::array<uint16_t, 3328> block_0;
|
||||||
extern const std::array<uint16_t, 512> block_1;
|
extern const std::array<uint16_t, 512> block_1;
|
||||||
|
|
||||||
|
const Config config { block_0, block_1 };
|
||||||
|
|
||||||
} /* namespace rev_20150901 */
|
} /* namespace rev_20150901 */
|
||||||
|
|
||||||
namespace rev_20170522 {
|
namespace rev_20170522 {
|
||||||
|
|
||||||
extern const std::array<uint16_t, 3328> block_0;
|
extern const std::array<uint16_t, 3328> block_0;
|
||||||
extern const std::array<uint16_t, 512> block_1;
|
extern const std::array<uint16_t, 512> block_1;
|
||||||
|
|
||||||
|
const Config config { block_0, block_1 };
|
||||||
|
|
||||||
} /* namespace rev_20170522 */
|
} /* namespace rev_20170522 */
|
||||||
|
|
||||||
} /* namespace cpld */
|
} /* namespace cpld */
|
||||||
|
Loading…
Reference in New Issue
Block a user