Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
AIM65 committed May 24, 2020
1 parent 0c39b72 commit 0859766
Show file tree
Hide file tree
Showing 38 changed files with 6,724 additions and 3 deletions.
66 changes: 66 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#ST CubeIDE & Cube MX files
*.cproject
*.mxproject
*.project
*.lauch
*.ld

#ST Cube IDE files
/debug
/release
/Drivers
/.settings


# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
58 changes: 58 additions & 0 deletions Core/Inc/adc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
******************************************************************************
* File Name : ADC.h
* Description : This file provides code for the configuration
* of the ADC instances.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __adc_H
#define __adc_H
#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

extern ADC_HandleTypeDef hadc;

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

void MX_ADC_Init(void);

/* USER CODE BEGIN Prototypes */

/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif
#endif /*__ adc_H */

/**
* @}
*/

/**
* @}
*/

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
176 changes: 176 additions & 0 deletions Core/Inc/amp_board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
/*
* *****************************************************************************
* NeatAmp software
*
* amp_board.h
*
* Author : AIM65
* Date : 6 Avr 2020
* (c) AIM65
*
* *****************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef AMP_BOARD_H_
#define AMP_BOARD_H_

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* Exported types ------------------------------------------------------------*/
enum DataType_en
{
Byte,
HalfWord,
Word,
};

//Status of encoder : still/left/right, updated by polling
typedef enum
{
still,
left,
right,
}
ENC_event_td;

typedef struct
{
bool nochange;
uint32_t crc;
}chk_res_td;

enum Time_cmd_en
{
Get_Tick,
Launch_ctr1,
Launch_ctr2,
Launch_ctr3,
Launch_tmr1,
Launch_tmr2,
Launch_tmr3,
Get_ctr1,
Get_ctr2,
Get_ctr3,
Get_tmr1,
Get_tmr2,
Get_tmr3,
};

//Typedef to handle parameters of two boards : master/slave
typedef struct
{
uint16_t m_volume;
uint16_t m_balance;
uint8_t m_stereo;
uint8_t m_lrswap;
uint8_t m_config;
uint8_t m_filterset;
uint16_t m_Param1;
uint16_t m_Param2;
uint16_t m_Param3;
uint16_t m_Param4;
uint16_t m_Param5;
uint16_t m_Param6;
uint16_t m_Param7;
uint16_t m_Param8;
uint16_t m_Param9;
uint16_t m_Param10;
uint16_t m_Param11;
uint16_t m_Param12;
uint16_t s_volume;
uint16_t s_balance;
uint8_t s_stereo;
uint8_t s_lrswap;
uint8_t s_config;
uint8_t s_filterset;
uint16_t s_Param1;
uint16_t s_Param2;
uint16_t s_Param3;
uint16_t s_Param4;
uint16_t s_Param5;
uint16_t s_Param6;
uint16_t s_Param7;
uint16_t s_Param8;
uint16_t s_Param9;
uint16_t s_Param10;
uint16_t s_Param11;
uint16_t s_Param12;
}board_user_param_td; //size is 64 bytes


/* Exported constants --------------------------------------------------------*/
//Amp define
#define BAL_CENTER 20
#define BAL_RIGHT (BAL_CENTER+BAL_CENTER)
#define BAL_LEFT (BAL_CENTER-BAL_CENTER)
#define DEFAULT_VOL 10

#define NOCONFIG 0xFF

#define PSU_FAULT_RST_DLY 3000 // 3s delay to reset integrator
#define PSU_FAULT_LONG_DLY 1000 // integrator will start with 1s minimun period
#define PSU_FAULT_SHRT_DLY 100 // integrator will use 100ms period

//STM32 MSP define
#define I2CXTIMEOUT 20 //20ms

#define TIMERSIZE 0xFFFF //Function TimeCounter uses 16bits counters

#define STM32_VDDA 3.3f // ADC Vref
#define STM32ADC_Resol 4096
#define STM32ANALOGBITS 12
#define STM32ANALOGMID (STM32ADC_Resol/2-1)
#define STM32_VREFINTCAL *(uint16_t*)0x1FFFF7BA //factory recorded value

#define MASK_LED 0x07
#define BLACK_LED 0
#define WHITE_LED 0x07
#define GREEN_LED 0x01
#define BLUE_LED 0x02
#define RED_LED 0x04


//TAS3251 define
#define TAS_BASEADDR0 0x94
#define TAS_BASEADDR1 0x96
#define CLIP_TRESHOLD 400 //maximum duration in ms of a CLIP_OTW pulse low to notify a clipping condition

//ATMEL/MICROCHIP AT24C256B define
#define EEPROM_BASEADDR 0xA0 //24C256 I2C base address
#define EEPROM_PAGE 512 //qty of pages
#define EEPROM_PAGESIZE 64
#define CHKSUMADDR (EEPROM_PAGESIZE*EEPROM_PAGE - 2) //two last byte on top of EEPROM memory space

/* Exported macro --------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */

void AMP_Init(void);

uint32_t Checksum_Calc(int new, uint8_t *pdata, uint32_t length);

void I2Cx_Error(void);
void GPIO_Int_On(uint32_t Pin);
void GPIO_Int_Off(uint32_t Pin);

void EEPROM_Init(void);
void EEPROM_Checksum(chk_res_td *result);
void EEPROM_Update_checksum(void);
void EEPROM_WR(uint16_t Addr, enum DataType_en Type, int Data);
void EEPROM_RD(uint16_t Addr, uint16_t nbyte, uint8_t* pdata);
void EEPROM_WR_Page(uint16_t Page, uint8_t* pdata);

ENC_event_td ENC_Manage(void);

void TAS_Init(void);
void TAS_On(void);
void TAS_Off(void);
void TAS_WR_reg(uint8_t* data);
uint8_t TAS_RD_reg(uint8_t book, uint8_t page, uint8_t reg);
void TAS_WR_Preset(uint8_t memory, uint8_t type);
void TAS_Get_Status (void);

uint32_t TimeCounter(enum Time_cmd_en Cmd, uint32_t duration);

#endif /* AMP_BOARD_H_ */
58 changes: 58 additions & 0 deletions Core/Inc/crc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
******************************************************************************
* File Name : CRC.h
* Description : This file provides code for the configuration
* of the CRC instances.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __crc_H
#define __crc_H
#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

extern CRC_HandleTypeDef hcrc;

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

void MX_CRC_Init(void);

/* USER CODE BEGIN Prototypes */

/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif
#endif /*__ crc_H */

/**
* @}
*/

/**
* @}
*/

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Loading

0 comments on commit 0859766

Please sign in to comment.