X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fdrivers%2Fao_m25.c;h=72617cc4504f24f18966e1a80f1be4699d2a1fc9;hb=refs%2Fheads%2Fmaster;hp=550c9535f2735837d566d09ff131f6bbe73bedb6;hpb=202166275ba5220db54f63dcd9366e9115d09c0d;p=fw%2Faltos diff --git a/src/drivers/ao_m25.c b/src/drivers/ao_m25.c index 550c9535..4be91e13 100644 --- a/src/drivers/ao_m25.c +++ b/src/drivers/ao_m25.c @@ -101,7 +101,9 @@ static uint8_t ao_m25_mutex; static uint8_t ao_m25_instruction[4]; -#define M25_SELECT(cs) ao_spi_get_mask(AO_M25_SPI_CS_PORT,cs,AO_M25_SPI_BUS, AO_SPI_SPEED_FAST) +#define AO_M25_SPI_SPEED ao_spi_speed(AO_M25_SPI_BUS, 10000000) /* this seems like a reasonable minimum speed to require */ + +#define M25_SELECT(cs) ao_spi_get_mask(AO_M25_SPI_CS_PORT,cs,AO_M25_SPI_BUS,AO_M25_SPI_SPEED) #define M25_DESELECT(cs) ao_spi_put_mask(AO_M25_SPI_CS_PORT,cs,AO_M25_SPI_BUS) #define M25_BLOCK_SHIFT 16 @@ -123,7 +125,7 @@ ao_m25_wait_wip(ao_port_t cs) ao_spi_recv(ao_m25_instruction, 1, AO_M25_SPI_BUS); } while (ao_m25_instruction[0] & M25_STATUS_WIP); M25_DESELECT(cs); - ao_m25_wip &= ~cs; + ao_m25_wip &= (ao_port_t) ~cs; } } @@ -190,9 +192,9 @@ ao_m25_set_address(uint32_t pos) #endif ao_m25_wait_wip(mask); - ao_m25_instruction[1] = pos >> 16; - ao_m25_instruction[2] = pos >> 8; - ao_m25_instruction[3] = pos; + ao_m25_instruction[1] = (uint8_t) (pos >> 16); + ao_m25_instruction[2] = (uint8_t) (pos >> 8); + ao_m25_instruction[3] = (uint8_t) (pos); return mask; }