Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • add_menu_vibration
  • blinkisync-as-preload
  • ch3/api-speed-eval2
  • ch3/dual-core
  • ch3/genapi-refactor
  • ch3/leds-api
  • ch3/splashscreen
  • dualcore
  • dx/flatten-config-module
  • dx/meh-bdf-to-stm
  • dx/somewhat-more-dynamic-config
  • esp32-nimble-wiki
  • freertos-btle
  • genofire/ble-follow-py
  • koalo/bhi160-works-but-dirty
  • koalo/factory-reset
  • koalo/wip/i2c-for-python
  • master
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • plaetzchen/ios-workaround
  • rahix/bhi
  • rahix/bma
  • rahix/hw-lock-new-mutex
  • renze/hatchery_apps
  • renze/safe_mode
  • schleicher-test
  • schneider/ble-buffers
  • schneider/ble-stability
  • schneider/ble-stability-new-phy
  • schneider/bonding
  • schneider/bootloader-update-9a0d158
  • schneider/bsec
  • schneider/fundamental-test
  • schneider/max30001
  • schneider/max30001-epicaridum
  • schneider/max30001-pycardium
  • schneider/maxim-sdk-update
  • schneider/mp-for-old-bl
  • schneider/schleicher-test
  • schneider/sdk-0.2.1-7
  • schneider/stream-locks
  • bootloader-v1
  • release-1
  • v0.0
  • v1.0
  • v1.1
  • v1.10
  • v1.11
  • v1.12
  • v1.2
  • v1.3
  • v1.4
  • v1.5
  • v1.6
  • v1.7
  • v1.8
  • v1.9
58 results

Target

Select target project
  • card10/firmware
  • annejan/firmware
  • astro/firmware
  • fpletz/firmware
  • gerd/firmware
  • fleur/firmware
  • swym/firmware
  • l/firmware
  • uberardy/firmware
  • wink/firmware
  • madonius/firmware
  • mot/firmware
  • filid/firmware
  • q3k/firmware
  • hauke/firmware
  • Woazboat/firmware
  • pink/firmware
  • mossmann/firmware
  • omniskop/firmware
  • zenox/firmware
  • trilader/firmware
  • Danukeru/firmware
  • shoragan/firmware
  • zlatko/firmware
  • sistason/firmware
  • datenwolf/firmware
  • bene/firmware
  • amedee/firmware
  • martinling/firmware
  • griffon/firmware
  • chris007/firmware
  • adisbladis/firmware
  • dbrgn/firmware
  • jelly/firmware
  • rnestler/firmware
  • mh/firmware
  • ln/firmware
  • penguineer/firmware
  • monkeydom/firmware
  • jens/firmware
  • jnaulty/firmware
  • jeffmakes/firmware
  • marekventur/firmware
  • pete/firmware
  • h2obrain/firmware
  • DooMMasteR/firmware
  • jackie/firmware
  • prof_r/firmware
  • Draradech/firmware
  • Kartoffel/firmware
  • hinerk/firmware
  • abbradar/firmware
  • JustTB/firmware
  • LuKaRo/firmware
  • iggy/firmware
  • ente/firmware
  • flgr/firmware
  • Lorphos/firmware
  • matejo/firmware
  • ceddral7/firmware
  • danb/firmware
  • joshi/firmware
  • melle/firmware
  • fitch/firmware
  • deurknop/firmware
  • sargon/firmware
  • markus/firmware
  • kloenk/firmware
  • lucaswerkmeister/firmware
  • derf/firmware
  • meh/firmware
  • dx/card10-firmware
  • torben/firmware
  • yuvadm/firmware
  • AndyBS/firmware
  • klausdieter1/firmware
  • katzenparadoxon/firmware
  • xiretza/firmware
  • ole/firmware
  • techy/firmware
  • thor77/firmware
  • TilCreator/firmware
  • fuchsi/firmware
  • dos/firmware
  • yrlf/firmware
  • PetePriority/firmware
  • SuperVirus/firmware
  • sur5r/firmware
  • tazz/firmware
  • Alienmaster/firmware
  • flo_h/firmware
  • baldo/firmware
  • mmu_man/firmware
  • Foaly/firmware
  • sodoku/firmware
  • Guinness/firmware
  • ssp/firmware
  • led02/firmware
  • Stormwind/firmware
  • arist/firmware
  • coon/firmware
  • mdik/firmware
  • pippin/firmware
  • royrobotiks/firmware
  • zigot83/firmware
  • mo_k/firmware
106 results
Select Git revision
  • add_menu_vibration
  • blinkisync-as-preload
  • ch3/api-speed-eval2
  • ch3/dual-core
  • ch3/genapi-refactor
  • ch3/leds-api
  • ch3/splashscreen
  • dualcore
  • dx/flatten-config-module
  • dx/meh-bdf-to-stm
  • freertos-btle
  • genofire/ble-follow-py
  • koalo/bhi160-works-but-dirty
  • koalo/factory-reset
  • koalo/wip/i2c-for-python
  • master
  • msgctl/faultscreen
  • msgctl/textbuffer_api
  • plaetzchen/ios-workaround
  • rahix/bhi
  • rahix/bluetooth-app-favorite
  • rahix/bma
  • rahix/user-space-ctx
  • renze/hatchery_apps
  • renze/safe_mode
  • schleicher-test
  • schneider/212-reset-hardware-when-entering-repl
  • schneider/ancs
  • schneider/ble-buffers
  • schneider/ble-central
  • schneider/ble-ecg-stream-visu
  • schneider/ble-fixes-2020-3
  • schneider/ble-mini-demo
  • schneider/ble-stability
  • schneider/ble-stability-new-phy
  • schneider/bonding
  • schneider/bonding-fail-if-full
  • schneider/bootloader-update-9a0d158
  • schneider/deepsleep
  • schneider/deepsleep2
  • schneider/deepsleep4
  • schneider/default-main
  • schneider/freertos-list-debug
  • schneider/fundamental-test
  • schneider/iaq-python
  • schneider/ir
  • schneider/max30001
  • schneider/max30001-epicaridum
  • schneider/max30001-pycardium
  • schneider/maxim-sdk-update
  • schneider/mp-exception-print
  • schneider/mp-for-old-bl
  • schneider/png
  • schneider/schleicher-test
  • schneider/sdk-0.2.1-11
  • schneider/sdk-0.2.1-7
  • schneider/sleep-display
  • schneider/spo2-playground
  • schneider/stream-locks
  • schneider/v1.17-changelog
  • bootloader-v1
  • release-1
  • v0.0
  • v1.0
  • v1.1
  • v1.10
  • v1.11
  • v1.12
  • v1.13
  • v1.14
  • v1.15
  • v1.16
  • v1.17
  • v1.18
  • v1.2
  • v1.3
  • v1.4
  • v1.5
  • v1.6
  • v1.7
  • v1.8
  • v1.9
82 results
Show changes
Showing
with 403 additions and 120 deletions
......@@ -29,8 +29,8 @@
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*
* $Date: 2019-03-11 12:57:08 +0000 (Mon, 11 Mar 2019) $
* $Revision: 41563 $
* $Date: 2019-09-11 13:25:48 -0500 (Wed, 11 Sep 2019) $
* $Revision: 46045 $
*
*************************************************************************** */
......@@ -525,7 +525,7 @@ int I2C_Slave(mxc_i2c_regs_t *i2c, uint8_t addr, const uint8_t* read_data, int r
break;
}
// Check for stop bit
// Check for done bit
if (i2c->int_fl0 & MXC_F_I2C_INT_FL0_DONE) {
break;
}
......@@ -537,7 +537,7 @@ int I2C_Slave(mxc_i2c_regs_t *i2c, uint8_t addr, const uint8_t* read_data, int r
}
}
// Wait for Stop
// Wait for Done
while (!(i2c->int_fl0 & MXC_F_I2C_INT_FL0_DONE)) {}
// Calculate number of bytes sent by the slave
......@@ -567,7 +567,7 @@ int I2C_Slave(mxc_i2c_regs_t *i2c, uint8_t addr, const uint8_t* read_data, int r
return E_COMM_ERR;
}
// Check for stop bit
// Check for done bit
if (i2c->int_fl0 & MXC_F_I2C_INT_FL0_DONE) {
break;
}
......@@ -579,7 +579,7 @@ int I2C_Slave(mxc_i2c_regs_t *i2c, uint8_t addr, const uint8_t* read_data, int r
}
}
// Wait for Stop
// Wait for done
while (!(i2c->int_fl0 & MXC_F_I2C_INT_FL0_DONE)) {
}
......
......@@ -346,6 +346,18 @@ void LP_EnterDeepSleepMode(void)
__WFI();
}
void LP_EnterBackgroundMode(void)
{
LP_ClearWakeStatus();
/* Set BACKGROUND bit and SLEEPDEEP bit */
MXC_PWRSEQ->lpcn |= MXC_F_PWRSEQ_LPCN_BCKGRND;
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
/* Go into Background mode and wait for an interrupt to wake the processor */
__WFI();
}
void LP_EnterBackupMode(void* func(void))
{
LP_ClearWakeStatus();
......
......@@ -39,9 +39,10 @@
#include "mxc_delay.h"
/* **** File Scope Variables **** */
static volatile int overflows = -1;
static uint32_t endtick;
static uint32_t ctrl_save;
static volatile uint64_t compare_value = 0;
static volatile uint64_t curr_value;
static volatile uint32_t reload;
static void mxc_delay_init(unsigned long us);
extern void SysTick_Handler(void);
......@@ -57,19 +58,20 @@ void mxc_delay_handler(void)
{
// Check and clear overflow flag
if (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) {
// Decrement overflow flag if delay is still ongoing
if (overflows > 0) {
overflows--;
} else {
// Is a delay in progress?
if(compare_value != 0) {
curr_value += reload;
if(curr_value >= compare_value) {
mxc_delay_stop();
}
}
}
}
/* ************************************************************************** */
static void mxc_delay_init(unsigned long us)
{
uint32_t starttick, reload, ticks, lastticks;
uint32_t starttick, ticks;
// Record the current tick value and clear the overflow flag
starttick = SysTick->VAL;
......@@ -81,7 +83,7 @@ static void mxc_delay_init(unsigned long us)
if (!(SysTick->CTRL & SysTick_CTRL_ENABLE_Msk)) {
SysTick->LOAD = SysTick_LOAD_RELOAD_Msk;
SysTick->VAL = SysTick_VAL_CURRENT_Msk;
SysTick->CTRL = SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_CLKSOURCE_Msk;
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk;
starttick = SysTick_VAL_CURRENT_Msk;
reload = SysTick_LOAD_RELOAD_Msk + 1;
} else {
......@@ -91,18 +93,11 @@ static void mxc_delay_init(unsigned long us)
// Calculate the total number of ticks to delay
ticks = (uint32_t)(((uint64_t)us * (uint64_t)SystemCoreClock) / 1000000);
// How many overflows of the SysTick will occur
overflows = ticks / reload;
compare_value = ticks + (reload - starttick);
curr_value = 0;
// How many remaining ticks after the last overflow
lastticks = ticks % reload;
// Check if there will be another overflow due to the current value of the SysTick
if (lastticks >= starttick) {
overflows++;
endtick = reload - (lastticks - starttick);
} else {
endtick = starttick - lastticks;
if (!(SysTick->CTRL & SysTick_CTRL_ENABLE_Msk)) {
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
}
......@@ -110,7 +105,7 @@ static void mxc_delay_init(unsigned long us)
int mxc_delay_start(unsigned long us)
{
// Check if timeout currently ongoing
if (overflows > 0) {
if (compare_value != 0) {
return E_BUSY;
}
......@@ -123,7 +118,7 @@ int mxc_delay_start(unsigned long us)
mxc_delay_init(us);
// Enable SysTick interrupt if necessary
if (overflows > 0) {
if (compare_value != 0) {
SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
}
......@@ -134,12 +129,11 @@ int mxc_delay_start(unsigned long us)
int mxc_delay_check(void)
{
// Check if timeout currently ongoing
if (overflows < 0) {
if (compare_value == 0) {
return E_NO_ERROR;
}
// Check the global values
if ((overflows == 0) && (SysTick->VAL <= endtick)) {
if((curr_value + (reload - SysTick->VAL)) >= compare_value) {
mxc_delay_stop();
return E_NO_ERROR;
}
......@@ -151,14 +145,14 @@ int mxc_delay_check(void)
void mxc_delay_stop(void)
{
SysTick->CTRL = ctrl_save;
overflows = -1;
compare_value = 0;
}
/* ************************************************************************** */
int mxc_delay(unsigned long us)
{
// Check if timeout currently ongoing
if (overflows > 0) {
if (compare_value != 0) {
return E_BUSY;
}
......@@ -170,20 +164,16 @@ int mxc_delay(unsigned long us)
// Calculate the necessary delay and start the timer
mxc_delay_init(us);
// Wait for the number of overflows
while (overflows > 0) {
// Wait until the total number of ticks exceeds the compare value.
while ((curr_value + (reload - SysTick->VAL)) < compare_value) {
// If SysTick interrupts are enabled, COUNTFLAG will never be set here and
// overflows will be decremented in the ISR. If SysTick interrupts are
// disabled, overflows is decremented here.
// curr_value will be incremented in the ISR. If SysTick interrupts are
// disabled, curr_value is incremented here.
if (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) {
overflows--;
curr_value += reload;
}
}
// Wait for the counter value
while (SysTick->VAL > endtick);
mxc_delay_stop();
return E_NO_ERROR;
}
......@@ -47,6 +47,8 @@
#include "mxc_sys.h"
#include "mxc_delay.h"
#include "gpio.h"
#include "flc.h"
#include "cipher.h"
#include "mxc_pins.h"
#include "gcr_regs.h"
#include "tmr_regs.h"
......@@ -76,6 +78,66 @@ static sys_cfg_spixr_t* spixr_cfg;
/* **** Functions **** */
static int SYS_Clock_Timeout(uint32_t ready);
/* ************************************************************************** */
int SYS_GetUSN(uint8_t *usn, uint8_t *checksum)
{
uint32_t *infoblock = (uint32_t*)MXC_INFO0_MEM_BASE;
// Read the USN from the info block
FLC_UnlockInfoBlock(MXC_INFO0_MEM_BASE);
usn[0] = (infoblock[0] & 0x007F8000) >> 15;
usn[1] = (infoblock[0] & 0x7F800000) >> 23;
usn[2] = (infoblock[1] & 0x0000007F) << 1;
usn[2] |= (infoblock[0] & 0x80000000) >> 31;
usn[3] = (infoblock[1] & 0x00007F80) >> 7;
usn[4] = (infoblock[1] & 0x007F8000) >> 15;
usn[5] = (infoblock[1] & 0x7F800000) >> 23;
usn[6] = (infoblock[2] & 0x007F8000) >> 15;
usn[7] = (infoblock[2] & 0x7F800000) >> 23;
usn[8] = (infoblock[3] & 0x0000007F) << 1;
usn[8] |= (infoblock[2] & 0x80000000) >> 31;
usn[9] = (infoblock[3] & 0x00007F80) >> 7;
usn[10] = (infoblock[3] & 0x007F8000) >> 15;
// Compute the checksum
if(checksum != NULL) {
uint8_t info_checksum[2];
char key[MXC_AES_KEY_128_LEN];
// Initialize the remainder of the USN and key
memset(&usn[11], 0, (AES_DATA_LEN - 11));
memset(key, 0, MXC_AES_KEY_128_LEN);
// Read the checksum from the info block
info_checksum[0] = ((infoblock[3] & 0x7F800000) >> 23);
info_checksum[1] = ((infoblock[4] & 0x007F8000) >> 15);
TPU_Cipher_Reset();
TPU_Cipher_Config(TPU_MODE_ECB, TPU_CIPHER_AES128);
TPU_AES_Encrypt((const char *)usn, NULL, (const char *)key,
TPU_CIPHER_AES128, MXC_V_TPU_CIPHER_CTRL_MODE_ECB, AES_DATA_LEN,
(char*)checksum);
TPU_Shutdown();
// Verify the checksum
if((checksum[1] != info_checksum[0]) ||
(checksum[0] != info_checksum[1])) {
FLC_LockInfoBlock(MXC_INFO0_MEM_BASE);
return E_UNKNOWN;
}
}
// Add the info block checksum to the USN
usn[11] = ((infoblock[3] & 0x7F800000) >> 23);
usn[12] = ((infoblock[4] & 0x007F8000) >> 15);
FLC_LockInfoBlock(MXC_INFO0_MEM_BASE);
return E_NO_ERROR;
}
/* ************************************************************************** */
int SYS_IsClockEnabled(sys_periph_clock_t clock)
{
......@@ -1003,5 +1065,11 @@ int SYS_WDT_Shutdown(mxc_wdt_regs_t* wdt)
return E_NO_ERROR;
}
/* ************************************************************************** */
uint32_t SYS_WUT_GetFreq(void)
{
return XTAL32K_FREQ;
}
/**@} end of mxc_sys */
......@@ -326,6 +326,7 @@ int RTC_CheckBusy(void)
return E_BUSY;
}
}
mxc_delay_stop();
return E_SUCCESS;
}
......
......@@ -29,8 +29,8 @@
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*
* $Date: 2018-08-28 22:03:02 +0000 (Tue, 28 Aug 2018) $
* $Revision: 37424 $
* $Date: 2019-09-11 14:43:14 -0500 (Wed, 11 Sep 2019) $
* $Revision: 46048 $
*
**************************************************************************** */
......@@ -47,12 +47,17 @@
/* **** Functions **** */
/* ************************************************************************** */
void TMR_Init(mxc_tmr_regs_t *tmr, tmr_pres_t pres, const sys_cfg_tmr_t* sys_cfg)
int TMR_Init(mxc_tmr_regs_t *tmr, tmr_pres_t pres, const sys_cfg_tmr_t* sys_cfg)
{
MXC_ASSERT(tmr);
int err;
// System settigns
SYS_TMR_Init(tmr, sys_cfg);
if((err = SYS_TMR_Init(tmr, sys_cfg)) != E_NO_ERROR)
{
return err;
}
// Disable timer and clear settings
tmr->cn = 0;
......@@ -62,42 +67,59 @@ void TMR_Init(mxc_tmr_regs_t *tmr, tmr_pres_t pres, const sys_cfg_tmr_t* sys_cfg
// Set the prescaler
tmr->cn = pres;
return err;
}
void TMR_Shutdown(mxc_tmr_regs_t *tmr)
int TMR_Shutdown(mxc_tmr_regs_t *tmr)
{
MXC_ASSERT(tmr);
int err;
// System settigns
SYS_TMR_Shutdown(tmr);
if((err = SYS_TMR_Shutdown(tmr)) != E_NO_ERROR)
{
return err;
}
// Disable timer and clear settings
tmr->cn = 0;
return err;
}
/* ************************************************************************** */
void TMR_Enable(mxc_tmr_regs_t* tmr)
{
MXC_ASSERT(tmr);
tmr->cn |= MXC_F_TMR_CN_TEN;
}
/* ************************************************************************** */
void TMR_Disable(mxc_tmr_regs_t* tmr)
{
MXC_ASSERT(tmr);
tmr->cn &= ~(MXC_F_TMR_CN_TEN);
}
/* ************************************************************************** */
void TMR_Config(mxc_tmr_regs_t *tmr, const tmr_cfg_t *cfg)
int TMR_Config(mxc_tmr_regs_t *tmr, const tmr_cfg_t *cfg)
{
MXC_ASSERT(tmr);
// Configure the timer
tmr->cn = (tmr->cn & ~(MXC_F_TMR_CN_TMODE | MXC_F_TMR_CN_TPOL)) |
((cfg->mode << MXC_F_TMR_CN_TMODE_POS) & MXC_F_TMR_CN_TMODE) |
((cfg->pol << MXC_F_TMR_CN_TPOL_POS) & MXC_F_TMR_CN_TPOL);
tmr->cnt = 0x1;
tmr->cmp = cfg->cmp_cnt;
return E_NO_ERROR;
}
/* ************************************************************************** */
......
/**
* @file wut.c
* @brief This file contains the function implementations for the
* WUT peripheral module.
*/
/* *****************************************************************************
* Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
* Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
......@@ -35,73 +29,244 @@
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*
* $Date: 2018-08-28 22:03:02 +0000 (Tue, 28 Aug 2018) $
* $Revision: 37424 $
* $Date: 2019-10-25 14:21:06 -0500 (Fri, 25 Oct 2019) $
* $Revision: 48094 $
*
**************************************************************************** */
/* **** Includes **** */
#include <string.h>
#include "mxc_config.h"
#include "mxc_assert.h"
#include "mxc_sys.h"
#include "wut.h"
#include "gcr_regs.h"
/**
* @ingroup wut
* @{
*/
/* **** Definitions **** */
int WUT_init(wut_config_t *config) {
//Do the configuration
/* **** Globals **** */
return E_NO_ERROR;
/* **** Local Variables **** */
static uint32_t wut_count;
static uint32_t wut_snapshot;
/* **** Functions **** */
/* ************************************************************************** */
void WUT_Init(wut_pres_t pres)
{
// Disable timer and clear settings
MXC_WUT->cn = 0;
// Clear interrupt flag
MXC_WUT->intr = MXC_F_WUT_INTR_IRQ_CLR;
// Set the prescaler
MXC_WUT->cn = pres;
// Initialize the compare register
MXC_WUT->cmp = 0xFFFFFFFF;
// Initialize the local variables
wut_count = 0;
wut_snapshot = 0;
}
int WUT_enable(void) {
//Set the enable bit?
void WUT_Shutdown(void)
{
// Disable timer and clear settings
MXC_WUT->cn = 0;
}
return E_NO_ERROR;
/* ************************************************************************** */
void WUT_Enable(void)
{
MXC_WUT->cn |= MXC_F_WUT_CN_TEN;
}
int WUT_disable(void) {
//Unset the enable bit?
/* ************************************************************************** */
void WUT_Disable(void)
{
MXC_WUT->cn &= ~(MXC_F_WUT_CN_TEN);
}
return E_NO_ERROR;
/* ************************************************************************** */
void WUT_Config(const wut_cfg_t *cfg)
{
// Configure the timer
MXC_WUT->cn = (MXC_WUT->cn & ~(MXC_F_WUT_CN_TMODE | MXC_F_WUT_CN_TPOL)) |
((cfg->mode << MXC_F_WUT_CN_TMODE_POS) & MXC_F_WUT_CN_TMODE);
MXC_WUT->cnt = 0x1;
MXC_WUT->cmp = cfg->cmp_cnt;
}
/* ************************************************************************** */
uint32_t WUT_GetCompare(void)
{
return MXC_WUT->cmp;
}
int WUT_get_time(void) {
//return WUT time register?
return -1;
/* ************************************************************************** */
uint32_t WUT_GetCapture(void)
{
return MXC_WUT->pwm;
}
int WUT_register_callback(wut_handler_t handler) {
/* ************************************************************************* */
uint32_t WUT_GetCount(void)
{
return MXC_WUT->cnt;
}
return E_NO_ERROR;
/* ************************************************************************* */
void WUT_IntClear(void)
{
MXC_WUT->intr = MXC_F_WUT_INTR_IRQ_CLR;
}
int WUT_unregister_callback(void) {
/* ************************************************************************* */
uint32_t WUT_IntStatus(void)
{
return MXC_WUT->intr;
}
/* ************************************************************************* */
void WUT_SetCompare(uint32_t cmp_cnt)
{
MXC_WUT->cmp = cmp_cnt;
}
/* ************************************************************************* */
void WUT_SetCount(uint32_t cnt)
{
MXC_WUT->cnt = cnt;
}
/* ************************************************************************* */
int WUT_GetTicks(uint32_t time, wut_unit_t units, uint32_t *ticks)
{
uint32_t unit_div0, unit_div1;
uint32_t timerClock;
uint32_t prescale;
uint64_t temp_ticks;
timerClock = SYS_WUT_GetFreq();
prescale = ((MXC_WUT->cn & MXC_F_WUT_CN_PRES) >> MXC_F_WUT_CN_PRES_POS)
| (((MXC_WUT->cn & MXC_F_WUT_CN_PRES3) >> (MXC_F_WUT_CN_PRES3_POS))<<3);
switch (units) {
case WUT_UNIT_NANOSEC:
unit_div0 = 1000000;
unit_div1 = 1000;
break;
case WUT_UNIT_MICROSEC:
unit_div0 = 1000;
unit_div1 = 1000;
break;
case WUT_UNIT_MILLISEC:
unit_div0 = 1;
unit_div1 = 1000;
break;
case WUT_UNIT_SEC:
unit_div0 = 1;
unit_div1 = 1;
break;
default:
return E_BAD_PARAM;
}
temp_ticks = (uint64_t)time * (timerClock / unit_div0) / (unit_div1 * (1 << (prescale & 0xF)));
//make sure ticks is within a 32 bit value
if (!(temp_ticks & 0xffffffff00000000) && (temp_ticks & 0xffffffff)) {
*ticks = temp_ticks;
return E_NO_ERROR;
}
void WUT_clear_flags(void) {
return;
return E_INVALID;
}
int WUT_get_flags(void) {
return 0;
/* ************************************************************************* */
int WUT_GetTime(uint32_t ticks, uint32_t *time, wut_unit_t *units)
{
uint64_t temp_time = 0;
uint32_t timerClock = SYS_WUT_GetFreq();
uint32_t prescale = ((MXC_WUT->cn & MXC_F_WUT_CN_PRES) >> MXC_F_WUT_CN_PRES_POS)
| (((MXC_WUT->cn & MXC_F_WUT_CN_PRES3) >> (MXC_F_WUT_CN_PRES3_POS))<<3);
temp_time = (uint64_t)ticks * 1000 * (1 << (prescale & 0xF)) / (timerClock / 1000000);
if (!(temp_time & 0xffffffff00000000)) {
*time = temp_time;
*units = WUT_UNIT_NANOSEC;
return E_NO_ERROR;
}
int WUT_set_timeout_ms(unsigned int timeout) {
temp_time = (uint64_t)ticks * 1000 * (1 << (prescale & 0xF)) / (timerClock / 1000);
if (!(temp_time & 0xffffffff00000000)) {
*time = temp_time;
*units = WUT_UNIT_MICROSEC;
return E_NO_ERROR;
}
int WUT_mode_ctrl(wut_mode_t mode) {
temp_time = (uint64_t)ticks * 1000 * (1 << (prescale & 0xF)) / timerClock;
if (!(temp_time & 0xffffffff00000000)) {
*time = temp_time;
*units = WUT_UNIT_MILLISEC;
return E_NO_ERROR;
}
void WUT_Handler(void) {
return;
temp_time = (uint64_t)ticks * (1 << (prescale & 0xF)) / timerClock;
if (!(temp_time & 0xffffffff00000000)) {
*time = temp_time;
*units = WUT_UNIT_SEC;
return E_NO_ERROR;
}
return E_INVALID;
}
/* ************************************************************************** */
void WUT_Edge(void)
{
// Wait for a WUT edge
uint32_t tmp = MXC_WUT->cnt;
while (tmp == MXC_WUT->cnt) {}
}
/* ************************************************************************** */
void WUT_Store(void)
{
wut_count = MXC_WUT->cnt;
wut_snapshot = MXC_WUT->snapshot;
}
/* ************************************************************************** */
void WUT_RestoreBBClock(uint32_t dbbFreq)
{
/* restore DBB clock from WUT */
WUT_Edge();
MXC_WUT->preset = wut_snapshot + (uint64_t)(MXC_WUT->cnt - wut_count + 1)
* dbbFreq / SYS_WUT_GetFreq();
MXC_WUT->reload = 1; // arm DBB_CNT update on the next rising WUT clock
WUT_Edge();
}
/* ************************************************************************** */
uint32_t WUT_GetSleepTicks(void)
{
return (MXC_WUT->cnt - wut_count);
}
/* ************************************************************************** */
void WUT_Delay_MS(uint32_t waitMs)
{
/* assume WUT is already running */
uint32_t tmp = MXC_WUT->cnt;
tmp += (waitMs * (SYS_WUT_GetFreq() /
(0x1 << ((MXC_WUT->cn & MXC_F_WUT_CN_PRES) >> MXC_F_WUT_CN_PRES_POS)))
+ 500) / 1000 ;
while(MXC_WUT->cnt < tmp){}
}
/**@} end of group wut */
......@@ -29,8 +29,8 @@
# property whatsoever. Maxim Integrated Products, Inc. retains all
# ownership rights.
#
# $Date: 2018-08-31 19:08:14 +0000 (Fri, 31 Aug 2018) $
# $Revision: 37586 $
# $Date: 2019-09-04 09:22:39 -0500 (Wed, 04 Sep 2019) $
# $Revision: 45915 $
#
###############################################################################
......@@ -40,7 +40,7 @@
################################################################################
ifeq "$(PERIPH_DRIVER_DIR)" ""
$(error PERIPH_DRIVER_DIR must be specified")
$(error "PERIPH_DRIVER_DIR must be specified")
endif
# Specify the build directory if not defined by the project
......@@ -67,12 +67,16 @@ export MXC_OPTIMIZE_CFLAGS
export DUAL_CORE
# Add to library list
ifeq "$(PERIPH_DRIVER_DEFS_ONLY)" ""
LIBS += ${PERIPH_DRIVER_BUILD_DIR}/PeriphDriver.a
endif
# Add to include directory list
IPATH += ${PERIPH_DRIVER_DIR}/Include
# Add rule to build the Driver Library
ifeq "$(PERIPH_DRIVER_DEFS_ONLY)" ""
${PERIPH_DRIVER_BUILD_DIR}/PeriphDriver.a: FORCE
$(MAKE) -C ${PERIPH_DRIVER_DIR} lib BUILD_DIR=${PERIPH_DRIVER_BUILD_DIR}
endif
......@@ -29,8 +29,8 @@
# property whatsoever. Maxim Integrated Products, Inc. retains all
# ownership rights.
#
# $Date: 2019-03-28 21:06:37 +0000 (Thu, 28 Mar 2019) $
# $Revision: 41966 $
# $Date: 2019-10-25 17:17:43 -0500 (Fri, 25 Oct 2019) $
# $Revision: 48103 $
#
###############################################################################
......@@ -84,6 +84,12 @@ endif
ifeq "$(TARGET_UC)" "MAX32656"
TARGET_USB=MUSBHSFC
endif
ifeq "$(TARGET_UC)" "MAX32570"
TARGET_USB=MUSBHSFC
endif
ifeq "$(TARGET_UC)" "MAX32572"
TARGET_USB=MUSBHSFC
endif
# Source files for this test (add path to VPATH below)
SRCS = usb.c
......
......@@ -29,8 +29,8 @@
# property whatsoever. Maxim Integrated Products, Inc. retains all
# ownership rights.
#
# $Date: 2019-03-28 21:06:37 +0000 (Thu, 28 Mar 2019) $
# $Revision: 41966 $
# $Date: 2019-10-25 17:17:43 -0500 (Fri, 25 Oct 2019) $
# $Revision: 48103 $
#
###############################################################################
......@@ -85,6 +85,12 @@ endif
ifeq "$(TARGET_UC)" "MAX32656"
TARGET_USB=MUSBHSFC
endif
ifeq "$(TARGET_UC)" "MAX32570"
TARGET_USB=MUSBHSFC
endif
ifeq "$(TARGET_UC)" "MAX32572"
TARGET_USB=MUSBHSFC
endif
# Add to include directory list
ifeq "$(TARGET_USB)" "MUSBHSFC"
......
......@@ -1092,10 +1092,6 @@ int usb_read_endpoint(usb_req_t *req)
if (req->callback) {
req->callback(req->cbdata);
}
#if MAXUSB_DEBUG
printf("MAXUSB ISSUE 4\n");
#endif
MAXUSB_EXIT_CRITICAL();
return 0;
} else {
/* Not done, more data requested */
......
......@@ -29,7 +29,7 @@
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*
* $Date: 2019-03-28 21:06:37 +0000 (Thu, 28 Mar 2019) $
* $Date: 2019-03-28 16:06:37 -0500 (Thu, 28 Mar 2019) $
* $Revision: 41966 $
*
******************************************************************************/
......@@ -71,7 +71,7 @@ static const uint8_t *report_desc;
static int (*chained_func)(usb_setup_pkt *, void *);
static void *chained_cbdata;
static void (*chained_getdesc_func)(usb_setup_pkt *, const uint8_t **, uint16_t *);
void (*chained_getdesc_func)(usb_setup_pkt *, const uint8_t **, uint16_t *);
/***** Function Prototypes *****/
static void getdescriptor(usb_setup_pkt *sud, const uint8_t **desc, uint16_t *desclen);
......
......@@ -29,8 +29,8 @@
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*
* $Date: 2019-03-28 21:06:37 +0000 (Thu, 28 Mar 2019) $
* $Revision: 41966 $
* $Date: 2019-08-02 10:39:06 -0500 (Fri, 02 Aug 2019) $
* $Revision: 45189 $
*
******************************************************************************/
......@@ -81,9 +81,9 @@ static const uint8_t *report_desc;
static int (*callback)(void);
static int (*chained_func)(usb_setup_pkt *, void *);
static void *chained_cbdata;
static void (*chained_getdesc_func)(usb_setup_pkt *, const uint8_t **, uint16_t *);
int (*chained_func)(usb_setup_pkt *, void *);
void *chained_cbdata;
void (*chained_getdesc_func)(usb_setup_pkt *, const uint8_t **, uint16_t *);
/***** Function Prototypes *****/
static void getdescriptor(usb_setup_pkt *sud, const uint8_t **desc, uint16_t *desclen);
......
......@@ -118,8 +118,8 @@ static unsigned int ep_to_host;
static uint32_t numBlocks;
static uint32_t blockAddr;
static int (*chained_func)(usb_setup_pkt *, void *);
static void *chained_cbdata;
int (*chained_func)(usb_setup_pkt *, void *);
void *chained_cbdata;
/***** Function Prototypes *****/
static int msc_classReq(usb_setup_pkt *sud, void *cbdata);
......
......@@ -29,8 +29,8 @@
* property whatsoever. Maxim Integrated Products, Inc. retains all
* ownership rights.
*
* $Date: 2019-03-28 21:06:37 +0000 (Thu, 28 Mar 2019) $
* $Revision: 41966 $
* $Date: 2019-10-25 17:17:43 -0500 (Fri, 25 Oct 2019) $
* $Revision: 48103 $
*
******************************************************************************/
......@@ -413,6 +413,7 @@ static int clearfeature(usb_setup_pkt *sud)
return -1;
}
} else {
/* Per USB 2.0: The Test_Mode feature cannot be cleared by the ClearFeature() request. */
/* Unsupported */
return -1;
}
......@@ -440,7 +441,7 @@ static int setfeature(usb_setup_pkt *sud)
return result;
}
} else if ((sud->wValue == FEAT_REMOTE_WAKE)) {
/* Clear the remote wakeup feature */
/* Set the remote wakeup feature */
if (callback[ENUM_SETFEATURE].fnaddr != NULL) {
result = callback[ENUM_SETFEATURE].fnaddr(sud, NULL);
if (result < 0) {
......@@ -451,7 +452,7 @@ static int setfeature(usb_setup_pkt *sud)
return -1;
}
} else if ((sud->wValue == FEAT_TEST_MODE)) {
/* Clear the test mode feature */
/* Set the test mode feature */
if (callback[ENUM_SETFEATURE].fnaddr != NULL) {
result = callback[ENUM_SETFEATURE].fnaddr(sud, NULL);
if (result < 0) {
......
###### Changes in version 0.2.1-7 #############################################
* Improved USB_CompositeDevice example to support high speed USB.
* Added function to enter background mode to lp.c/h.
* Added function to read the device's serial number (USN) to mxc_sys.c/h.
* Provided missing wakeup timer functions (wut.c/h).
* Added BLE deep sleep example.
* Removed debug symbols from pre-built BLE libraries.
* Made BLE transmit power a build time option.
###### Changes in version 0.2.1-6 #############################################
* Changed gcc.mk to allow overriding the -mfloat-abi and -mfpu switches.
###### Changes in version 0.2.1-5 #############################################
* Removed the CONSOLE_UART override in the config.mk files for BLE.
* Addressed an issue with the BLE scanning apps that was causing a hard fault.
......