int sdio_read (uint32_t *buf, uint32_t block_num, uint32_t num_block) {
int sd = open(FILE_MICROSD_PATH, O_RDONLY);
if (sd == -1) {
return -1;
};
int rv = lseek(sd, block_num*SD_BLOCK_SIZE, SEEK_SET);
if (rv != block_num*SD_BLOCK_SIZE) {
close(sd);
return -1;
}
ssize_t read_byte_num = 0;
while (read_byte_num != SD_BLOCK_SIZE*num_block) {
ssize_t real_read_byte_num = read(sd, &buf[read_byte_num], SD_BLOCK_SIZE*num_block - read_byte_num);
if (real_read_byte_num == -1) {
close(sd);
return -1;
}
read_byte_num += real_read_byte_num;
}
rv = close(sd);
return rv;
}
int sdio_write (const uint32_t *buf, uint32_t block_num, uint32_t num_block) {
int sd = open(FILE_MICROSD_PATH, O_WRONLY);
if (sd == -1) {
return -1;
};
int rv = lseek(sd, block_num*SD_BLOCK_SIZE, SEEK_SET);
if (rv != block_num*SD_BLOCK_SIZE) {
close(sd);
return -1;
}
ssize_t write_byte_num = 0;
while (write_byte_num != SD_BLOCK_SIZE*num_block) {
ssize_t real_write_byte_num = write(sd, &buf[write_byte_num], SD_BLOCK_SIZE*num_block - write_byte_num);
if (real_write_byte_num == -1) {
close(sd);
return -1;
}
write_byte_num += real_write_byte_num;
}
rv = close(sd);
return rv;
}
1) Мне не нравится static FILE *sd Я бы сделал локальные переменные внутри обеих функций. При многопоточном программировании со статическими переменными - можно поиметь проблему.
До кучи можно указать, что они регистровые.
2) При отладке можно ставить задержку хоть в десять секунд. Тут надо найти источник проблемы, эффективность работы программы на этапе поиска ошибки совершенно не важна.
3) "После возвращения NULL из fopen в errno -переменной пусто." - противоречит мануалу. Я понимаю, что реальность сильнее мануала - но такого быть не должно. Напишите актуальный на данный код вместо старого в головном посте.
4) Кстати, errno - статическая. Т.е. при многопоточном программировании - её может затереть другой поток.
5) По правилам хорошего тона - в зависимости от того, где произошла ошибка, надо возвращать разные значения. Не "-1", как Вы сделали, а разные.
6) Попробуйте отказаться от оптимизации при компиляции. См.пункт 2.
7) Проверьте код завершения fclose().
8) Можно попробовать работать без буферизации. Ваш стиль работы с файлом - как бы намекает, что надо использовать open(), close(), read() и write() - без "f" в начале. Заодно избавитесь от от лишних расходов на буферизацию в user-space, которые здесь бесполезны.
typedef typename std::conditional< FRAME == EC_SPI_CFG_DATA_FRAME::FRAME_8_BIT, uint8_t, uint16_t >::type spi_frame_size;
mutable spi_frame_size* p_tx = nullptr;
#pragma once
#include "stm32_f20x_f21x_port.h"
/*
* Структура инициализации всех выводов порта.
*/
/*
* ADC.
*/
M_OBJ_PIN_CFG_ADC(adc_bat, EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_0); // ADC_BAT.
M_OBJ_PIN_CFG_ADC(adc_right, EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_4); // ADC_RIGHT.
M_OBJ_PIN_CFG_ADC(adc_left, EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_1); // ADC_LEFT.
/*
* EXTI кнопки.
*/
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_1, EC_PIN_MODE::INPUT, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::LOW, EC_PIN_PULL::UP, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> b_v_up;
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_2, EC_PIN_MODE::INPUT, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::LOW, EC_PIN_PULL::UP, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> b_v_down;
/*
* MIDI (USART2).
*/
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_3, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::USART2, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> midi_uart_rx;
/*
* LCD (SPI1 + TIMx).
*/
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_5, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::SPI1, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> lcd_clk;
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_6, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::SPI1, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> lcd_miso;
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_7, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::SPI1, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> lcd_mosi;
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_4, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::SET> lcd_res;
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_5, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::RESET> lcd_dc;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_2, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::RESET> lcd__cs;
/*
* micro-sd (SDIO + GPIO).
*/
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_8, EC_PIN_MODE::INPUT, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::LOW, EC_PIN_PULL::UP, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> sd1_push;
const pin_config_check_param<EC_PORT_NAME::D, EC_PORT_PIN_NAME::PIN_2, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::FAST, EC_PIN_PULL::NO_USE, EC_PIN_AF::SDIO, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> sd1_smd;
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_8, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::FAST, EC_PIN_PULL::NO_USE, EC_PIN_AF::SDIO, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> sd1_d0;
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_9, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::FAST, EC_PIN_PULL::NO_USE, EC_PIN_AF::SDIO, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> sd1_d1;
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_10, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::FAST, EC_PIN_PULL::NO_USE, EC_PIN_AF::SDIO, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> sd1_d2;
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_11, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::FAST, EC_PIN_PULL::NO_USE, EC_PIN_AF::SDIO, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> sd1_d3;
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_12, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::FAST, EC_PIN_PULL::NO_USE, EC_PIN_AF::SDIO, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> sd1_clk;
/*
* USB (USB_FS + GPIO).
*/
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_9, EC_PIN_MODE::INPUT, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::LOW, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> otg_fs_vbus;
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_11, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::HIGH, EC_PIN_PULL::NO_USE, EC_PIN_AF::OTG_FS, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> usb_dm;
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_12, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::HIGH, EC_PIN_PULL::NO_USE, EC_PIN_AF::OTG_FS, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> usb_dp;
/*
* AY (GPIO + TIM1 + SPI3)
*/
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_10, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::RESET> bdir;
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_15, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::LOW, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::RESET> ay_1_res;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_15, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::LOW, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::RESET> ay_2_res;
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_6, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::RESET> bc1;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_0, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::FAST, EC_PIN_PULL::NO_USE, EC_PIN_AF::TIM1, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> ay_clk;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_3, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::SPI3, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> spi_audio_clk;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_5, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::SPI3, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> spi_audio_tx;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_6, EC_PIN_MODE::INPUT, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::LOW, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> shdn;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_8, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::RESET> spi_audio_st_reg;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_14, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::RESET> cs_res;
/*
* SPI клавиатура (SPI общий AY, тут только вход).
*/
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_7, EC_PIN_MODE::INPUT, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::LOW, EC_PIN_PULL::UP, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> button_in;
/*
* SWD.
*/
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_13, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::LOW, EC_PIN_PULL::UP, EC_PIN_AF::SYS, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> swd_io;
const pin_config_check_param<EC_PORT_NAME::A, EC_PORT_PIN_NAME::PIN_14, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::LOW, EC_PIN_PULL::DOWN, EC_PIN_AF::SYS, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> swd_clk;
/*
* PWR.
*/
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_0, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::LOW, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::RESET> on_5v;
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_1, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::LOW, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::SET> power_on;
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_14, EC_PIN_MODE::INPUT, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::LOW, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> tp_st;
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_15, EC_PIN_MODE::INPUT, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::LOW, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> tp_ch;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_4, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::RESET> ay1_on;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_12, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::RESET> ay2_on;
/*
* MICRO-SD SPI2 (SPI2 + GPIO).
*/
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_2, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::SPI2, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> sd2_rx;
const pin_config_check_param<EC_PORT_NAME::C, EC_PORT_PIN_NAME::PIN_3, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::SPI2, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> sd2_tx;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_13, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::SPI2, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> sd2__clk;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_7, EC_PIN_MODE::OUTPUT, EC_PIN_OUTPUT_CFG::PUSH_PULL, EC_PIN_SPEED::MEDIUM, EC_PIN_PULL::NO_USE, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::RESET> sd2_cs;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_9, EC_PIN_MODE::INPUT, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::LOW, EC_PIN_PULL::UP, EC_PIN_AF::NO_USE, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> sd2_push;
/*
* BOOT-USART (USART3)
*/
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_10, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::MEDIUM,EC_PIN_PULL::NO_USE, EC_PIN_AF::USART3, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> boot_tx;
const pin_config_check_param<EC_PORT_NAME::B, EC_PORT_PIN_NAME::PIN_11, EC_PIN_MODE::AF, EC_PIN_OUTPUT_CFG::NO_USE, EC_PIN_SPEED::MEDIUM,EC_PIN_PULL::NO_USE, EC_PIN_AF::USART3, EC_LOCKED::LOCKED, EC_PIN_STATE_AFTER_INIT::NO_USE> boot_rx;
int ayplayer_port_init ( void );
#include "ayplayer_port.h"
const constexpr pin_config_t ayplayer_global_port_pin_cfg_1[] = {
adc_bat, adc_right, adc_left, // ADC.
midi_uart_rx, // MIDI (USART2).
lcd_clk, lcd_miso, lcd_mosi, lcd_res, lcd_dc, lcd__cs, // LCD (SPI1 + TIMx).
sd1_push, sd1_smd, sd1_d0, sd1_d1, sd1_d2, sd1_d3, sd1_clk, // micro-sd (SDIO + GPIO).
otg_fs_vbus, usb_dm, usb_dp, // USB (USB_FS + GPIO).
bdir, ay_1_res, ay_2_res, bc1, ay_clk, spi_audio_clk, spi_audio_tx, shdn, spi_audio_st_reg, cs_res, // AY (GPIO + TIM1 + SPI3)
button_in, // SPI клавиатура (SPI общий AY, тут только вход).
swd_io, swd_clk, // SWD.
on_5v, power_on, tp_st, tp_ch, ay1_on, ay2_on, // PWR.
sd2_rx, sd2_tx, sd2__clk, sd2_cs, sd2_push, // MICRO-SD SPI2 (SPI2 + GPIO).
boot_tx, boot_rx // BOOT-USART (USART3).
};
const constexpr global_port ayplayer_global_port( ayplayer_global_port_pin_cfg_1, M_SIZE_ARRAY(ayplayer_global_port_pin_cfg_1) );
int ayplayer_port_init ( void ) {
return ( ayplayer_global_port.reinit_all_ports() == E_ANSWER_GP::SUCCESS )?0:-1;
}