mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-13 18:12:13 +00:00
Merge
This commit is contained in:
@@ -187,15 +187,15 @@ static void i2c_lld_abort_operation(I2CDriver *i2cp) {
|
||||
}
|
||||
|
||||
static bool_t i2c_lld_tx_not_done(I2CDriver *i2cp) {
|
||||
return i2cp->txidx < i2cp->txbytes;
|
||||
return i2cp->txbytes > 0;
|
||||
}
|
||||
|
||||
static bool_t i2c_lld_rx_not_done(I2CDriver *i2cp) {
|
||||
return i2cp->rxbuf && i2cp->rxbytes;
|
||||
return i2cp->rxbytes > 0;
|
||||
}
|
||||
|
||||
static bool_t i2c_lld_rx_last_byte(I2CDriver *i2cp) {
|
||||
return i2cp->rxidx == (i2cp->rxbytes - 1);
|
||||
return i2cp->rxbytes == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,7 +249,8 @@ static void i2c_lld_serve_event_interrupt(I2CDriver *i2cp) {
|
||||
case I2C_MASTER_TX_DATA_ACK: /* 0x28 */
|
||||
if (i2c_lld_tx_not_done(i2cp)) {
|
||||
//i2c_periph_transmit_byte(dp, i2cp->txbuf[i2cp->txidx++]);
|
||||
dp->DAT = i2cp->txbuf[i2cp->txidx++];
|
||||
dp->DAT = *i2cp->txbuf++;
|
||||
i2cp->txbytes--;
|
||||
dp->CONCLR = I2C_CONCLR_SIC;
|
||||
} else {
|
||||
if (i2c_lld_rx_not_done(i2cp)) {
|
||||
@@ -266,7 +267,8 @@ static void i2c_lld_serve_event_interrupt(I2CDriver *i2cp) {
|
||||
break;
|
||||
|
||||
case I2C_MASTER_RX_DATA_ACK: /* 0x50 */
|
||||
i2cp->rxbuf[i2cp->rxidx++] = i2c_periph_read_byte(dp);
|
||||
*i2cp->rxbuf++ = i2c_periph_read_byte(dp);
|
||||
i2cp->rxbytes--;
|
||||
/* fall through */
|
||||
case I2C_MASTER_RX_ADDR_ACK: /* 0x40 */
|
||||
if (i2c_lld_rx_last_byte(i2cp)) {
|
||||
@@ -277,7 +279,8 @@ static void i2c_lld_serve_event_interrupt(I2CDriver *i2cp) {
|
||||
break;
|
||||
|
||||
case I2C_MASTER_RX_DATA_NACK: /* 0x58 */
|
||||
i2cp->rxbuf[i2cp->rxidx] = i2c_periph_read_byte(dp);
|
||||
*i2cp->rxbuf++ = i2c_periph_read_byte(dp);
|
||||
i2cp->rxbytes--;
|
||||
i2c_periph_stop(dp);
|
||||
wakeup_isr(i2cp, RDY_OK);
|
||||
/* fall through */
|
||||
@@ -474,10 +477,8 @@ static msg_t i2c_lld_master_start(I2CDriver *i2cp, uint_fast8_t addr_r,
|
||||
i2cp->addr_r = addr_r;
|
||||
i2cp->txbuf = txbuf;
|
||||
i2cp->txbytes = txbytes;
|
||||
i2cp->txidx = 0;
|
||||
i2cp->rxbuf = rxbuf;
|
||||
i2cp->rxbytes = rxbytes;
|
||||
i2cp->rxidx = 0;
|
||||
|
||||
/* Atomic check on the timer in order to make sure that a timeout didn't
|
||||
happen outside the critical zone.*/
|
||||
|
@@ -169,10 +169,6 @@ struct I2CDriver {
|
||||
* @brief Number of bytes of data to send.
|
||||
*/
|
||||
size_t txbytes;
|
||||
/**
|
||||
* @brief Current index in buffer when sending data.
|
||||
*/
|
||||
size_t txidx;
|
||||
/**
|
||||
* @brief Pointer to the buffer to put received data.
|
||||
*/
|
||||
@@ -181,10 +177,6 @@ struct I2CDriver {
|
||||
* @brief Number of bytes of data to receive.
|
||||
*/
|
||||
size_t rxbytes;
|
||||
/**
|
||||
* @brief Current index in buffer when receiving data.
|
||||
*/
|
||||
size_t rxidx;
|
||||
/**
|
||||
* @brief Pointer to the I2Cx registers block.
|
||||
*/
|
||||
|
@@ -580,6 +580,11 @@ void sdc_lld_start(SDCDriver *sdcp) {
|
||||
sdio_reset();
|
||||
sdio_reset_card();
|
||||
|
||||
// UM10503 recommendation
|
||||
LPC_SCU->SDDELAY =
|
||||
(0x8 << 0)
|
||||
| (0xf << 8)
|
||||
;
|
||||
LPC_SDMMC->CTRL =
|
||||
(1U << 4) /* INT_ENABLE */
|
||||
| (1U << 25) /* USE_INTERNAL_DMAC */
|
||||
|
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
||||
Copyright (C) 2014 Jared Boone, ShareBrained Technology
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* LPC43xx M4 memory setup.
|
||||
*/
|
||||
__main_stack_size__ = 0x1000; /* Exceptions/interrupts stack */
|
||||
__process_stack_size__ = 0x6000; /* main() stack */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
flash : org = 0x00000000, len = 512k /* Flash bank A @ 0x1a000000 */
|
||||
ram : org = 0x10080000, len = 40k /* Local SRAM @ 0x10080000 */
|
||||
}
|
||||
|
||||
__ram_start__ = ORIGIN(ram);
|
||||
__ram_size__ = LENGTH(ram);
|
||||
__ram_end__ = __ram_start__ + __ram_size__;
|
||||
|
||||
ENTRY(ResetHandler)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0;
|
||||
_text = .;
|
||||
|
||||
startup : ALIGN(16) SUBALIGN(16)
|
||||
{
|
||||
KEEP(*(vectors))
|
||||
} > flash
|
||||
|
||||
constructors : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
PROVIDE(__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE(__init_array_end = .);
|
||||
} > flash
|
||||
|
||||
destructors : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
PROVIDE(__fini_array_start = .);
|
||||
KEEP(*(.fini_array))
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
PROVIDE(__fini_array_end = .);
|
||||
} > flash
|
||||
|
||||
.text : ALIGN(16) SUBALIGN(16)
|
||||
{
|
||||
*(.text.startup.*)
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
*(.glue_7t)
|
||||
*(.glue_7)
|
||||
*(.gcc*)
|
||||
} > flash
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > flash
|
||||
|
||||
.ARM.exidx : {
|
||||
PROVIDE(__exidx_start = .);
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
PROVIDE(__exidx_end = .);
|
||||
} > flash
|
||||
|
||||
.eh_frame_hdr :
|
||||
{
|
||||
*(.eh_frame_hdr)
|
||||
} > flash
|
||||
|
||||
.eh_frame : ONLY_IF_RO
|
||||
{
|
||||
*(.eh_frame)
|
||||
} > flash
|
||||
|
||||
.textalign : ONLY_IF_RO
|
||||
{
|
||||
. = ALIGN(8);
|
||||
} > flash
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .;
|
||||
_textdata = _etext;
|
||||
|
||||
.stacks :
|
||||
{
|
||||
. = ALIGN(8);
|
||||
__main_stack_base__ = .;
|
||||
. += __main_stack_size__;
|
||||
. = ALIGN(8);
|
||||
__main_stack_end__ = .;
|
||||
__process_stack_base__ = .;
|
||||
__main_thread_stack_base__ = .;
|
||||
. += __process_stack_size__;
|
||||
. = ALIGN(8);
|
||||
__process_stack_end__ = .;
|
||||
__main_thread_stack_end__ = .;
|
||||
} > ram
|
||||
|
||||
.data ALIGN(4) : ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_data = .);
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
*(.ramtext)
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_edata = .);
|
||||
} > ram AT > flash
|
||||
|
||||
.bss ALIGN(4) : ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_bss_start = .);
|
||||
*(.bss)
|
||||
*(.bss.*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
PROVIDE(_bss_end = .);
|
||||
} > ram
|
||||
}
|
||||
|
||||
PROVIDE(end = .);
|
||||
_end = .;
|
||||
|
||||
__heap_base__ = _end;
|
||||
__heap_end__ = __ram_end__;
|
Reference in New Issue
Block a user