*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
-static uint8_t ao_m25_size[M25_MAX_CHIPS]; /* number of sectors in each chip */
-static uint8_t ao_m25_pin[M25_MAX_CHIPS]; /* chip select pin for each chip */
+static uint32_t ao_m25_size[M25_MAX_CHIPS]; /* number of sectors in each chip */
+static ao_port_t ao_m25_pin[M25_MAX_CHIPS]; /* chip select pin for each chip */
-static uint8_t ao_m25_total; /* total sectors available */
-static uint8_t ao_m25_wip; /* write in progress */
+static uint32_t ao_m25_total; /* total sectors available */
+static ao_port_t ao_m25_wip; /* write in progress */
-static void ao_boot_radio(void) {
- if (ao_radio_in_recv)
- ao_radio_recv_abort();
-}
-#else
-#define ao_boot_radio()
-#endif
-
-#define M25_SELECT(cs) do { ao_boot_radio(); ao_spi_get_mask(AO_M25_SPI_CS_PORT,cs,AO_M25_SPI_BUS); } while (0)
+#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
#define M25_BLOCK 65536L
#define M25_DESELECT(cs) ao_spi_put_mask(AO_M25_SPI_CS_PORT,cs,AO_M25_SPI_BUS)
#define M25_BLOCK_SHIFT 16
#define M25_BLOCK 65536L
#define M25_SECTOR_TO_POS(sector) (((uint32_t) (sector)) << M25_BLOCK_SHIFT)
/*
* Block until the specified chip is done writing
*/
static void
#define M25_SECTOR_TO_POS(sector) (((uint32_t) (sector)) << M25_BLOCK_SHIFT)
/*
* Block until the specified chip is done writing
*/
static void
ao_m25_instruction[1] = pos >> 16;
ao_m25_instruction[2] = pos >> 8;
ao_m25_instruction[3] = pos;
ao_m25_instruction[1] = pos >> 16;
ao_m25_instruction[2] = pos >> 8;
ao_m25_instruction[3] = pos;
for (chip = 0; chip < ao_m25_numchips; chip++)
printf ("Flash chip %d select %02x size %d\n",
chip, ao_m25_pin[chip], ao_m25_size[chip]);
#else
for (chip = 0; chip < ao_m25_numchips; chip++)
printf ("Flash chip %d select %02x size %d\n",
chip, ao_m25_pin[chip], ao_m25_size[chip]);
#else
printf ("Available chips:\n");
for (cs = 1; cs != 0; cs <<= 1) {
if ((AO_M25_SPI_CS_MASK & cs) == 0)
printf ("Available chips:\n");
for (cs = 1; cs != 0; cs <<= 1) {
if ((AO_M25_SPI_CS_MASK & cs) == 0)