make sound work
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/* f_util.h
|
||||
Copyright 2021 Carl John Kugler III
|
||||
|
||||
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.
|
||||
*/
|
||||
#pragma once
|
||||
#include "ff.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
const char *FRESULT_str(FRESULT i);
|
||||
FRESULT delete_node (
|
||||
TCHAR* path, /* Path name buffer with the sub-directory to delete */
|
||||
UINT sz_buff, /* Size of path name buffer (items) */
|
||||
FILINFO* fno /* Name read buffer */
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,77 @@
|
||||
/* ff_stdio.h
|
||||
Copyright 2021 Carl John Kugler III
|
||||
|
||||
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.
|
||||
*/
|
||||
// For compatibility with FreeRTOS+FAT API
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
//
|
||||
#include "ff.h"
|
||||
//
|
||||
#include "my_debug.h"
|
||||
|
||||
#define BaseType_t int
|
||||
#define FF_FILE FIL
|
||||
|
||||
#define ff_rewind f_rewind
|
||||
#define pvPortMalloc malloc
|
||||
#define vPortFree free
|
||||
#define ffconfigMAX_FILENAME 250
|
||||
#define configASSERT myASSERT
|
||||
#define FF_PRINTF printf
|
||||
#define pdFREERTOS_ERRNO_NONE 0
|
||||
#define FF_EOF (-1)
|
||||
#define FF_SEEK_SET 0
|
||||
#define FF_SEEK_CUR 1
|
||||
#define FF_SEEK_END 2
|
||||
#define pdFALSE 0
|
||||
#define pdTRUE 1
|
||||
#define ff_filelength f_size
|
||||
#define ff_feof f_eof
|
||||
|
||||
typedef struct FF_STAT {
|
||||
uint32_t st_size; /* Size of the object in number of bytes. */
|
||||
// uint16_t st_mode; /* The mode (attribute bits) of this
|
||||
// file or directory. */
|
||||
} FF_Stat_t;
|
||||
|
||||
typedef struct {
|
||||
DIR dir;
|
||||
FILINFO fileinfo;
|
||||
const char *pcFileName;
|
||||
uint32_t ulFileSize;
|
||||
//uint8_t ucAttributes;
|
||||
} FF_FindData_t;
|
||||
|
||||
FF_FILE *ff_fopen(const char *pcFile, const char *pcMode);
|
||||
int ff_fclose(FF_FILE *pxStream);
|
||||
int ff_stat(const char *pcFileName, FF_Stat_t *pxStatBuffer);
|
||||
size_t ff_fwrite(const void *pvBuffer, size_t xSize, size_t xItems,
|
||||
FF_FILE *pxStream);
|
||||
size_t ff_fread(void *pvBuffer, size_t xSize, size_t xItems, FF_FILE *pxStream);
|
||||
int ff_chdir(const char *pcDirectoryName);
|
||||
char *ff_getcwd(char *pcBuffer, size_t xBufferLength);
|
||||
int ff_mkdir(const char *pcPath);
|
||||
int ff_fputc(int iChar, FF_FILE *pxStream);
|
||||
int ff_fgetc(FF_FILE *pxStream);
|
||||
int ff_rmdir(const char *pcDirectory);
|
||||
int ff_remove(const char *pcPath);
|
||||
long ff_ftell(FF_FILE *pxStream);
|
||||
int ff_fseek(FF_FILE *pxStream, int iOffset, int iWhence);
|
||||
int ff_findfirst(const char *pcDirectory, FF_FindData_t *pxFindData);
|
||||
int ff_findnext( FF_FindData_t *pxFindData );
|
||||
FF_FILE *ff_truncate( const char * pcFileName, long lTruncateSize );
|
||||
int ff_seteof( FF_FILE *pxStream );
|
||||
int ff_rename( const char *pcOldName, const char *pcNewName, int bDeleteIfExists );
|
||||
char *ff_fgets(char *pcBuffer, size_t xCount, FF_FILE *pxStream);
|
||||
@@ -0,0 +1,39 @@
|
||||
/* my_debug.h
|
||||
Copyright 2021 Carl John Kugler III
|
||||
|
||||
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.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void my_printf(const char *pcFormat, ...) __attribute__((format(__printf__, 1, 2)));
|
||||
|
||||
void my_assert_func(const char *file, int line, const char *func,
|
||||
const char *pred);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//#if defined(DEBUG) && !defined(NDEBUG)
|
||||
#define DBG_PRINTF my_printf
|
||||
//#else
|
||||
//#define DBG_PRINTF(fmt, args...) /* Don't do anything in release builds*/
|
||||
//#endif
|
||||
|
||||
#define myASSERT(__e) \
|
||||
((__e) ? (void)0 : my_assert_func(__FILE__, __LINE__, __func__, #__e))
|
||||
@@ -0,0 +1,24 @@
|
||||
/* rtc.h
|
||||
Copyright 2021 Carl John Kugler III
|
||||
|
||||
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.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void time_init();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,68 @@
|
||||
/* util.h
|
||||
Copyright 2021 Carl John Kugler III
|
||||
|
||||
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.
|
||||
*/
|
||||
#ifndef _UTIL_H_
|
||||
#define _UTIL_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hardware/structs/scb.h"
|
||||
|
||||
// works with negative index
|
||||
static inline int wrap_ix(int index, int n)
|
||||
{
|
||||
return ((index % n) + n) % n;
|
||||
}
|
||||
|
||||
__attribute__((always_inline)) static inline uint32_t calculate_checksum(uint32_t const *p, size_t const size){
|
||||
uint32_t checksum = 0;
|
||||
for (uint32_t i = 0; i < (size/sizeof(uint32_t))-1; i++){
|
||||
checksum ^= *p;
|
||||
p++;
|
||||
}
|
||||
return checksum;
|
||||
}
|
||||
|
||||
|
||||
// from Google Chromium's codebase:
|
||||
#ifndef COUNT_OF
|
||||
#define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
|
||||
#endif
|
||||
|
||||
__attribute__((always_inline)) static inline void __DSB(void) {
|
||||
__asm volatile("dsb 0xF" ::: "memory");
|
||||
}
|
||||
|
||||
// Patterned after CMSIS NVIC_SystemReset
|
||||
__attribute__((__noreturn__)) static inline void system_reset() {
|
||||
__DSB(); /* Ensure all outstanding memory accesses included
|
||||
buffered write are completed before reset */
|
||||
scb_hw->aircr = ((0x5FAUL << 16U) | (1UL << 2U));
|
||||
__DSB(); /* Ensure completion of memory access */
|
||||
for (;;) {
|
||||
__asm volatile("nop");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Disable IRQ Interrupts
|
||||
\details Disables IRQ interrupts by setting the I-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
__attribute__((always_inline)) static inline void __disable_irq(void) {
|
||||
__asm volatile("cpsid i" : : : "memory");
|
||||
}
|
||||
|
||||
#endif
|
||||
/* [] END OF FILE */
|
||||
Reference in New Issue
Block a user