SPI: Pull remaining hardware bits out of MAX2837/5864/W25Q80BV device drivers.

This commit is contained in:
Jared Boone
2014-11-10 14:48:42 -08:00
parent 8ced9415c2
commit 569f320826
7 changed files with 6 additions and 11 deletions

View File

@ -649,6 +649,9 @@ void pin_setup(void) {
/* GPIO3[6] on P6_10 as output. */ /* GPIO3[6] on P6_10 as output. */
GPIO3_DIR |= PIN_EN1V8; GPIO3_DIR |= PIN_EN1V8;
spi_init(&spi_ssp1, &ssp_config_max2837);
spi_init(&rffc5071_spi, NULL);
rf_path_pin_setup(); rf_path_pin_setup();
/* Configure external clock in */ /* Configure external clock in */

View File

@ -33,8 +33,6 @@
#include "max2837.h" #include "max2837.h"
#include "max2837_regs.def" // private register def macros #include "max2837_regs.def" // private register def macros
#include "hackrf_core.h"
/* Default register values. */ /* Default register values. */
static const uint16_t max2837_regs_default[MAX2837_NUM_REGS] = { static const uint16_t max2837_regs_default[MAX2837_NUM_REGS] = {
0x150, /* 0 */ 0x150, /* 0 */
@ -78,7 +76,6 @@ static const uint16_t max2837_regs_default[MAX2837_NUM_REGS] = {
/* Set up all registers according to defaults specified in docs. */ /* Set up all registers according to defaults specified in docs. */
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);
drv->target_init(drv); drv->target_init(drv);
max2837_set_mode(drv, MAX2837_MODE_SHUTDOWN); max2837_set_mode(drv, MAX2837_MODE_SHUTDOWN);

View File

@ -23,14 +23,11 @@
#include "max5864.h" #include "max5864.h"
#include "hackrf_core.h"
static void max5864_write(max5864_driver_t* const drv, uint8_t value) { static void max5864_write(max5864_driver_t* const drv, uint8_t value) {
spi_transfer(drv->spi, &value, 1); spi_transfer(drv->spi, &value, 1);
} }
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);
drv->target_init(drv); drv->target_init(drv);
} }

View File

@ -90,8 +90,6 @@ void rffc5071_setup(rffc5071_driver_t* const drv)
{ {
rffc5071_init(drv); rffc5071_init(drv);
spi_init(drv->spi, NULL);
/* initial setup */ /* initial setup */
/* put zeros in freq contol registers */ /* put zeros in freq contol registers */
set_RFFC5071_P2N(drv, 0); set_RFFC5071_P2N(drv, 0);

View File

@ -77,6 +77,7 @@ isp_iap_ret_code_t iap_cmd_call(iap_cmd_res_t* iap_cmd_res)
Alternative way to retrieve Part Id on MCU with no IAP Alternative way to retrieve Part Id on MCU with no IAP
Read Serial No => Read Unique ID in SPIFI (only compatible with W25Q80BV Read Serial No => Read Unique ID in SPIFI (only compatible with W25Q80BV
*/ */
spi_init(spi_flash.spi, &ssp_config_w25q80bv);
w25q80bv_setup(&spi_flash); w25q80bv_setup(&spi_flash);
switch(iap_cmd_res->cmd_param.command_code) switch(iap_cmd_res->cmd_param.command_code)

View File

@ -32,8 +32,6 @@
#include "w25q80bv.h" #include "w25q80bv.h"
#include "hackrf_core.h"
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define W25Q80BV_WRITE_ENABLE 0x06 #define W25Q80BV_WRITE_ENABLE 0x06
@ -59,7 +57,6 @@ void w25q80bv_setup(w25q80bv_driver_t* const drv)
drv->num_pages = 4096U; drv->num_pages = 4096U;
drv->num_bytes = 1048576U; drv->num_bytes = 1048576U;
spi_init(drv->spi, &ssp_config_w25q80bv);
drv->target_init(drv); drv->target_init(drv);
device_id = 0; device_id = 0;

View File

@ -39,6 +39,7 @@ usb_request_status_t usb_vendor_request_erase_spiflash(
//FIXME This should refuse to run if executing from SPI flash. //FIXME This should refuse to run if executing from SPI flash.
if (stage == USB_TRANSFER_STAGE_SETUP) { if (stage == USB_TRANSFER_STAGE_SETUP) {
spi_init(spi_flash.spi, &ssp_config_w25q80bv);
w25q80bv_setup(&spi_flash); w25q80bv_setup(&spi_flash);
/* only chip erase is implemented */ /* only chip erase is implemented */
w25q80bv_chip_erase(&spi_flash); w25q80bv_chip_erase(&spi_flash);
@ -65,6 +66,7 @@ usb_request_status_t usb_vendor_request_write_spiflash(
} else { } else {
usb_transfer_schedule_block(endpoint->out, &spiflash_buffer[0], len, usb_transfer_schedule_block(endpoint->out, &spiflash_buffer[0], len,
NULL, NULL); NULL, NULL);
spi_init(spi_flash.spi, &ssp_config_w25q80bv);
w25q80bv_setup(&spi_flash); w25q80bv_setup(&spi_flash);
return USB_REQUEST_STATUS_OK; return USB_REQUEST_STATUS_OK;
} }