Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ACPS (E-24)
P
public
ahoi
firmware
Commits
1d654e77
Commit
1d654e77
authored
Jul 15, 2021
by
Bernd-Christian Renner
Browse files
clean-up
parent
1c67958d
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
255 additions
and
293 deletions
+255
-293
src/agc.c
src/agc.c
+6
-5
src/freqsetup.h
src/freqsetup.h
+2
-2
src/hal/interface/hal_board.h
src/hal/interface/hal_board.h
+0
-13
src/hal/mcu/mcu_adda.c
src/hal/mcu/mcu_adda.c
+0
-1
src/hal/mcu/stm32f4-legacy/board_config.h
src/hal/mcu/stm32f4-legacy/board_config.h
+18
-30
src/hal/mcu/stm32f4/board_board.h
src/hal/mcu/stm32f4/board_board.h
+7
-1
src/hal/mcu/stm32f4/board_config.h
src/hal/mcu/stm32f4/board_config.h
+17
-21
src/hal/mcu/stm32f4/board_gpio.h
src/hal/mcu/stm32f4/board_gpio.h
+8
-23
src/hal/mcu/stm32f4/board_irq.h
src/hal/mcu/stm32f4/board_irq.h
+13
-2
src/hal/mcu/stm32f4/lib/src/ahoi/vectors_stm32f446xx.c
src/hal/mcu/stm32f4/lib/src/ahoi/vectors_stm32f446xx.c
+3
-3
src/hal/mcu/stm32f4/stm32f4_board.c
src/hal/mcu/stm32f4/stm32f4_board.c
+1
-1
src/hal/mcu/stm32f4/stm32f4_gpio.c
src/hal/mcu/stm32f4/stm32f4_gpio.c
+26
-24
src/hal/mcu/stm32f4/stm32f4_spi.c
src/hal/mcu/stm32f4/stm32f4_spi.c
+24
-24
src/lut/nonos
src/lut/nonos
+1
-1
src/main.c
src/main.c
+129
-142
No files found.
src/agc.c
View file @
1d654e77
...
...
@@ -186,7 +186,7 @@ agc_setGain(void)
void
agc_init
(
bool
en
)
{
// enable
?
//
store
enable
state
enabled
=
en
;
if
(
enabled
)
{
led_on
(
LED_AGC
);
...
...
@@ -216,8 +216,8 @@ agc_enable(void)
void
agc_disable
(
void
)
{
led_off
(
LED_AGC
);
enabled
=
false
;
led_off
(
LED_AGC
);
}
...
...
@@ -228,12 +228,12 @@ agc_restore(void)
// make sure that previously set gain is set correctly
// however, avoid extremes (min or max): if anything in the lower
// layer is wrong, this may lead to a lock-out (we assume at least
// three levels
// three levels
)
if
(
enabled
)
{
if
(
gainLvl
==
0
)
{
gainLvl
++
;
gainLvl
=
1
;
}
else
if
(
gainLvl
>=
NUM_GAIN_LEVELS
-
1
)
{
gainLvl
--
;
gainLvl
=
NUM_GAIN_LEVELS
-
2
;
}
agc_setGain
();
}
...
...
@@ -316,6 +316,7 @@ agc_checkAction(sample_time_t ticks)
}
void
agc_processSample
(
fp16_t
sample
,
sample_time_t
ticks
)
{
...
...
src/freqsetup.h
View file @
1d654e77
...
...
@@ -133,8 +133,8 @@ enum {
#define FREQ_IDX(n) (n)
#define FREQ_LIST_NUM 49
#define SAMPLES_PER_SYMBOL_MASK (SAMPLES_PER_SYMBOL-1)
const
fp16_t
*
const
FREQ_LIST
[
FREQ_LIST_NUM
];
const
fp16_t
*
const
FREQ_TXLIST
[
FREQ_LIST_NUM
];
extern
const
fp16_t
*
const
FREQ_LIST
[
FREQ_LIST_NUM
];
extern
const
fp16_t
*
const
FREQ_TXLIST
[
FREQ_LIST_NUM
];
// sync/preamble length setup
...
...
src/hal/interface/hal_board.h
View file @
1d654e77
...
...
@@ -38,19 +38,6 @@
#ifndef HAL_BOARD_H_
#define HAL_BOARD_H_
// needs to define
//
// static inline void
// __attribute__((__always_inline__))
// board_enterPowerSaveMode(void) {
// ...
// }
//
// static inline void
// __attribute__((__always_inline__))
// board_restMCU(void) {
// }
#include "mcu_board.h"
#endif
src/hal/mcu/mcu_adda.c
View file @
1d654e77
...
...
@@ -425,7 +425,6 @@ ISR_ADC(void)
// read from ADC
// note that this starts the conversion and sample will be available next time
spi_receive
((
void
*
)
&
SPI_RX_Buf
);
}
...
...
src/hal/mcu/stm32f4-legacy/board_config.h
View file @
1d654e77
/**
* Copyright 2016-201
9
* Copyright 2016-20
2
1
*
* Timo Kortbrae,
* Jan Heitmann,
...
...
@@ -36,13 +36,6 @@
*/
/*! \file board_config.h
\brief Configuration file for the stm32f4 project
This file can be used to add application and target specific configurations to the project by adding defines and include paths.
All hal interfaces include this header file.
*/
#ifndef BOARD_CONFIG_H_
#define BOARD_CONFIG_H_
...
...
@@ -51,6 +44,7 @@
#define INTERRUPT //!< The INTERRUPT define is not needed for the stm32f4 project
#define CONST
// adc/dac spi channels
/**
* \defgroup spi_channels adc/dac spi channels
...
...
@@ -61,6 +55,7 @@
#define NO_CHANNEL 2
/** @} */
/**
* \defgroup timer_config configuration for adc/dac and uart timer
* @{
...
...
@@ -95,38 +90,31 @@
* @{
*/
#ifdef PIN_DEBUG
//#define DEBUG_GPIO_PORT GPIOC
#define DEBUG_PIN_0 MODEM_GPIO_10
#define DEBUG_PIN_1 MODEM_GPIO_1
#define DEBUG_PIN_2 MODEM_GPIO_2
#define DEBUG_PIN_3 MODEM_GPIO_3
#define DEBUG_PIN_4 MODEM_GPIO_4
#define DEBUG_PIN_5 MODEM_GPIO_5
#define DEBUG_PIN_6 MODEM_GPIO_6
#define DEBUG_PIN_7 MODEM_GPIO_7
#define DEBUG_PIN_8 MODEM_GPIO_8
#define DEBUG_PIN_9 MODEM_GPIO_9
# define DEBUG_PIN_0 MODEM_GPIO_10
# define DEBUG_PIN_1 MODEM_GPIO_1
# define DEBUG_PIN_2 MODEM_GPIO_2
# define DEBUG_PIN_3 MODEM_GPIO_3
# define DEBUG_PIN_4 MODEM_GPIO_4
# define DEBUG_PIN_5 MODEM_GPIO_5
# define DEBUG_PIN_6 MODEM_GPIO_6
# define DEBUG_PIN_7 MODEM_GPIO_7
# define DEBUG_PIN_8 MODEM_GPIO_8
# define DEBUG_PIN_9 MODEM_GPIO_9
#endif
/** @} */
/**
* \defgroup gpio_pins STM32F4 GPIO Pins
* @{
*/
// #define ... (gpio_t){GPIOC, GPIO_PIN_11} // currently unused
#define TXEN_PIN (gpio_t){GPIOA, GPIO_PIN_1}
#define RXEN_PIN (gpio_t){GPIOA, GPIO_PIN_0}
#define TXEN_PIN (gpio_t){GPIOA, GPIO_PIN_1}
#define TXRX_SW_PIN (gpio_t){GPIOA, GPIO_PIN_2}
#define MODEM_EN_PIN (gpio_t){GPIOA, GPIO_PIN_8}
/** @} */
/**
* \defgroup modem_sleep_pin STM32F4 Sleep
* @{
*/
// #define SLEEP_PIN (gpio_t){GPIOA, GPIO_PIN_8}
// #define SLEEP_EXTI_IRQn EXTI9_5_IRQn
// #define SLEEP_EXTI_IRQHandler EXTI9_5_IRQHandler
/**
* \defgroup leds STM32F4 Led to GPIO mapping
...
...
@@ -229,7 +217,7 @@ enum {
};
// flash setup for modem config
// flash setup for modem config
(the legacy board has no EEPROM IC)
#define MODEM_CONFIG_FLASH_SECTOR FLASH_SECTOR_7
#define MODEM_CONFIG_ADDR_START 0x08060000
/* 128kb sector :-( */
#define MODEM_CONFIG_ADDR_END 0x0807FFFF
...
...
src/hal/mcu/stm32f4/board_board.h
View file @
1d654e77
/**
* Copyright 2016-20
18
* Copyright 2016-20
20
*
* Timo Kortbrae,
* Jan Heitmann,
...
...
@@ -50,9 +50,15 @@
static
inline
void
__attribute__
((
__always_inline__
))
board_enterPowerSaveMode
(
void
)
{
// sleep mode (not deep sleep aka stop)
CLEAR_BIT
(
SCB
->
SCR
,
((
uint32_t
)
SCB_SCR_SLEEPDEEP_Msk
));
__WFI
();
// Sleep and wait for next interrupt
//HAL_PWR_EnterSTANDBYMode();
}
/**
* @brief Resets the MCU
*
...
...
src/hal/mcu/stm32f4/board_config.h
View file @
1d654e77
/**
* Copyright 2016-201
9
* Copyright 2016-20
2
1
*
* Timo Kortbrae,
* Jan Heitmann,
...
...
@@ -44,6 +44,7 @@
#define INTERRUPT //!< The INTERRUPT define is not needed for the stm32f4 project
#define CONST
// adc/dac spi channels
/**
* \defgroup spi_channels adc/dac spi channels
...
...
@@ -54,6 +55,7 @@
#define NO_CHANNEL 2
/** @} */
/**
* \defgroup timer_config configuration for adc/dac and uart timer
* @{
...
...
@@ -88,37 +90,31 @@
* @{
*/
#ifdef PIN_DEBUG
//#define DEBUG_GPIO_PORT GPIOC
#define DEBUG_PIN_0 MODEM_GPIO_10
#define DEBUG_PIN_1 MODEM_GPIO_1
#define DEBUG_PIN_2 MODEM_GPIO_2
#define DEBUG_PIN_3 MODEM_GPIO_3
#define DEBUG_PIN_4 MODEM_GPIO_4
#define DEBUG_PIN_5 MODEM_GPIO_5
#define DEBUG_PIN_6 MODEM_GPIO_6
#define DEBUG_PIN_7 MODEM_GPIO_7
#define DEBUG_PIN_8 MODEM_GPIO_8
#define DEBUG_PIN_9 MODEM_GPIO_9
# define DEBUG_PIN_0 MODEM_GPIO_10
# define DEBUG_PIN_1 MODEM_GPIO_1
# define DEBUG_PIN_2 MODEM_GPIO_2
# define DEBUG_PIN_3 MODEM_GPIO_3
# define DEBUG_PIN_4 MODEM_GPIO_4
# define DEBUG_PIN_5 MODEM_GPIO_5
# define DEBUG_PIN_6 MODEM_GPIO_6
# define DEBUG_PIN_7 MODEM_GPIO_7
# define DEBUG_PIN_8 MODEM_GPIO_8
# define DEBUG_PIN_9 MODEM_GPIO_9
#endif
/** @} */
/**
* \defgroup gpio_pins STM32F4 GPIO Pins
* @{
*/
// #define ... (gpio_t){GPIOC, GPIO_PIN_11} // currently unused
#define TXEN_PIN (gpio_t){GPIOA, GPIO_PIN_1}
#define RXEN_PIN (gpio_t){GPIOA, GPIO_PIN_0}
#define TXEN_PIN (gpio_t){GPIOA, GPIO_PIN_1}
#define TXRX_SW_PIN (gpio_t){GPIOA, GPIO_PIN_2}
/** @} */
/**
* \defgroup modem_sleep_pin STM32F4 Sleep
* @{
*/
// #define SLEEP_PIN (gpio_t){GPIOA, GPIO_PIN_8}
// #define SLEEP_EXTI_IRQn EXTI9_5_IRQn
// #define SLEEP_EXTI_IRQHandler EXTI9_5_IRQHandler
/**
* \defgroup leds STM32F4 Led to GPIO mapping
...
...
src/hal/mcu/stm32f4/board_gpio.h
View file @
1d654e77
/**
* Copyright 2016-201
9
* Copyright 2016-20
2
1
*
* Timo Kortbrae,
* Jan Heitmann,
...
...
@@ -43,8 +43,9 @@
#include <stdbool.h>
// TODO define "NONE" (rather than using magic 0xFF everywhere)
// TODO use pointers (call by reference rather than call by value)
#define GPIO_NA ((gpio_t){0})
/* (pin0 = 1, pin1 = 2, ..., @see stm32f4xx_hal_gpio.h) */
typedef
struct
{
GPIO_TypeDef
*
port
;
uint16_t
pin
;
...
...
@@ -69,9 +70,6 @@ void gpio_init(void);
static
inline
bool
__attribute__
((
__always_inline__
))
gpio_read
(
gpio_t
gpio
)
{
if
(
gpio
.
pin
==
0xFF
)
{
return
false
;
}
return
(
gpio
.
port
->
IDR
&
gpio
.
pin
)
!=
0
;
}
...
...
@@ -85,9 +83,6 @@ gpio_read(gpio_t gpio) {
static
inline
void
__attribute__
((
__always_inline__
))
gpio_set
(
gpio_t
gpio
)
{
if
(
gpio
.
pin
==
0xFF
)
{
return
;
}
gpio
.
port
->
BSRR
=
gpio
.
pin
;
}
...
...
@@ -101,25 +96,20 @@ gpio_set(gpio_t gpio) {
static
inline
void
__attribute__
((
__always_inline__
))
gpio_clear
(
gpio_t
gpio
)
{
if
(
gpio
.
pin
==
0xFF
)
{
return
;
}
gpio
.
port
->
BSRR
=
gpio
.
pin
<<
16
;
//gpio.port->BRR = gpio.pin;
}
/**
* @brief Toggles the gpio output
*
* @param pin: specifies the pin that is
reset
.
* @param pin: specifies the pin that is
toggled
.
* This parameter has to be one of the @link gpio_pins gpio pins listed here@endlink
* @retval None
*/
static
inline
void
__attribute__
((
__always_inline__
))
gpio_toggle
(
gpio_t
gpio
)
{
if
(
gpio
.
pin
==
0xFF
)
{
return
;
}
gpio
.
port
->
BSRR
=
(
gpio
.
port
->
ODR
^
gpio
.
pin
)
|
(
gpio
.
pin
<<
16
);
}
...
...
@@ -133,8 +123,6 @@ gpio_toggle(gpio_t gpio) {
static
inline
void
__attribute__
((
__always_inline__
))
led_on
(
gpio_t
gpio
)
{
if
(
gpio
.
pin
==
0xFF
)
return
;
gpio
.
port
->
BSRR
=
gpio
.
pin
;
}
...
...
@@ -148,23 +136,20 @@ led_on(gpio_t gpio) {
static
inline
void
__attribute__
((
__always_inline__
))
led_off
(
gpio_t
gpio
)
{
if
(
gpio
.
pin
==
0xFF
)
return
;
gpio
.
port
->
BSRR
=
gpio
.
pin
<<
16
;
//gpio.port->BRR = gpio.pin;
}
/**
* @brief Toggles the gpio output
*
* @param pin: specifies the pin that is
reset
.
* @param pin: specifies the pin that is
toggled
.
* This parameter has to be one of the @link gpio_pins gpio pins listed here@endlink
* @retval None
*/
static
inline
void
__attribute__
((
__always_inline__
))
led_toggle
(
gpio_t
gpio
)
{
if
(
gpio
.
pin
==
0xFF
)
return
;
gpio
.
port
->
BSRR
=
(
gpio
.
port
->
ODR
^
gpio
.
pin
)
|
(
gpio
.
pin
<<
16
);
}
...
...
src/hal/mcu/stm32f4/board_irq.h
View file @
1d654e77
...
...
@@ -41,6 +41,7 @@
#define BOARD_IRQ_H_
#include <stm32f4xx_hal.h>
#include <stdbool.h>
/**
* @brief enable all interrupts
...
...
@@ -49,8 +50,9 @@
*/
static
inline
void
__attribute__
((
__always_inline__
))
irq_enable_global
(
void
)
{
__enable_irq
();
irq_enable_global
(
void
)
{
__enable_irq
();
}
/**
...
...
@@ -64,4 +66,13 @@ irq_disable_global(void) {
__disable_irq
();
}
static
inline
bool
__attribute__
((
__always_inline__
))
irq_getState
(
void
)
{
/* Returns 0 if they are enabled, or non-zero if disabled */
return
0
==
__get_PRIMASK
();
}
#endif
src/hal/mcu/stm32f4/lib/src/ahoi/vectors_stm32f446xx.c
View file @
1d654e77
...
...
@@ -653,9 +653,9 @@ __attribute__((section(".after_vectors"),weak))
void
SysTick_Handler
(
void
)
{
// default implementation in case this gets activated somewhere
// deep in STM's HAL and stalls the program as a consequence,
// (@see Default_Handler above)
// default implementation in case this gets activated somewhere
// deep in STM's HAL and stalls the program as a consequence,
// (@see Default_Handler above)
}
...
...
src/hal/mcu/stm32f4/stm32f4_board.c
View file @
1d654e77
/**
* Copyright 2016-201
9
* Copyright 2016-20
2
1
*
* Timo Kortbrae,
* Jan Heitmann,
...
...
src/hal/mcu/stm32f4/stm32f4_gpio.c
View file @
1d654e77
...
...
@@ -59,61 +59,62 @@
*
* @retval None
*/
void
gpio_init
(
void
)
{
void
gpio_init
(
void
)
{
__HAL_RCC_GPIOA_CLK_ENABLE
();
__HAL_RCC_GPIOB_CLK_ENABLE
();
__HAL_RCC_GPIOC_CLK_ENABLE
();
GPIO_InitTypeDef
GPIO_InitStruct
;
//>>>>>>> FIXME move partly (?) to txamp implementation
GPIO_InitStruct
.
Pin
=
RXEN_PIN
.
pin
;
//
// internal switching, all same setup
//
GPIO_InitStruct
.
Mode
=
GPIO_MODE_OUTPUT_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_NOPULL
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_
MEDIUM
;
//<- medium should be fast enough GPIO_SPEED_FAST
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_
LOW
;
//GPIO_InitStruct.Alternate = 0;
// RXEN
GPIO_InitStruct
.
Pin
=
RXEN_PIN
.
pin
;
HAL_GPIO_Init
(
RXEN_PIN
.
port
,
&
GPIO_InitStruct
);
gpio_clear
(
RXEN_PIN
);
GPIO_InitStruct
.
Pin
=
TXEN_PIN
.
pin
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_OUTPUT_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_NOPULL
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_MEDIUM
;
//<- medium should be fast enough GPIO_SPEED_FAST;
//GPIO_InitStruct.Alternate = 0;
// TXEN
GPIO_InitStruct
.
Pin
=
TXEN_PIN
.
pin
;
HAL_GPIO_Init
(
TXEN_PIN
.
port
,
&
GPIO_InitStruct
);
gpio_
set
(
TXEN_PIN
);
gpio_
clear
(
TXEN_PIN
);
GPIO_InitStruct
.
Pin
=
TXRX_SW_PIN
.
pin
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_OUTPUT_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_NOPULL
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_MEDIUM
;
//<- medium should be fast enough GPIO_SPEED_FAST;
//GPIO_InitStruct.Alternate = 0;
// TXRX_SW
GPIO_InitStruct
.
Pin
=
TXRX_SW_PIN
.
pin
;
HAL_GPIO_Init
(
TXRX_SW_PIN
.
port
,
&
GPIO_InitStruct
);
gpio_clear
(
TXRX_SW_PIN
);
//<<<<<<< FIXME move partly (?) to txamp implementation
//
// LEDs, all same setup
//
GPIO_InitStruct
.
Mode
=
GPIO_MODE_OUTPUT_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_NOPULL
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_
MEDIUM
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_
LOW
;
//GPIO_InitStruct.Alternate = 0;
GPIO_InitStruct
.
Pin
=
LED_1
.
pin
;
GPIO_InitStruct
.
Pin
=
LED_1
.
pin
;
HAL_GPIO_Init
(
LED_1
.
port
,
&
GPIO_InitStruct
);
led_off
(
LED_1
);
GPIO_InitStruct
.
Pin
=
LED_2
.
pin
;
GPIO_InitStruct
.
Pin
=
LED_2
.
pin
;
HAL_GPIO_Init
(
LED_2
.
port
,
&
GPIO_InitStruct
);
led_off
(
LED_2
);
GPIO_InitStruct
.
Pin
=
LED_3
.
pin
;
GPIO_InitStruct
.
Pin
=
LED_3
.
pin
;
HAL_GPIO_Init
(
LED_3
.
port
,
&
GPIO_InitStruct
);
led_off
(
LED_3
);
GPIO_InitStruct
.
Pin
=
LED_4
.
pin
;
GPIO_InitStruct
.
Pin
=
LED_4
.
pin
;
HAL_GPIO_Init
(
LED_4
.
port
,
&
GPIO_InitStruct
);
led_off
(
LED_4
);
GPIO_InitStruct
.
Pin
=
LED_5
.
pin
;
GPIO_InitStruct
.
Pin
=
LED_5
.
pin
;
HAL_GPIO_Init
(
LED_5
.
port
,
&
GPIO_InitStruct
);
led_off
(
LED_5
);
}
...
...
@@ -125,7 +126,8 @@ void gpio_init(void) {
*
* @retval None
*/
void
pin_debug_init
(
void
)
{
void
pin_debug_init
(
void
)
{
__HAL_RCC_GPIOC_CLK_ENABLE
();
GPIO_InitTypeDef
GPIO_InitStruct
;
...
...
@@ -165,6 +167,6 @@ void pin_debug_init(void) {
pin_debug_clear
(
DEBUG_PIN_7
);
pin_debug_clear
(
DEBUG_PIN_8
);
pin_debug_clear
(
DEBUG_PIN_9
);
}
}
#endif
src/hal/mcu/stm32f4/stm32f4_spi.c
View file @
1d654e77
/**
* Copyright 2016-201
9
* Copyright 2016-20
2
1
*
* Timo Kortbrae,
* Jan Heitmann,
...
...
@@ -87,9 +87,9 @@ __attribute__((__always_inline__))
static
inline
void
spi_chipDeSelect
(
void
)
{
gpio_set
((
gpio_t
){
CFG_SPI_CS0_GPIO_PORT
,
CFG_SPI_CS0_PIN
});
gpio_set
((
gpio_t
){
CFG_SPI_CS1_GPIO_PORT
,
CFG_SPI_CS1_PIN
});
//gpio_set((gpio_t){CFG_SPI_CS2_GPIO_PORT, CFG_SPI_CS2_PIN}); // Not needed atm
gpio_set
((
gpio_t
){
CFG_SPI_CS0_GPIO_PORT
,
CFG_SPI_CS0_PIN
});
gpio_set
((
gpio_t
){
CFG_SPI_CS1_GPIO_PORT
,
CFG_SPI_CS1_PIN
});
//gpio_set((gpio_t){CFG_SPI_CS2_GPIO_PORT, CFG_SPI_CS2_PIN}); // Not needed atm
}
...
...
@@ -99,13 +99,13 @@ __attribute__((__always_inline__))
static
inline
void
spi_TxRx
(
uint8_t
*
rxPtr
,
uint8_t
*
txPtr
)
{
spiHandle
.
pTxBuffPtr
=
(
uint8_t
*
)
txPtr
;
spiHandle
.
pRxBuffPtr
=
(
uint8_t
*
)
rxPtr
;
while
((
spiHandle
.
Instance
->
SR
&
SPI_FLAG_TXE
)
==
RESET
);
spiHandle
.
Instance
->
DR
=
*
((
uint16_t
*
)
spiHandle
.
pTxBuffPtr
);
__HAL_SPI_CLEAR_OVRFLAG
(
&
spiHandle
);
__HAL_SPI_ENABLE_IT
(
&
spiHandle
,
(
SPI_IT_RXNE
));
__HAL_SPI_ENABLE
(
&
spiHandle
);
spiHandle
.
pTxBuffPtr
=
(
uint8_t
*
)
txPtr
;
spiHandle
.
pRxBuffPtr
=
(
uint8_t
*
)
rxPtr
;
while
((
spiHandle
.
Instance
->
SR
&
SPI_FLAG_TXE
)
==
RESET
);
spiHandle
.
Instance
->
DR
=
*
((
uint16_t
*
)
spiHandle
.
pTxBuffPtr
);
__HAL_SPI_CLEAR_OVRFLAG
(
&
spiHandle
);
__HAL_SPI_ENABLE_IT
(
&
spiHandle
,
(
SPI_IT_RXNE
));
__HAL_SPI_ENABLE
(
&
spiHandle
);
}
...
...
@@ -113,12 +113,12 @@ __attribute__((used))
void
CFG_SPI_IRQHandler
(
void
)
{
//pin_debug_set(DEBUG_PIN_8);
*
((
uint16_t
*
)
spiHandle
.
pRxBuffPtr
)
=
spiHandle
.
Instance
->
DR
;
__HAL_SPI_DISABLE_IT
(
&
spiHandle
,
SPI_IT_RXNE
);
spi_chipDeSelect
();
//__HAL_SPI_DISABLE(&spiHandle);
//pin_debug_clear(DEBUG_PIN_8);
//pin_debug_set(DEBUG_PIN_8);
*
((
uint16_t
*
)
spiHandle
.
pRxBuffPtr
)
=
spiHandle
.
Instance
->
DR
;
__HAL_SPI_DISABLE_IT
(
&
spiHandle
,
SPI_IT_RXNE
);
spi_chipDeSelect
();
//__HAL_SPI_DISABLE(&spiHandle);
//pin_debug_clear(DEBUG_PIN_8);
}
...
...
@@ -172,25 +172,25 @@ spi_clockMode(uint8_t mode)
void
spi_chipSelect
(
uint16_t
chip
)
{
if
(
chip
==
ADC_CHANNEL
)
{
gpio_clear
((
gpio_t
){
CFG_SPI_CS0_GPIO_PORT
,
CFG_SPI_CS0_PIN
});
}
else
if
(
chip
==
DAC_CHANNEL
)
{
gpio_clear
((
gpio_t
){
CFG_SPI_CS1_GPIO_PORT
,
CFG_SPI_CS1_PIN
});
}
if
(
chip
==
ADC_CHANNEL
)
{
gpio_clear
((
gpio_t
){
CFG_SPI_CS0_GPIO_PORT
,
CFG_SPI_CS0_PIN
});
}
else
if
(
chip
==
DAC_CHANNEL
)
{
gpio_clear
((
gpio_t
){
CFG_SPI_CS1_GPIO_PORT
,
CFG_SPI_CS1_PIN
});
}
}
void
spi_receive
(
void
*
rxPtr
)
{
spi_TxRx
(
rxPtr
,
(
void
*
)
&
SPI_DUMMY
);
spi_TxRx
(
rxPtr
,
(
void
*
)
&
SPI_DUMMY
);
}
void
spi_transmit
(
void
*
txPtr
)
{
spi_TxRx
((
void
*
)
&
SPI_RX_Buf
,
txPtr
);
spi_TxRx
((
void
*
)
&
SPI_RX_Buf
,
txPtr
);
}
...
...
nonos
@
3046c75c
Compare
e1dad976
...
3046c75c
Subproject commit
e1dad976ae340ef9ce08cee5ae8c757b2d0c4d7a
Subproject commit
3046c75c4218af6ffca8ab186b42021c9cb5dc96
src/main.c
View file @
1d654e77
...
...
@@ -116,6 +116,7 @@
#include "aci_sniffmode.h"