SPI: Remove MAX2837/5864, W25Q80BV driver dependence on target code.
Conflicts: firmware/common/tuning.c
This commit is contained in:
@ -82,11 +82,13 @@ spi_t spi_ssp1 = {
|
|||||||
|
|
||||||
max2837_driver_t max2837 = {
|
max2837_driver_t max2837 = {
|
||||||
.spi = &spi_ssp1,
|
.spi = &spi_ssp1,
|
||||||
|
.target_init = max2837_target_init,
|
||||||
.set_mode = max2837_target_set_mode,
|
.set_mode = max2837_target_set_mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
max5864_driver_t max5864 = {
|
max5864_driver_t max5864 = {
|
||||||
.spi = &spi_ssp1,
|
.spi = &spi_ssp1,
|
||||||
|
.target_init = max5864_target_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
spi_t rffc5071_spi = {
|
spi_t rffc5071_spi = {
|
||||||
@ -118,6 +120,7 @@ spi_t spi_ssp0 = {
|
|||||||
|
|
||||||
w25q80bv_driver_t spi_flash = {
|
w25q80bv_driver_t spi_flash = {
|
||||||
.spi = &spi_ssp0,
|
.spi = &spi_ssp0,
|
||||||
|
.target_init = w25q80bv_target_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
void delay(uint32_t duration)
|
void delay(uint32_t duration)
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "max2837.h"
|
#include "max2837.h"
|
||||||
#include "max2837_target.h"
|
|
||||||
#include "max2837_regs.def" // private register def macros
|
#include "max2837_regs.def" // private register def macros
|
||||||
|
|
||||||
#include "hackrf_core.h"
|
#include "hackrf_core.h"
|
||||||
@ -80,7 +79,7 @@ static const uint16_t max2837_regs_default[MAX2837_NUM_REGS] = {
|
|||||||
static void max2837_init(max2837_driver_t* const drv)
|
static void max2837_init(max2837_driver_t* const drv)
|
||||||
{
|
{
|
||||||
spi_init(drv->spi, &ssp_config_max2837);
|
spi_init(drv->spi, &ssp_config_max2837);
|
||||||
max2837_target_init(drv);
|
drv->target_init(drv);
|
||||||
max2837_set_mode(drv, MAX2837_MODE_SHUTDOWN);
|
max2837_set_mode(drv, MAX2837_MODE_SHUTDOWN);
|
||||||
|
|
||||||
memcpy(drv->regs, max2837_regs_default, sizeof(drv->regs));
|
memcpy(drv->regs, max2837_regs_default, sizeof(drv->regs));
|
||||||
|
@ -39,13 +39,17 @@ typedef enum {
|
|||||||
MAX2837_MODE_RX
|
MAX2837_MODE_RX
|
||||||
} max2837_mode_t;
|
} max2837_mode_t;
|
||||||
|
|
||||||
typedef struct {
|
struct max2837_driver_t;
|
||||||
|
typedef struct max2837_driver_t max2837_driver_t;
|
||||||
|
|
||||||
|
struct max2837_driver_t {
|
||||||
spi_t* const spi;
|
spi_t* const spi;
|
||||||
|
void (*target_init)(max2837_driver_t* const drv);
|
||||||
void (*set_mode)(max2837_driver_t* const drv, const max2837_mode_t new_mode);
|
void (*set_mode)(max2837_driver_t* const drv, const max2837_mode_t new_mode);
|
||||||
max2837_mode_t mode;
|
max2837_mode_t mode;
|
||||||
uint16_t regs[MAX2837_NUM_REGS];
|
uint16_t regs[MAX2837_NUM_REGS];
|
||||||
uint32_t regs_dirty;
|
uint32_t regs_dirty;
|
||||||
} max2837_driver_t;
|
};
|
||||||
|
|
||||||
/* Initialize chip. */
|
/* Initialize chip. */
|
||||||
extern void max2837_setup(max2837_driver_t* const drv);
|
extern void max2837_setup(max2837_driver_t* const drv);
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "max5864.h"
|
#include "max5864.h"
|
||||||
#include "max5864_target.h"
|
|
||||||
|
|
||||||
#include "hackrf_core.h"
|
#include "hackrf_core.h"
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ static void max5864_write(max5864_driver_t* const drv, uint8_t value) {
|
|||||||
|
|
||||||
static void max5864_init(max5864_driver_t* const drv) {
|
static void max5864_init(max5864_driver_t* const drv) {
|
||||||
spi_init(drv->spi, &ssp_config_max5864);
|
spi_init(drv->spi, &ssp_config_max5864);
|
||||||
max5864_target_init(drv);
|
drv->target_init(drv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void max5864_setup(max5864_driver_t* const drv) {
|
void max5864_setup(max5864_driver_t* const drv) {
|
||||||
|
@ -24,9 +24,13 @@
|
|||||||
|
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
|
|
||||||
typedef struct max5864_driver_t {
|
struct max5864_driver_t;
|
||||||
|
typedef struct max5864_driver_t max5864_driver_t;
|
||||||
|
|
||||||
|
struct max5864_driver_t {
|
||||||
spi_t* const spi;
|
spi_t* const spi;
|
||||||
} max5864_driver_t;
|
void (*target_init)(max5864_driver_t* const drv);
|
||||||
|
};
|
||||||
|
|
||||||
void max5864_setup(max5864_driver_t* const drv);
|
void max5864_setup(max5864_driver_t* const drv);
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <rffc5071.h>
|
#include <rffc5071.h>
|
||||||
#include <max2837.h>
|
#include <max2837.h>
|
||||||
#include <sgpio.h>
|
#include <sgpio.h>
|
||||||
#include "max2837_target.h"
|
|
||||||
|
|
||||||
#define FREQ_ONE_MHZ (1000*1000)
|
#define FREQ_ONE_MHZ (1000*1000)
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "w25q80bv.h"
|
#include "w25q80bv.h"
|
||||||
#include "w25q80bv_target.h"
|
|
||||||
|
|
||||||
#include "hackrf_core.h"
|
#include "hackrf_core.h"
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ void w25q80bv_setup(w25q80bv_driver_t* const drv)
|
|||||||
drv->num_bytes = 1048576U;
|
drv->num_bytes = 1048576U;
|
||||||
|
|
||||||
spi_init(drv->spi, &ssp_config_w25q80bv);
|
spi_init(drv->spi, &ssp_config_w25q80bv);
|
||||||
w25q80bv_target_init(drv);
|
drv->target_init(drv);
|
||||||
|
|
||||||
device_id = 0;
|
device_id = 0;
|
||||||
while(device_id != W25Q80BV_DEVICE_ID_RES)
|
while(device_id != W25Q80BV_DEVICE_ID_RES)
|
||||||
|
@ -36,12 +36,16 @@ typedef union
|
|||||||
uint8_t id_8b[8]; /* 8*8bits 64bits Unique ID */
|
uint8_t id_8b[8]; /* 8*8bits 64bits Unique ID */
|
||||||
} w25q80bv_unique_id_t;
|
} w25q80bv_unique_id_t;
|
||||||
|
|
||||||
typedef struct {
|
struct w25q80bv_driver_t;
|
||||||
|
typedef struct w25q80bv_driver_t w25q80bv_driver_t;
|
||||||
|
|
||||||
|
struct w25q80bv_driver_t {
|
||||||
spi_t* spi;
|
spi_t* spi;
|
||||||
|
void (*target_init)(w25q80bv_driver_t* const drv);
|
||||||
size_t page_len;
|
size_t page_len;
|
||||||
size_t num_pages;
|
size_t num_pages;
|
||||||
size_t num_bytes;
|
size_t num_bytes;
|
||||||
} w25q80bv_driver_t;
|
};
|
||||||
|
|
||||||
void w25q80bv_setup(w25q80bv_driver_t* const drv);
|
void w25q80bv_setup(w25q80bv_driver_t* const drv);
|
||||||
void w25q80bv_chip_erase(w25q80bv_driver_t* const drv);
|
void w25q80bv_chip_erase(w25q80bv_driver_t* const drv);
|
||||||
|
Reference in New Issue
Block a user