Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
makbit authored Jun 10, 2020
1 parent 5b39fca commit 693ae3a
Show file tree
Hide file tree
Showing 55 changed files with 52,893 additions and 0 deletions.
Binary file not shown.
719 changes: 719 additions & 0 deletions Firmware/EFM8/sdk/Device/EFM8UB2/VCPXpress/VCPXpress.h

Large diffs are not rendered by default.

Binary file not shown.
120 changes: 120 additions & 0 deletions Firmware/EFM8/sdk/Device/EFM8UB2/bsp/efm8_memory_lcd/spi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/**************************************************************************//**
* Copyright (c) 2015 by Silicon Laboratories Inc. All rights reserved.
*
* http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt
*****************************************************************************/
/////////////////////////////////////////////////////////////////////////////
// Spi.c
/////////////////////////////////////////////////////////////////////////////

// SPI FIFO Format
// ---------------
//
// All SPI transfers are pushed to the TX FIFO with the transfer size in
// bytes followed by the data to transmit.

/////////////////////////////////////////////////////////////////////////////
// Includes
/////////////////////////////////////////////////////////////////////////////

#include "bsp.h"
#include "spi.h"
#include "spi_0.h"
#include <string.h>

/////////////////////////////////////////////////////////////////////////////
// Globals
/////////////////////////////////////////////////////////////////////////////

static SI_SEGMENT_VARIABLE(TxBuffer[SPI_BUF_SIZE], uint8_t, EFM8PDL_SPI0_TX_SEGTYPE);

static volatile uint8_t TransferState = ST_IDLE;
static volatile uint8_t TransferSize = 0;

/////////////////////////////////////////////////////////////////////////////
// Functions
/////////////////////////////////////////////////////////////////////////////

void SPI_StartTransfer(SI_VARIABLE_SEGMENT_POINTER(buffer, uint8_t, SI_SEG_GENERIC), uint8_t size)
{
uint8_t sfrPageSave;
uint8_t i;

// Wait for previous transfer to complete
while (TransferState != ST_IDLE);

// Start new transfer
TransferState = ST_CS_SETUP;
TransferSize = size;

for (i = 0; i < size; i++)
{
TxBuffer[i] = buffer[i];
}

sfrPageSave = SFRPAGE;
SFRPAGE = LEGACY_PAGE;

// CS setup time
// Timer 2 overflows at end of setup time
TMR2 = (uint16_t)-(DELAY_TIMER_FREQ / 1000000 * SPI_CS_SETUP_US);
BSP_DISP_CS = SPI_CS_ASSERT_LVL;
TMR2CN0 |= TMR2CN0_TR2__BMASK;

SFRPAGE = sfrPageSave;
}

/////////////////////////////////////////////////////////////////////////////
// Interrupt Service Handlers
/////////////////////////////////////////////////////////////////////////////

void SPI0_transferCompleteCb(void)
{
uint8_t sfrPageSave;

// CS hold time
TransferState = ST_CS_HOLD;

sfrPageSave = SFRPAGE;
SFRPAGE = LEGACY_PAGE;

// CS hold time
// Timer 2 overflows at end of hold time
TMR2 = (uint16_t)-(DELAY_TIMER_FREQ / 1000000 * SPI_CS_HOLD_US);
TMR2CN0 |= TMR2CN0_TR2__BMASK;

SFRPAGE = sfrPageSave;
}

//-----------------------------------------------------------------------------
// TIMER2_ISR
//-----------------------------------------------------------------------------
//
// TIMER2 ISR Content goes here. Remember to clear flag bits:
// TMR2CN::TF2H (Timer # High Byte Overflow Flag)
// TMR2CN::TF2L (Timer # Low Byte Overflow Flag)
//
//-----------------------------------------------------------------------------
SI_INTERRUPT (TIMER2_ISR, TIMER2_IRQn)
{
TMR2CN0 &= ~TMR2CN0_TF2H__BMASK;

// Stop timer
TMR2CN0 &= ~TMR2CN0_TR2__BMASK;

// CS setup complete
if (TransferState == ST_CS_SETUP)
{
TransferState = ST_TX;
SPI0_transfer(TxBuffer, NULL, SPI0_TRANSFER_TX, TransferSize);
}
// CS hold complete
else if (TransferState == ST_CS_HOLD)
{
// Deassert CS
BSP_DISP_CS = SPI_CS_DEASSERT_LVL;

// Transfer complete
TransferState = ST_IDLE;
}
}
80 changes: 80 additions & 0 deletions Firmware/EFM8/sdk/Device/EFM8UB2/bsp/efm8_memory_lcd/tick.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**************************************************************************//**
* Copyright (c) 2015 by Silicon Laboratories Inc. All rights reserved.
*
* http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt
*****************************************************************************/
/////////////////////////////////////////////////////////////////////////////
// Tick.c
/////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// Includes
/////////////////////////////////////////////////////////////////////////////

#include "bsp.h"
#include "tick.h"

/////////////////////////////////////////////////////////////////////////////
// Globals
/////////////////////////////////////////////////////////////////////////////

static volatile uint16_t Ticks = 0;

/////////////////////////////////////////////////////////////////////////////
// Functions
/////////////////////////////////////////////////////////////////////////////

//---------------------------------------------------------------------------
// GetTickCount
//---------------------------------------------------------------------------
//
// Description - Return the system up time in milliseconds
//
// return - Number of milliseconds since system start.
//
uint16_t GetTickCount()
{
uint16_t ticks;

// Disable Timer 3 interrupts
EIE1 &= ~EIE1_ET3__BMASK;

ticks = Ticks;

// Enable Timer 3 interrupts
EIE1 |= EIE1_ET3__BMASK;

return ticks;
}

//---------------------------------------------------------------------------
// Wait
//---------------------------------------------------------------------------
//
// Description - Wait the specified number of milliseconds
//
// ms - The number of milliseconds to wait
//
void Wait(uint16_t ms)
{
uint16_t ticks = GetTickCount();

while ((GetTickCount() - ticks) < ms);
}

//-----------------------------------------------------------------------------
// TIMER3_ISR
//-----------------------------------------------------------------------------
//
// TIMER3 ISR Content goes here. Remember to clear flag bits:
// TMR3CN::TF3H (Timer # High Byte Overflow Flag)
// TMR3CN::TF3L (Timer # Low Byte Overflow Flag)
//
//-----------------------------------------------------------------------------
SI_INTERRUPT (TIMER3_ISR, TIMER3_IRQn)
{
// Overflows every 1 ms
TMR3CN0 &= ~TMR3CN0_TF3H__BMASK;

Ticks++;
}
Loading

0 comments on commit 693ae3a

Please sign in to comment.