2021-06-26 15:24:07 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2019-12-06 07:27:08 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2019 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef GOWIN_HPP_
|
|
|
|
|
#define GOWIN_HPP_
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "device.hpp"
|
|
|
|
|
#include "fsparser.hpp"
|
2020-03-06 09:05:57 +01:00
|
|
|
#include "jtag.hpp"
|
2019-12-06 07:27:08 +01:00
|
|
|
#include "jedParser.hpp"
|
|
|
|
|
|
|
|
|
|
class Gowin: public Device {
|
|
|
|
|
public:
|
2021-02-21 18:30:13 +01:00
|
|
|
Gowin(Jtag *jtag, std::string filename, const std::string &file_type,
|
|
|
|
|
Device::prog_type_t prg_type,
|
2021-06-25 08:58:45 +02:00
|
|
|
bool verify, int8_t verbose);
|
2019-12-06 07:27:08 +01:00
|
|
|
~Gowin();
|
|
|
|
|
int idCode() override;
|
2020-01-15 09:49:09 +01:00
|
|
|
void reset() override;
|
2019-12-06 07:27:08 +01:00
|
|
|
void program(unsigned int offset) override;
|
2020-01-04 17:37:16 +01:00
|
|
|
void programFlash();
|
2019-12-06 07:27:08 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool wr_rd(uint8_t cmd, uint8_t *tx, int tx_len,
|
|
|
|
|
uint8_t *rx, int rx_len, bool verbose = false);
|
|
|
|
|
bool EnableCfg();
|
|
|
|
|
bool DisableCfg();
|
|
|
|
|
bool pollFlag(uint32_t mask, uint32_t value);
|
|
|
|
|
bool eraseSRAM();
|
2020-01-04 17:37:16 +01:00
|
|
|
bool eraseFLASH();
|
2019-12-06 07:27:08 +01:00
|
|
|
bool flashSRAM(uint8_t *data, int length);
|
2020-01-04 17:37:16 +01:00
|
|
|
bool flashFLASH(uint8_t *data, int length);
|
2019-12-06 07:27:08 +01:00
|
|
|
void displayReadReg(uint32_t dev);
|
|
|
|
|
uint32_t readStatusReg();
|
|
|
|
|
uint32_t readUserCode();
|
|
|
|
|
FsParser *_fs;
|
2020-05-23 14:51:48 +02:00
|
|
|
bool is_gw1n1;
|
2019-12-06 07:27:08 +01:00
|
|
|
};
|
|
|
|
|
#endif // GOWIN_HPP_
|