Browse Source

Исправлена инициализация ног SPI, включен

вывод отладки в SDIO.
pull/3/head
Sergey 5 years ago
parent
commit
83a726679b
  1. 3
      Marlin/Configuration.h
  2. 2
      Marlin/src/HAL/STM32F1/HAL.h
  3. 21
      Marlin/src/HAL/STM32F1/eeprom_spi_w25q.cpp
  4. 33
      Marlin/src/HAL/STM32F1/sdio.cpp
  5. 2
      Marlin/src/gcode/gcode.cpp

3
Marlin/Configuration.h

@ -763,7 +763,6 @@
* Override with M201
* X, Y, Z, E0 [, E1[, E2...]]
*/
// @efim-a-efim - decreased E0 acceleration to make it less noisy (yes, even with TMC2208 drivers)
#define DEFAULT_MAX_ACCELERATION { 1000, 1000, 100, 800 }
#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2
@ -1155,7 +1154,7 @@
* For other boards you may need to define FIL_RUNOUT_PIN, FIL_RUNOUT2_PIN, etc.
* By default the firmware assumes HIGH=FILAMENT PRESENT.
*/
#define FILAMENT_RUNOUT_SENSOR
//#define FILAMENT_RUNOUT_SENSOR
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
#define FIL_RUNOUT_INVERTING true // Set to true to invert the logic of the sensor.

2
Marlin/src/HAL/STM32F1/HAL.h

@ -267,8 +267,6 @@ void eeprom_read_block(void *__dst, const void *__src, size_t __n);
void eeprom_update_block(const void *__src, void *__dst, size_t __n);
//
// ADC
//

21
Marlin/src/HAL/STM32F1/eeprom_spi_w25q.cpp

@ -63,24 +63,28 @@ CS - PB12 Out push-pull
dwt_init();
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN|RCC_APB2ENR_AFIOEN;
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN|RCC_APB2ENR_IOPAEN|RCC_APB2ENR_AFIOEN;
tmp = PORTB->CRH;
tmp |= (GPIO_CRH_MODE13|GPIO_CRH_MODE15|GPIO_CRH_CNF13|GPIO_CRH_CNF15);
tmp &= ~(GPIO_CRH_MODE14|GPIO_CRH_CNF14);
tmp |= GPIO_CRH_CNF14_0;
tmp &= ~GPIO_CRH_CNF12;
tmp |= GPIO_CRH_MODE12;
tmp &= ~(GPIO_CRH_MODE14|GPIO_CRH_CNF14|GPIO_CRH_CNF12|GPIO_CRH_CNF13|GPIO_CRH_CNF14|GPIO_CRH_CNF15);
tmp |= (GPIO_CRH_MODE12|GPIO_CRH_MODE13|GPIO_CRH_MODE15|GPIO_CRH_CNF13_1|GPIO_CRH_CNF15_1|GPIO_CRH_CNF14_0);
PORTB->CRH = tmp;
//CS PIN
tmp= PORTA->CRL;
tmp &= ~GPIO_CRL_CNF7;
tmp |= GPIO_CRL_MODE7;
PORTA->CRL = tmp;
PORTA->BSRR = GPIO_BSRR_BS7;
SPI2_STOP;
RCC->APB1ENR|= RCC_APB1ENR_SPI2EN;
SPI2->CR1 = SPI_CR1_SSM|\
SPI_CR1_SSI|\
(6 << SPI_CR1_BR_Pos)|\
SPI_CR1_CPHA|\
(4 << SPI_CR1_BR_Pos)|\
SPI_CR1_MSTR;
SPI2->CR1 |= SPI_CR1_SPE;
@ -171,7 +175,6 @@ void eeprom_update_block(const void *__src, void *__dst, size_t __n){
uint8_t spi_send(uint8_t data){
while((SPI2->SR & SPI_SR_TXE) == 0){NOP;};
SPI2->DR = data;

33
Marlin/src/HAL/STM32F1/sdio.cpp

@ -26,6 +26,7 @@
#include <libmaple/stm32.h>
#include "../../inc/MarlinConfig.h" // Allow pins/pins.h to set density
#include "../../module/mks_wifi/debug_to_uart.h"
#if defined(STM32_HIGH_DENSITY) || defined(STM32_XL_DENSITY)
@ -82,10 +83,12 @@ bool SDIO_Init() {
return true;
}
bool SDIO_ReadBlock_DMA(uint32_t blockAddress, uint8_t *data) {
if (SDIO_GetCardState() != SDIO_CARD_TRANSFER) return false;
if (blockAddress >= SdCard.LogBlockNbr) return false;
if ((0x03 & (uint32_t)data)) return false; // misaligned data
uint32_t SDIO_ReadBlock_DMA(uint32_t blockAddress, uint8_t *data) {
uint32_t ret_val;
if (SDIO_GetCardState() != SDIO_CARD_TRANSFER) return 0xF0000000;
if (blockAddress >= SdCard.LogBlockNbr) return 0xF1000000;
if ((0x03 & (uint32_t)data)) return 0xF2000000; // misaligned data
if (SdCard.CardType != CARD_SDHC_SDXC) { blockAddress *= 512U; }
@ -99,30 +102,42 @@ bool SDIO_ReadBlock_DMA(uint32_t blockAddress, uint8_t *data) {
if (!SDIO_CmdReadSingleBlock(blockAddress)) {
SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS);
dma_disable(SDIO_DMA_DEV, SDIO_DMA_CHANNEL);
return false;
return 0xF3000000;
}
while (!SDIO_GET_FLAG(SDIO_STA_DATAEND | SDIO_STA_TRX_ERROR_FLAGS)) {}
ret_val = SDIO->STA;
dma_disable(SDIO_DMA_DEV, SDIO_DMA_CHANNEL);
if (SDIO->STA & SDIO_STA_RXDAVL) {
DEBUG("SDIO_STA_RXDAVL");
while (SDIO->STA & SDIO_STA_RXDAVL) (void)SDIO->FIFO;
SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS);
return false;
return ret_val;
}
if (SDIO_GET_FLAG(SDIO_STA_TRX_ERROR_FLAGS)) {
DEBUG("SDIO_STA_TRX_ERROR_FLAGS");
SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS);
return false;
return ret_val;
}
SDIO_CLEAR_FLAG(SDIO_ICR_CMD_FLAGS | SDIO_ICR_DATA_FLAGS);
return true;
return 0;
}
bool SDIO_ReadBlock(uint32_t blockAddress, uint8_t *data) {
uint32_t retries = 10;
while (retries--) if (SDIO_ReadBlock_DMA(blockAddress, data)) return true;
uint32_t status;
while (retries--){
status = SDIO_ReadBlock_DMA(blockAddress, data);
if (status == 0){
return true;
}else{
DEBUG("SD error, R: %d STA=0x%0X",retries,status);
}
}
return false;
}

2
Marlin/src/gcode/gcode.cpp

@ -230,7 +230,7 @@ void GcodeSuite::dwell(millis_t time) {
void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
KEEPALIVE_STATE(IN_HANDLER);
DEBUG("Cmd %c %d",parser.command_letter,parser.codenum);
//DEBUG("Cmd %c %d",parser.command_letter,parser.codenum);
// Handle a known G, M, or T
switch (parser.command_letter) {

Loading…
Cancel
Save