Browse Source

Synced with Marlin

Implemented the LCD fix and support for the FLSUN HiSpeed board.
FLSUN-QQS
Martin Carlsson 7 months ago
parent
commit
2a4a40eebe
13 changed files with 783 additions and 173 deletions
  1. +43
    -0
      .github/ISSUE_TEMPLATE/bug_report.md
  2. +17
    -0
      .github/ISSUE_TEMPLATE/config.yml
  3. +35
    -0
      .github/ISSUE_TEMPLATE/feature_request.md
  4. +35
    -0
      .github/workflows/bump-date.yml
  5. +33
    -0
      .github/workflows/check-pr.yml
  6. +27
    -0
      .github/workflows/close-stale.yml
  7. +32
    -0
      .github/workflows/lock-closed.yml
  8. +22
    -0
      .github/workflows/unlock-reopened.yml
  9. +221
    -172
      Marlin/src/HAL/LPC1768/HAL_SPI.cpp
  10. +1
    -0
      Marlin/src/core/boards.h
  11. +2
    -1
      Marlin/src/pins/pins.h
  12. +306
    -0
      Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h
  13. +9
    -0
      platformio.ini

+ 43
- 0
.github/ISSUE_TEMPLATE/bug_report.md View File

@ -0,0 +1,43 @@
---
name: Bug report
about: Report a bug in Marlin
title: "[BUG] (short description)"
labels: ''
assignees: ''
---
<!--
Have you read Marlin's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/MarlinFirmware/Marlin/blob/master/.github/code_of_conduct.md
Do you want to ask a question? Are you looking for support? Please don't post here. Instead please use one of the support links at https://github.com/MarlinFirmware/Marlin/issues/new/choose
Before filing an issue be sure to test the "bugfix" branches to see whether the issue has been resolved.
-->
### Bug Description
<!-- Description of the bug -->
### My Configurations
**Required:** Please include a ZIP file containing your `Configuration.h` and `Configuration_adv.h` files.
### Steps to Reproduce
<!-- Please describe the steps needed to reproduce the issue -->
1. [First Step]
2. [Second Step]
3. [and so on...]
**Expected behavior:** [What you expect to happen]
**Actual behavior:** [What actually happens]
#### Additional Information
* Provide pictures or links to videos that clearly demonstrate the issue.
* See [How Can I Contribute](#how-can-i-contribute) for additional guidelines.

+ 17
- 0
.github/ISSUE_TEMPLATE/config.yml View File

@ -0,0 +1,17 @@
blank_issues_enabled: false
contact_links:
- name: Marlin Documentation
url: http://marlinfw.org/
about: Lots of documentation on installing and using Marlin.
- name: MarlinFirmware Facebook group
url: https://www.facebook.com/groups/1049718498464482
about: Please ask and answer questions here.
- name: Marlin on Discord
url: https://discord.gg/n5NJ59y
about: Join the Discord server for support and discussion.
- name: Marlin Discussion Forum
url: http://forums.reprap.org/list.php?415
about: A searchable web forum hosted by RepRap dot org.
- name: Marlin Videos on YouTube
url: https://www.youtube.com/results?search_query=marlin+firmware
about: Tutorials and more from Marlin users all around the world. Great for new users!

+ 35
- 0
.github/ISSUE_TEMPLATE/feature_request.md View File

@ -0,0 +1,35 @@
---
name: Feature request
about: Request a Feature
title: "[FR] (feature request title)"
labels: 'T: Feature Request'
assignees: ''
---
<!--
Have you read Marlin's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/MarlinFirmware/Marlin/blob/master/.github/code_of_conduct.md
Do you want to ask a question? Are you looking for support? Please don't post here. Instead please use one of the support links at https://github.com/MarlinFirmware/Marlin/issues/new/choose
Before filing an issue be sure to test the "bugfix" branches to see whether the issue has been resolved.
-->
### Description
<!-- Description of the requested feature -->
### Feature Workflow
<!-- Please describe the feature's behavior, user interaction, etc. -->
1. [First Action]
2. [Second Action]
3. [and so on...]
#### Additional Information
* Provide pictures or links that demonstrate a similar feature or concept.
* See [How Can I Contribute](#how-can-i-contribute) for additional guidelines.

+ 35
- 0
.github/workflows/bump-date.yml View File

@ -0,0 +1,35 @@
#
# bump-date.yml
# Bump the distribution date once per day
#
name: Bump Distribution Date
on:
schedule:
- cron: '0 0 * * *'
jobs:
bump_date:
name: Bump Distribution Date
if: github.repository == 'MarlinFirmware/Marlin'
runs-on: ubuntu-latest
steps:
- name: Check out bugfix-2.0.x
uses: actions/checkout@v2
with:
ref: bugfix-2.0.x
- name: Bump Distribution Date
run: |
# Inline Bump Script
DIST=$( date +"%Y-%m-%d" )
eval "sed -E -i 's/(#define +STRING_DISTRIBUTION_DATE) .*$/\1 \"$DIST\"/g' Marlin/src/inc/Version.h" && \
git config user.name "${GITHUB_ACTOR}" && \
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" && \
git add . && \
git commit -m "[cron] Bump distribution date ($DIST)" && \
git push

+ 33
- 0
.github/workflows/check-pr.yml View File

@ -0,0 +1,33 @@
#
# check-pr.yml
# Close PRs directed at release branches
#
name: PR Bad Target
on:
pull_request:
branches:
- 1.0.x
- 1.1.x
- 2.0.x
jobs:
bad_target:
name: PR Bad Target
if: github.repository == 'MarlinFirmware/Marlin'
runs-on: ubuntu-latest
steps:
- uses: peter-evans/close-pull@v1
with:
delete-branch: false
comment: >
Thanks for your contribution! Unfortunately we can't accept PRs directed at release branches. We make patches to the bugfix branches and only later do we push them out as releases.
Please redo this PR starting with the `bugfix-2.0.x` branch and be careful to target `bugfix-2.0.x` when resubmitting the PR.
It may help to set your fork's default branch to `bugfix-2.0.x`.
See [this page](http://marlinfw.org/docs/development/getting_started_pull_requests.html) for full instructions.

+ 27
- 0
.github/workflows/close-stale.yml View File

@ -0,0 +1,27 @@
#
# close-stale.yml
# Close open issues after a period of inactivity
#
name: Close Stale Issues
on:
schedule:
- cron: "22 1 * * *"
jobs:
stale:
name: Close Stale Issues
if: github.repository == 'MarlinFirmware/Marlin'
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label / comment or this will be closed in 5 days.'
days-before-stale: 30
days-before-close: 5
stale-issue-label: 'stale-closing-soon'
exempt-issue-labels: 'T: Feature Request'

+ 32
- 0
.github/workflows/lock-closed.yml View File

@ -0,0 +1,32 @@
#
# lock-closed.yml
# Lock closed issues after a period of inactivity
#
name: Lock Closed Issues
on:
schedule:
- cron: '0 1/13 * * *'
jobs:
lock:
name: Lock Closed Issues
if: github.repository == 'MarlinFirmware/Marlin'
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
with:
github-token: ${{ github.token }}
process-only: 'issues'
issue-lock-inactive-days: '60'
issue-exclude-created-before: ''
issue-exclude-labels: 'no-locking'
issue-lock-labels: ''
issue-lock-comment: >
This issue has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
issue-lock-reason: ''

+ 22
- 0
.github/workflows/unlock-reopened.yml View File

@ -0,0 +1,22 @@
#
# unlock-reopened.yml
# Unlock an issue whenever it is re-opened
#
name: "Unlock reopened issue"
on:
issues:
types: [reopened]
jobs:
unlock:
name: Unlock Reopened
if: github.repository == 'MarlinFirmware/Marlin'
runs-on: ubuntu-latest
steps:
- uses: OSDKDev/unlock-issues@v1.1
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

+ 221
- 172
Marlin/src/HAL/LPC1768/HAL_SPI.cpp View File

@ -60,184 +60,217 @@
// ------------------------
#if ENABLED(LPC_SOFTWARE_SPI)
#include <SoftwareSPI.h>
#include <SoftwareSPI.h>
// Software SPI
// Software SPI
static uint8_t SPI_speed = 0;
static uint8_t SPI_speed = 0;
static uint8_t spiTransfer(uint8_t b) {
return swSpiTransfer(b, SPI_speed, SCK_PIN, MISO_PIN, MOSI_PIN);
}
static uint8_t spiTransfer(uint8_t b)
{
return swSpiTransfer(b, SPI_speed, SCK_PIN, MISO_PIN, MOSI_PIN);
}
void spiBegin() {
swSpiBegin(SCK_PIN, MISO_PIN, MOSI_PIN);
}
void spiBegin()
{
swSpiBegin(SCK_PIN, MISO_PIN, MOSI_PIN);
}
void spiInit(uint8_t spiRate) {
SPI_speed = swSpiInit(spiRate, SCK_PIN, MOSI_PIN);
}
void spiInit(uint8_t spiRate)
{
SPI_speed = swSpiInit(spiRate, SCK_PIN, MOSI_PIN);
}
uint8_t spiRec() { return spiTransfer(0xFF); }
uint8_t spiRec() { return spiTransfer(0xFF); }
void spiRead(uint8_t*buf, uint16_t nbyte) {
for (int i = 0; i < nbyte; i++)
buf[i] = spiTransfer(0xFF);
}
void spiRead(uint8_t *buf, uint16_t nbyte)
{
for (int i = 0; i < nbyte; i++)
buf[i] = spiTransfer(0xFF);
}
void spiSend(uint8_t b) { (void)spiTransfer(b); }
void spiSend(uint8_t b) { (void)spiTransfer(b); }
void spiSend(const uint8_t* buf, size_t nbyte) {
for (uint16_t i = 0; i < nbyte; i++)
(void)spiTransfer(buf[i]);
}
void spiSend(const uint8_t *buf, size_t nbyte)
{
for (uint16_t i = 0; i < nbyte; i++)
(void)spiTransfer(buf[i]);
}
void spiSendBlock(uint8_t token, const uint8_t* buf) {
(void)spiTransfer(token);
for (uint16_t i = 0; i < 512; i++)
(void)spiTransfer(buf[i]);
}
void spiSendBlock(uint8_t token, const uint8_t *buf)
{
(void)spiTransfer(token);
for (uint16_t i = 0; i < 512; i++)
(void)spiTransfer(buf[i]);
}
#else
void spiBegin() { // setup SCK, MOSI & MISO pins for SSP0
spiInit(SPI_SPEED);
}
void spiBegin()
{ // setup SCK, MOSI & MISO pins for SSP0
spiInit(SPI_SPEED);
}
void spiInit(uint8_t spiRate) {
#if MISO_PIN == BOARD_SPI1_MISO_PIN
SPI.setModule(1);
#elif MISO_PIN == BOARD_SPI2_MISO_PIN
SPI.setModule(2);
#endif
SPI.setDataSize(DATA_SIZE_8BIT);
SPI.setDataMode(SPI_MODE0);
SPI.setClock(SPISettings::spiRate2Clock(spiRate));
SPI.begin();
}
void spiInit(uint8_t spiRate)
{
#if MISO_PIN == BOARD_SPI1_MISO_PIN
SPI.setModule(1);
#elif MISO_PIN == BOARD_SPI2_MISO_PIN
SPI.setModule(2);
#endif
SPI.setDataSize(DATA_SIZE_8BIT);
SPI.setDataMode(SPI_MODE0);
static uint8_t doio(uint8_t b) {
return SPI.transfer(b & 0x00FF) & 0x00FF;
}
SPI.setClock(SPISettings::spiRate2Clock(spiRate));
SPI.begin();
}
void spiSend(uint8_t b) { doio(b); }
static uint8_t doio(uint8_t b)
{
return SPI.transfer(b & 0x00FF) & 0x00FF;
}
void spiSend(const uint8_t* buf, size_t nbyte) {
for (uint16_t i = 0; i < nbyte; i++) doio(buf[i]);
}
void spiSend(uint8_t b) { doio(b); }
void spiSend(uint32_t chan, byte b) {
}
void spiSend(const uint8_t *buf, size_t nbyte)
{
for (uint16_t i = 0; i < nbyte; i++)
doio(buf[i]);
}
void spiSend(uint32_t chan, const uint8_t* buf, size_t nbyte) {
}
void spiSend(uint32_t chan, byte b)
{
}
// Read single byte from SPI
uint8_t spiRec() { return doio(0xFF); }
void spiSend(uint32_t chan, const uint8_t *buf, size_t nbyte)
{
}
uint8_t spiRec(uint32_t chan) { return 0; }
// Read single byte from SPI
uint8_t spiRec() { return doio(0xFF); }
// Read from SPI into buffer
void spiRead(uint8_t *buf, uint16_t nbyte) {
for (uint16_t i = 0; i < nbyte; i++) buf[i] = doio(0xFF);
}
uint8_t spiRec(uint32_t chan) { return 0; }
uint8_t spiTransfer(uint8_t b) {
return doio(b);
}
// Read from SPI into buffer
void spiRead(uint8_t *buf, uint16_t nbyte)
{
for (uint16_t i = 0; i < nbyte; i++)
buf[i] = doio(0xFF);
}
// Write from buffer to SPI
void spiSendBlock(uint8_t token, const uint8_t* buf) {
(void)spiTransfer(token);
for (uint16_t i = 0; i < 512; i++)
(void)spiTransfer(buf[i]);
}
uint8_t spiTransfer(uint8_t b)
{
return doio(b);
}
/** Begin SPI transaction, set clock, bit order, data mode */
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) {
// TODO: to be implemented
// Write from buffer to SPI
void spiSendBlock(uint8_t token, const uint8_t *buf)
{
(void)spiTransfer(token);
for (uint16_t i = 0; i < 512; i++)
(void)spiTransfer(buf[i]);
}
}
/** Begin SPI transaction, set clock, bit order, data mode */
void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode)
{
// TODO: to be implemented
}
#endif // LPC_SOFTWARE_SPI
/**
* @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset.
*/
static inline void waitSpiTxEnd(LPC_SSP_TypeDef *spi_d) {
while (SSP_GetStatus(spi_d, SSP_STAT_TXFIFO_EMPTY) == RESET) { /* nada */ } // wait until TXE=1
while (SSP_GetStatus(spi_d, SSP_STAT_BUSY) == SET) { /* nada */ } // wait until BSY=0
static inline void waitSpiTxEnd(LPC_SSP_TypeDef *spi_d)
{
while (SSP_GetStatus(spi_d, SSP_STAT_TXFIFO_EMPTY) == RESET)
{ /* nada */
} // wait until TXE=1
while (SSP_GetStatus(spi_d, SSP_STAT_BUSY) == SET)
{ /* nada */
} // wait until BSY=0
}
SPIClass::SPIClass(uint8_t device) {
// Hold the pin init state of the SPI, to avoid init more than once,
//even if more instances of SPIClass exist
static bool spiInitialised[BOARD_NR_SPI] = {false};
SPIClass::SPIClass(uint8_t device)
{
// Init things specific to each SPI device
// clock divider setup is a bit of hack, and needs to be improved at a later date.
PINSEL_CFG_Type PinCfg; // data structure to hold init values
#if BOARD_NR_SPI >= 1
_settings[0].spi_d = LPC_SSP0;
_settings[0].dataMode = SPI_MODE0;
_settings[0].dataSize = DATA_SIZE_8BIT;
_settings[0].clock = SPI_CLOCK_MAX;
// _settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock);
PinCfg.Funcnum = 2;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_SCK_PIN);
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_SCK_PIN);
PINSEL_ConfigPin(&PinCfg);
SET_OUTPUT(BOARD_SPI1_SCK_PIN);
#if BOARD_NR_SPI >= 1
_settings[0].spi_d = LPC_SSP0;
_settings[0].dataMode = SPI_MODE0;
_settings[0].dataSize = DATA_SIZE_8BIT;
_settings[0].clock = SPI_CLOCK_MAX;
// _settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock);
#endif
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_MISO_PIN);
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_MISO_PIN);
PINSEL_ConfigPin(&PinCfg);
SET_INPUT(BOARD_SPI1_MISO_PIN);
#if BOARD_NR_SPI >= 2
_settings[1].spi_d = LPC_SSP1;
_settings[1].dataMode = SPI_MODE0;
_settings[1].dataSize = DATA_SIZE_8BIT;
_settings[1].clock = SPI_CLOCK_MAX;
// _settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);
#endif
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI1_MOSI_PIN);
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI1_MOSI_PIN);
PINSEL_ConfigPin(&PinCfg);
SET_OUTPUT(BOARD_SPI1_MOSI_PIN);
#endif
#if BOARD_NR_SPI >= 2
_settings[1].spi_d = LPC_SSP1;
_settings[1].dataMode = SPI_MODE0;
_settings[1].dataSize = DATA_SIZE_8BIT;
_settings[1].clock = SPI_CLOCK_MAX;
// _settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock);
setModule(device);
/* Initialize GPDMA controller */
//TODO: call once in the constructor? or each time?
GPDMA_Init();
}
void SPIClass::begin()
{
// Init the SPI pins in the firt begin call
if ((_currentSetting->spi_d == LPC_SSP0 && spiInitialised[0] == false) ||
(_currentSetting->spi_d == LPC_SSP1 && spiInitialised[1] == false))
{
pin_t sck, miso, mosi;
if (_currentSetting->spi_d == LPC_SSP0)
{
sck = BOARD_SPI1_SCK_PIN;
miso = BOARD_SPI1_MISO_PIN;
mosi = BOARD_SPI1_MOSI_PIN;
spiInitialised[0] = true;
}
else if (_currentSetting->spi_d == LPC_SSP0)
{
sck = BOARD_SPI2_SCK_PIN;
miso = BOARD_SPI2_MISO_PIN;
mosi = BOARD_SPI2_MOSI_PIN;
spiInitialised[1] = true;
}
PINSEL_CFG_Type PinCfg; // data structure to hold init values
PinCfg.Funcnum = 2;
PinCfg.OpenDrain = 0;
PinCfg.Pinmode = 0;
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_SCK_PIN);
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_SCK_PIN);
PinCfg.Pinnum = LPC176x::pin_bit(sck);
PinCfg.Portnum = LPC176x::pin_port(sck);
PINSEL_ConfigPin(&PinCfg);
SET_OUTPUT(BOARD_SPI2_SCK_PIN);
SET_OUTPUT(sck);
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_MISO_PIN);
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_MISO_PIN);
PinCfg.Pinnum = LPC176x::pin_bit(miso);
PinCfg.Portnum = LPC176x::pin_port(miso);
PINSEL_ConfigPin(&PinCfg);
SET_INPUT(BOARD_SPI2_MISO_PIN);
SET_INPUT(miso);
PinCfg.Pinnum = LPC176x::pin_bit(BOARD_SPI2_MOSI_PIN);
PinCfg.Portnum = LPC176x::pin_port(BOARD_SPI2_MOSI_PIN);
PinCfg.Pinnum = LPC176x::pin_bit(mosi);
PinCfg.Portnum = LPC176x::pin_port(mosi);
PINSEL_ConfigPin(&PinCfg);
SET_OUTPUT(BOARD_SPI2_MOSI_PIN);
#endif
setModule(device);
/* Initialize GPDMA controller */
//TODO: call once in the constructor? or each time?
GPDMA_Init();
}
SET_OUTPUT(mosi);
}
void SPIClass::begin() {
updateSettings();
SSP_Cmd(_currentSetting->spi_d, ENABLE); // start SSP running
SSP_Cmd(_currentSetting->spi_d, ENABLE); // start SSP running
}
void SPIClass::beginTransaction(const SPISettings &cfg) {
void SPIClass::beginTransaction(const SPISettings &cfg)
{
setBitOrder(cfg.bitOrder);
setDataMode(cfg.dataMode);
setDataSize(cfg.dataSize);
@ -245,29 +278,33 @@ void SPIClass::beginTransaction(const SPISettings &cfg) {
begin();
}
uint8_t SPIClass::transfer(const uint16_t b) {
uint8_t SPIClass::transfer(const uint16_t b)
{
/* send and receive a single byte */
SSP_ReceiveData(_currentSetting->spi_d); // read any previous data
SSP_SendData(_currentSetting->spi_d, b);
waitSpiTxEnd(_currentSetting->spi_d); // wait for it to finish
waitSpiTxEnd(_currentSetting->spi_d); // wait for it to finish
return SSP_ReceiveData(_currentSetting->spi_d);
}
uint16_t SPIClass::transfer16(const uint16_t data) {
return (transfer((data >> 8) & 0xFF) << 8)
| (transfer(data & 0xFF) & 0xFF);
uint16_t SPIClass::transfer16(const uint16_t data)
{
return (transfer((data >> 8) & 0xFF) << 8) | (transfer(data & 0xFF) & 0xFF);
}
void SPIClass::end() {
void SPIClass::end()
{
// SSP_Cmd(_currentSetting->spi_d, DISABLE); // stop device or SSP_DeInit?
SSP_DeInit(_currentSetting->spi_d);
}
void SPIClass::send(uint8_t data) {
void SPIClass::send(uint8_t data)
{
SSP_SendData(_currentSetting->spi_d, data);
}
void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
void SPIClass::dmaSend(void *buf, uint16_t length, bool minc)
{
//TODO: LPC dma can only write 0xFFF bytes at once.
GPDMA_Channel_CFG_Type GPDMACfg;
@ -304,11 +341,13 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
GPDMA_ChannelCmd(0, ENABLE);
// wait data transfer
while (!GPDMA_IntGetStatus(GPDMA_STAT_RAWINTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_RAWINTERR, 0)) { }
while (!GPDMA_IntGetStatus(GPDMA_STAT_RAWINTTC, 0) && !GPDMA_IntGetStatus(GPDMA_STAT_RAWINTERR, 0))
{
}
// clear err and int
GPDMA_ClearIntPending (GPDMA_STATCLR_INTTC, 0);
GPDMA_ClearIntPending (GPDMA_STATCLR_INTERR, 0);
GPDMA_ClearIntPending(GPDMA_STATCLR_INTTC, 0);
GPDMA_ClearIntPending(GPDMA_STATCLR_INTERR, 0);
// dma disable
GPDMA_ChannelCmd(0, DISABLE);
@ -318,45 +357,54 @@ void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) {
SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, DISABLE);
}
uint16_t SPIClass::read() {
uint16_t SPIClass::read()
{
return SSP_ReceiveData(_currentSetting->spi_d);
}
void SPIClass::read(uint8_t *buf, uint32_t len) {
for (uint16_t i = 0; i < len; i++) buf[i] = transfer(0xFF);
void SPIClass::read(uint8_t *buf, uint32_t len)
{
for (uint16_t i = 0; i < len; i++)
buf[i] = transfer(0xFF);
}
void SPIClass::setClock(uint32_t clock) {
void SPIClass::setClock(uint32_t clock)
{
_currentSetting->clock = clock;
}
void SPIClass::setModule(uint8_t device) {
_currentSetting = &_settings[device - 1];// SPI channels are called 1 2 and 3 but the array is zero indexed
void SPIClass::setModule(uint8_t device)
{
_currentSetting = &_settings[device - 1]; // SPI channels are called 1 2 and 3 but the array is zero indexed
}
void SPIClass::setBitOrder(uint8_t bitOrder) {
void SPIClass::setBitOrder(uint8_t bitOrder)
{
_currentSetting->bitOrder = bitOrder;
}
void SPIClass::setDataMode(uint8_t dataMode) {
void SPIClass::setDataMode(uint8_t dataMode)
{
_currentSetting->dataMode = dataMode;
}
void SPIClass::setDataSize(uint32_t ds) {
void SPIClass::setDataSize(uint32_t ds)
{
_currentSetting->dataSize = ds;
}
/**
* Set up/tear down
*/
void SPIClass::updateSettings() {
void SPIClass::updateSettings()
{
//SSP_DeInit(_currentSetting->spi_d); //todo: need force de init?!
// divide PCLK by 2 for SSP0
CLKPWR_SetPCLKDiv(_currentSetting->spi_d == LPC_SSP0 ? CLKPWR_PCLKSEL_SSP0 : CLKPWR_PCLKSEL_SSP1, CLKPWR_PCLKSEL_CCLK_DIV_2);
SSP_CFG_Type HW_SPI_init; // data structure to hold init values
SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode
SSP_CFG_Type HW_SPI_init; // data structure to hold init values
SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode
HW_SPI_init.ClockRate = _currentSetting->clock;
HW_SPI_init.Databit = _currentSetting->dataSize;
@ -367,35 +415,36 @@ void SPIClass::updateSettings() {
* 2 1 0 Rising Falling
* 3 1 1 Falling Rising
*/
switch (_currentSetting->dataMode) {
case SPI_MODE0:
HW_SPI_init.CPHA = SSP_CPHA_FIRST;
HW_SPI_init.CPOL = SSP_CPOL_HI;
break;
case SPI_MODE1:
HW_SPI_init.CPHA = SSP_CPHA_SECOND;
HW_SPI_init.CPOL = SSP_CPOL_HI;
break;
case SPI_MODE2:
HW_SPI_init.CPHA = SSP_CPHA_FIRST;
HW_SPI_init.CPOL = SSP_CPOL_LO;
break;
case SPI_MODE3:
HW_SPI_init.CPHA = SSP_CPHA_SECOND;
HW_SPI_init.CPOL = SSP_CPOL_LO;
break;
default:
break;
switch (_currentSetting->dataMode)
{
case SPI_MODE0:
HW_SPI_init.CPHA = SSP_CPHA_FIRST;
HW_SPI_init.CPOL = SSP_CPOL_HI;
break;
case SPI_MODE1:
HW_SPI_init.CPHA = SSP_CPHA_SECOND;
HW_SPI_init.CPOL = SSP_CPOL_HI;
break;
case SPI_MODE2:
HW_SPI_init.CPHA = SSP_CPHA_FIRST;
HW_SPI_init.CPOL = SSP_CPOL_LO;
break;
case SPI_MODE3:
HW_SPI_init.CPHA = SSP_CPHA_SECOND;
HW_SPI_init.CPOL = SSP_CPOL_LO;
break;
default:
break;
}
// TODO: handle bitOrder
SSP_Init(_currentSetting->spi_d, &HW_SPI_init); // puts the values into the proper bits in the SSP0 registers
SSP_Init(_currentSetting->spi_d, &HW_SPI_init); // puts the values into the proper bits in the SSP0 registers
}
#if MISO_PIN == BOARD_SPI1_MISO_PIN
SPIClass SPI(1);
SPIClass SPI(1);
#elif MISO_PIN == BOARD_SPI2_MISO_PIN
SPIClass SPI(2);
SPIClass SPI(2);
#endif
#endif // TARGET_LPC1768

+ 1
- 0
Marlin/src/core/boards.h View File

@ -318,6 +318,7 @@
#define BOARD_CREALITY_V4 4033 // Creality v4.x (STM32F103RE)
#define BOARD_CREALITY_V427 4034 // Creality v4.2.7 (STM32F103RE)
#define BOARD_TRIGORILLA_PRO 4035 // Trigorilla Pro (STM32F103ZET6)
#define BOARD_FLSUN_HISPEED 4036 // FLSUN HiSpeedV1 (STM32F103VET6)
//
// ARM Cortex-M4F


+ 2
- 1
Marlin/src/pins/pins.h View File

@ -558,7 +558,8 @@
#include "stm32f1/pins_CREALITY_V427.h" // STM32F1 env:STM32F103RET6_creality
#elif MB(TRIGORILLA_PRO)
#include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro
#elif MB(FLSUN_HISPEED)
#include "stm32f1/pins_FLSUN_HISPEED.h" // STM32F1 env:flsun_hispeed
//
// ARM Cortex-M4F
//


+ 306
- 0
Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h View File

@ -0,0 +1,306 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* FLSUN HiSpeed V1 (STM32F130VET6) board pin assignments
* MKS Robin Mini USB Use UART3(PB10-TX,PB11-RX)
* #define SERIAL_PORT_2 3
*/
#ifndef __STM32F1__
#error "Oops! Select an STM32F1 board in 'Tools > Board.'"
#elif HOTENDS > 1 || E_STEPPERS > 1
#error "FLSUN hispeed supports 1 hotends / E-steppers. Comment out this line to continue."
#endif
#define BOARD_INFO_NAME "FLSUN HISPEED"
//
// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
//
#define DISABLE_DEBUG
//
// EEPROM
//
#if EITHER(NO_EEPROM_SELECTED, FLASH_EEPROM_EMULATION)
#define FLASH_EEPROM_EMULATION
#define EEPROM_PAGE_SIZE (0x800U) // 2KB
#define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE)*1024UL - (EEPROM_PAGE_SIZE)*2UL)
#define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE // 2KB
#endif
// SPI1(PA7) & SPI3(PB5) not available
//
// Note: FLSun Hispeed (clone MKS_Robin_miniV2) board is using SPI2 interface.
//
#define ENABLE_SPI2
//
// Limit Switches
//
#define X_STOP_PIN PA15 //-X
#define Y_STOP_PIN PA12 //-Y
#define Z_MIN_PIN PA11 //-Z
#define Z_MAX_PIN PC4 //+Z
//
// Steppers
//
#define X_ENABLE_PIN PE4 //X_EN
#define X_STEP_PIN PE3 //X_STEP
#define X_DIR_PIN PE2 //X_DIR
#define Y_ENABLE_PIN PE1 //Y_EN
#define Y_STEP_PIN PE0 //Y_STEP
#define Y_DIR_PIN PB9 //Y_DIR
#define Z_ENABLE_PIN PB8 //Z_EN
#define Z_STEP_PIN PB5 //Z_STEP
#define Z_DIR_PIN PB4 //Z_DIR
#define E0_ENABLE_PIN PB3 //E0_EN
#define E0_STEP_PIN PD6 //E0_STEP
#define E0_DIR_PIN PD3 //E0_DIR
//#define VREF_XY_PIN PA6 //Vref Control XY
//#define VREF_Z_PIN PA7 //Vref Control Z
//#define VREF_E0_PIN PB0 //Vref Control E
#if HAS_TMC_UART
#define X_CS_PIN PA10 //RXD1 /PD5
#define Y_CS_PIN PA9 //TXD1 /PD7
#define Z_CS_PIN PC7 //IO0 /PD4
#define E0_CS_PIN PA8 //IO1 /PD9
/**
* TMC2208/TMC2209 stepper drivers
*
* Software serial.
* TMC2208 || TMC2209
*
*/
#define X_SERIAL_TX_PIN PA10 //RXD1 /PD5
#define X_SERIAL_RX_PIN PA10 //RXD1 /PD5
#define Y_SERIAL_TX_PIN PA9 //TXD1 /PD7
#define Y_SERIAL_RX_PIN PA9 //TXD1 /PD7
#define Z_SERIAL_TX_PIN PC7 //IO1 /PD4
#define Z_SERIAL_RX_PIN PC7 //IO1 /PD4
#define E0_SERIAL_TX_PIN PA8 //IO0 /PD9
#define E0_SERIAL_RX_PIN PA8 //IO0 /PD9
// Reduce baud rate to improve software serial reliability
#define TMC_BAUD_RATE 19200
#else
// Motor current PWM pins
#define MOTOR_CURRENT_PWM_XY_PIN PA6
#define MOTOR_CURRENT_PWM_Z_PIN PA7
#define MOTOR_CURRENT_PWM_E_PIN PB0
#define MOTOR_CURRENT_PWM_RANGE 1500 // (255 * (1000mA / 65535)) * 257 = 1000 is equal 1.6v Vref in turn equal 1Amp
#ifndef DEFAULT_PWM_MOTOR_CURRENT
#define DEFAULT_PWM_MOTOR_CURRENT \
{ \
800, 800, 800 \
}
#endif
#if ENABLED(ESP_WIFI)
/**
* src: MKS Robin_Mini V2
* __ESP(M1)__ -J1-
* GND| 15 | | 08 |+3v3 (22)=>RXD1(PA10) //
* | 16 | | 07 |MOSI (21)=>TXD1(PA9) // active low, probably OK to leave floating
* IO2| 17 | | 06 |MISO (19)=>IO1(PC7) // Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating)
* IO0| 18 | | 05 |CLK (18)=>IO0(PA8) // must be high (ESP3D software configures this with a pullup so OK to leave as floating)
* IO1| 19 | | 03 |EN (03)=>WIFI_EN() // Must be high for module to run
* | nc | | nc | (01)=>WIFI_CTRL(PA5)
* RX| 21 | | nc |
* TX| 22 | | 01 |RST
* AE
*
*/
#define WIFI_IO0_PIN PA8 // PC13 MKS ESP WIFI IO0 PIN
#define WIFI_IO1_PIN PC7 // MKS ESP WIFI IO1 PIN
#define WIFI_RESET_PIN PA5 // MKS ESP WIFI RESET PIN
#endif
#endif
//
// Temperature Sensors(THM)
//
#define TEMP_0_PIN PC1 // TEMP_E0
#define TEMP_BED_PIN PC0 // TEMP_BED
//
// Heaters / Fans
//
#define HEATER_0_PIN PC3 // HEATER_E0
#define HEATER_BED_PIN PA0 // HEATER_BED-WKUP
#define FAN_PIN PB1 // E_FAN
//#define CONTROLLER_FAN_PIN PD6 // BOARD FAN
//
// Misc. Functions
//
//#define POWER_LOSS_PIN PA1 // PW_SO
#if ENABLED(BACKUP_POWER_SUPPLY)
#define POWER_LOSS_PIN PA2 // PW_DET (UPS) MKSPWC
#endif
// Enable Power Supply Control
#if ENABLED(PSU_CONTROL)
#define KILL_PIN PA2 // PW_DET
#define KILL_PIN_INVERTING true //
//#define PS_ON_PIN PA3 // PW_CN /PW_OFF
#endif
#define MT_DET_1_PIN PA4 // MT_DET
#define MT_DET_2_PIN PE6 // FALA_CRTL
#define MT_DET_PIN_INVERTING false
#ifndef FIL_RUNOUT_PIN
#define FIL_RUNOUT_PIN MT_DET_1_PIN
#endif
//#define LED_PIN PB2
//#define SERVO0_PIN PA8 // use IO0 to enable BLTOUCH support/remove Mks_Wifi
//
// SD Card
//
#define SDIO_SUPPORT
#define SDIO_CLOCK 4500000 // 4.5 MHz
#if ENABLED(SDIO_SUPPORT)
#define SCK_PIN PB13 // SPI2
#define MISO_PIN PB14 // SPI2
#define MOSI_PIN PB15 // SPI2
#define SD_DETECT_PIN PD12 // SD_CD
#endif
//
// LCD / Controller
//
#ifndef BEEPER_PIN
#define BEEPER_PIN PC5
#endif
/**
* Note: MKS Robin TFT screens use various TFT controllers
* Supported screens are based on the ILI9341, ST7789V and ILI9328 (320x240)
* ILI9488 is not supported
* Define init sequences for other screens in u8g_dev_tft_320x240_upscale_from_128x64.cpp
*
* If the screen stays white, disable 'LCD_RESET_PIN'
* to let the bootloader init the screen.
*
* Setting an 'LCD_RESET_PIN' may cause a flicker when entering the LCD menu
* because Marlin uses the reset as a failsafe to revive a glitchy LCD.
*/
/* MKS Robin TFT v2.0 with ILI9341 */
//#define XPT2046_X_CALIBRATION 12013
//#define XPT2046_Y_CALIBRATION -8711
//#define XPT2046_X_OFFSET -32
//#define XPT2046_Y_OFFSET 256
/* MKS Robin TFT v1.1 with ILI9328 */
//#define XPT2046_X_CALIBRATION -11792
//#define XPT2046_Y_CALIBRATION 8947
//#define XPT2046_X_OFFSET 342
//#define XPT2046_Y_OFFSET -19
/* MKS Robin TFT v1.1 with R61505 */
//#define XPT2046_X_CALIBRATION 12489
//#define XPT2046_Y_CALIBRATION 9210
//#define XPT2046_X_OFFSET -52
//#define XPT2046_Y_OFFSET -17
/* QQS-Pro use MKS Robin TFT v2.0 */
//+++++++++++++++++++++++//
#define XPT2046_X_CALIBRATION 12013
#define XPT2046_Y_CALIBRATION -8711
#define XPT2046_X_OFFSET -32
#define XPT2046_Y_OFFSET 256
#define TFT_RST_PIN PC6 // FSMC_RST
#define TFT_BACKLIGHT_PIN PD13 // FSMC_LIGHT
#define TFT_CS_PIN PD7
#define TFT_DC_PIN PD11
#define TFT_A0_PIN TFT_DC_PIN
#define FSMC_CS_PIN TFT_CS_PIN
#define FSMC_RS_PIN TFT_DC_PIN
#define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT
#define FSMC_DMA_DEV DMA2
#define FSMC_DMA_CHANNEL DMA_CH5
#if ENABLED(FSMC_GRAPHICAL_TFT)
#define LCD_RESET_PIN TFT_RST_PIN // FSMC_RST
#define LCD_BACKLIGHT_PIN TFT_BACKLIGHT_PIN
#if NEED_TOUCH_PINS
#define TOUCH_CS_PIN PC2 // SPI2_NSS
#define TOUCH_SCK_PIN PB13 // SPI2_SCK
#define TOUCH_MISO_PIN PB14 // SPI2_MISO
#define TOUCH_MOSI_PIN PB15 // SPI2_MOSI
#define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens
#define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus
#define TFT_MARLINUI_COLOR 0xFFFF // White
#define TFT_BTARROWS_COLOR 0xDEE6 // 11011 110111 00110 Yellow
#define TFT_BTOKMENU_COLOR 0x145F // 00010 100010 11111 Cyan
#endif
#elif ENABLED(TFT_320x240)
#define TOUCH_CS_PIN PC2 // SPI2_NSS
#define TOUCH_SCK_PIN PB13 // SPI2_SCK
#define TOUCH_MISO_PIN PB14 // SPI2_MISO
#define TOUCH_MOSI_PIN PB15 // SPI2_MOSI
#define TFT_BUFFER_SIZE 14400
#endif
// end defintion MKS robin TFT
// SPI Flash
#define HAS_SPI_FLASH 1
#define SPI_FLASH_SIZE 0x1000000 // 16MB
#if HAS_SPI_FLASH
// SPI 2
#define W25QXX_CS_PIN PB12 //SPI2_NSS / Flash chip-select
#define W25QXX_MOSI_PIN PB15
#define W25QXX_MISO_PIN PB14
#define W25QXX_SCK_PIN PB13
#endif

+ 9
- 0
platformio.ini View File

@ -389,6 +389,15 @@ monitor_flags =
# #
#################################
[env:flsun_hispeed]
platform = ${common_stm32f1.platform}
extends = common_stm32f1
board = genericSTM32F103VE
extra_scripts = ${common.extra_scripts}
buildroot/share/PlatformIO/scripts/mks_robin_mini.py
build_flags = ${common_stm32f1.build_flags}
-DMCU_STM32F103VE
#################################
# #
# AVR Architecture #


Loading…
Cancel
Save