2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
25 #include "drivers/io.h"
28 #include "pg/pg_ids.h"
30 #include "bus_quadspi.h"
32 typedef struct quadSpiDefaultConfig_s
{
36 // Note: Either or both CS pin may be used in DUAL_FLASH mode, any unused pins should be IO_NONE
51 // CS pins can be under software control, useful when using BK1CS as the CS pin for BK2 in non-DUAL-FLASH mode.
53 } quadSpiDefaultConfig_t
;
55 const quadSpiDefaultConfig_t quadSpiDefaultConfig
[] = {
56 #ifdef USE_QUADSPI_DEVICE_1
59 IO_TAG(QUADSPI1_SCK_PIN
),
60 IO_TAG(QUADSPI1_BK1_IO0_PIN
), IO_TAG(QUADSPI1_BK1_IO1_PIN
), IO_TAG(QUADSPI1_BK1_IO2_PIN
), IO_TAG(QUADSPI1_BK1_IO3_PIN
), IO_TAG(QUADSPI1_BK1_CS_PIN
),
61 IO_TAG(QUADSPI1_BK2_IO0_PIN
), IO_TAG(QUADSPI1_BK2_IO1_PIN
), IO_TAG(QUADSPI1_BK2_IO2_PIN
), IO_TAG(QUADSPI1_BK2_IO3_PIN
), IO_TAG(QUADSPI1_BK2_CS_PIN
),
68 PG_REGISTER_ARRAY_WITH_RESET_FN(quadSpiConfig_t
, QUADSPIDEV_COUNT
, quadSpiConfig
, PG_QUADSPI_CONFIG
, 1);
70 void pgResetFn_quadSpiConfig(quadSpiConfig_t
*quadSpiConfig
)
72 for (size_t i
= 0 ; i
< ARRAYLEN(quadSpiDefaultConfig
) ; i
++) {
73 const quadSpiDefaultConfig_t
*defconf
= &quadSpiDefaultConfig
[i
];
74 quadSpiConfig
[defconf
->device
].ioTagClk
= defconf
->clk
;
76 quadSpiConfig
[defconf
->device
].ioTagBK1IO0
= defconf
->bk1IO0
;
77 quadSpiConfig
[defconf
->device
].ioTagBK1IO1
= defconf
->bk1IO1
;
78 quadSpiConfig
[defconf
->device
].ioTagBK1IO2
= defconf
->bk1IO2
;
79 quadSpiConfig
[defconf
->device
].ioTagBK1IO3
= defconf
->bk1IO3
;
80 quadSpiConfig
[defconf
->device
].ioTagBK1CS
= defconf
->bk1CS
;
82 quadSpiConfig
[defconf
->device
].ioTagBK2IO0
= defconf
->bk2IO0
;
83 quadSpiConfig
[defconf
->device
].ioTagBK2IO1
= defconf
->bk2IO1
;
84 quadSpiConfig
[defconf
->device
].ioTagBK2IO2
= defconf
->bk2IO2
;
85 quadSpiConfig
[defconf
->device
].ioTagBK2IO3
= defconf
->bk2IO3
;
86 quadSpiConfig
[defconf
->device
].ioTagBK2CS
= defconf
->bk2CS
;
88 quadSpiConfig
[defconf
->device
].mode
= defconf
->mode
;
89 quadSpiConfig
[defconf
->device
].csFlags
= defconf
->csFlags
;