Skip to content

Commit

Permalink
hpm_sdk release v0.13.1
Browse files Browse the repository at this point in the history
Main changes since 0.13.0

- Changed:
  - Driver:I2S: update i2s drivers
  - middleware: lwip: optimize variable_name definition
  - samples: lwip: lwip_iperf: update readme files
  - samples: lwip: common: arch: add LWIP_MEM_SECTION declartion

- Fixed:
  - samples: multicore: BOOT_HEADER was missing in multicore core0 example
  - samples: jpeg: Fix encoding and decoding problem
  - samples: audio codec: wav decoder: fix 32bit wave file playback
  - I2S_DMA: fix wav channel not align problem
  - i2s_interrupt: fix I2S FIFO overflow
  - fix lack of interrupt claim for swi
  - driver: watchdog: overflow
  - Fix critical section logic issue in dma manager
  - Fix the core1 application debugging issue

Signed-off-by: Ryan QIAN <[email protected]>
  • Loading branch information
jhqian committed Aug 24, 2022
1 parent 948eda9 commit b6ff51c
Show file tree
Hide file tree
Showing 51 changed files with 450 additions and 248 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Change Log

## [0.13.1] - 2022-08-23:

Main changes since 0.13.0

### Changed:
- Driver:I2S: update i2s drivers
- middleware: lwip: optimize variable_name definition
- samples: lwip: lwip_iperf: update readme files
- samples: lwip: common: arch: add LWIP_MEM_SECTION declartion

### Fixed:
- samples: multicore: BOOT_HEADER was missing in multicore core0 example
- samples: jpeg: Fix encoding and decoding problem
- samples: audio codec: wav decoder: fix 32bit wave file playback
- I2S_DMA: fix wav channel not align problem
- i2s_interrupt: fix I2S FIFO overflow
- fix lack of interrupt claim for swi
- driver: watchdog: overflow
- Fix critical section logic issue in dma manager
- Fix the core1 application debugging issue

## [0.13.0] - 2022-07-31:

Main changes since 0.12.1
Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "")
SET(FLASH_XIP 0)
SET(FLASH_SDRAM_XIP 0)
SET(LINK_TO_FLASH 0)
SET(INCLUDE_BOOTHEADER 0)

if(NOT DEFINED INCLUDE_BOOTHEADER)
SET(INCLUDE_BOOTHEADER 0)
endif()
set(USE_PRESET_FLASH_LINKER 0)
string(FIND ${build_type} "flash_" found)
if(${found} GREATER_EQUAL 0)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_MAJOR = 0
VERSION_MINOR = 13
PATCHLEVEL = 0
PATCHLEVEL = 1
VERSION_TWEAK = 0
EXTRAVERSION = 0
4 changes: 1 addition & 3 deletions components/dma_manager/hpm_dma_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ static uint32_t dma_manager_enter_critical(void)

static void dma_manager_exit_critical(uint32_t level)
{
if ((level & CSR_MSTATUS_MIE_MASK) == 0) {
enable_global_irq(CSR_MSTATUS_MIE_MASK);
}
write_csr(CSR_MSTATUS, level);
}

/* See hpm_dma_manager.h for more details */
Expand Down
9 changes: 9 additions & 0 deletions components/dma_manager/hpm_dma_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ enum {

/**
* @brief DMA Channel Interrupt callback
*
* @param [in] DMA base address
* @param [in] channel DMA channel index
* @param [in/out] user_data User Data context
* @param [in] int_stat DMA interrupt status
* bit0 - DMA_CHANNEL_STATUS_ONGOING
* bit1 - DMA_CHANNEL_STATUS_ERROR
* bit2 - DMA_CHANNEL_STATUS_ABORT
* bit3 - DMA_CHANNEL_STATUS_TC
*/
typedef void (*hpm_dma_channel_callback_t)(DMA_Type *base, uint32_t channel, void *user_data, uint32_t int_stat);

Expand Down
9 changes: 9 additions & 0 deletions drivers/inc/hpm_i2s_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
#define I2S_CHANNEL_LENGTH_16_BITS (0U)
#define I2S_CHANNEL_LENGTH_32_BITS (1U)

/**
* @brief I2S stereo/mono channel
*/
enum {
i2s_mono_left = 0,
i2s_mono_right = 1,
i2s_stereo = 2,
};

/**
* @}
*/
Expand Down
11 changes: 7 additions & 4 deletions drivers/inc/hpm_i2s_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,26 @@
*/

/**
* @brief I2C IRQ mask
* @brief I2S IRQ mask
*/
#define I2S_IRQ_TX_FIFO_EMPTY I2S_CTRL_TXDNIE_MASK
#define I2S_IRQ_RX_FIFO_DATA_AVAILABLE I2S_CTRL_RXDAIE_MASK
#define I2S_IRQ_ERROR I2S_CTRL_ERRIE_MASK

/**
* @brief I2C data line
* @brief I2S data line
*/
#define I2S_DATA_LINE_0 (0U)
#define I2S_DATA_LINE_1 (1U)
#define I2S_DATA_LINE_2 (2U)
#define I2S_DATA_LINE_3 (3U)
#define I2S_DATA_LINE_MAX I2S_DATA_LINE_3

/* i2s channel slot mask */
#define I2S_CHANNEL_SLOT_MASK(x) ((1U << (x)) & I2S_RXDSLOT_EN_MASK)

/**
* @brief I2C config
* @brief I2S config
*/
typedef struct i2s_config {
bool invert_mclk_out;
Expand All @@ -54,7 +57,7 @@ typedef struct i2s_config {
} i2s_config_t;

/**
* @brief I2C transfer config
* @brief I2S transfer config
*/
typedef struct i2x_transfer_config {
uint32_t sample_rate;
Expand Down
19 changes: 14 additions & 5 deletions drivers/src/hpm_i2s_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,15 @@ hpm_stat_t i2s_config_tx(I2S_Type *ptr, uint32_t mclk_in_hz, i2s_transfer_config
{
uint32_t bclk_freq_in_hz;
uint32_t bclk_div;
if (I2S_AUDIO_DEPTH_IS_NOT_VALID(config->audio_depth)
|| !config->sample_rate
|| !config->channel_num_per_frame
|| (config->channel_num_per_frame > I2S_SOC_MAX_CHANNEL_NUM)
|| !(config->channel_slot_mask & ((1U << config->channel_num_per_frame) - 1U))) {
return status_invalid_argument;
}

bclk_freq_in_hz = config->sample_rate * ((config->audio_depth << 3) + 16) * config->channel_num_per_frame;
bclk_freq_in_hz = config->sample_rate * ((config->channel_length << 4) + 16) * config->channel_num_per_frame;
bclk_div = mclk_in_hz / bclk_freq_in_hz;
if ((bclk_div > (I2S_CFGR_BCLK_DIV_MASK >> I2S_CFGR_BCLK_DIV_SHIFT))) {
return status_invalid_argument;
Expand Down Expand Up @@ -125,11 +132,12 @@ hpm_stat_t i2s_config_rx(I2S_Type *ptr, uint32_t mclk_in_hz, i2s_transfer_config
if (I2S_AUDIO_DEPTH_IS_NOT_VALID(config->audio_depth)
|| !config->sample_rate
|| !config->channel_num_per_frame
|| (config->channel_num_per_frame > I2S_SOC_MAX_CHANNEL_NUM)) {
|| (config->channel_num_per_frame > I2S_SOC_MAX_CHANNEL_NUM)
|| !(config->channel_slot_mask & ((1U << config->channel_num_per_frame) - 1U))) {
return status_invalid_argument;
}

bclk_freq_in_hz = config->sample_rate * ((config->audio_depth << 3) + 16) * config->channel_num_per_frame;
bclk_freq_in_hz = config->sample_rate * ((config->channel_length << 4) + 16) * config->channel_num_per_frame;
bclk_div = mclk_in_hz / bclk_freq_in_hz;
if (!bclk_div || (bclk_div > (I2S_CFGR_BCLK_DIV_MASK >> I2S_CFGR_BCLK_DIV_SHIFT))) {
return status_invalid_argument;
Expand Down Expand Up @@ -157,11 +165,12 @@ hpm_stat_t i2s_config_transfer(I2S_Type *ptr, uint32_t mclk_in_hz, i2s_transfer_
if (I2S_AUDIO_DEPTH_IS_NOT_VALID(config->audio_depth)
|| !config->sample_rate
|| !config->channel_num_per_frame
|| (config->channel_num_per_frame > I2S_SOC_MAX_CHANNEL_NUM)) {
|| (config->channel_num_per_frame > I2S_SOC_MAX_CHANNEL_NUM)
|| !(config->channel_slot_mask & ((1U << config->channel_num_per_frame) - 1U))) {
return status_invalid_argument;
}

bclk_freq_in_hz = config->sample_rate * ((config->audio_depth << 3) + 16) * config->channel_num_per_frame;
bclk_freq_in_hz = config->sample_rate * ((config->channel_length << 4) + 16) * config->channel_num_per_frame;
bclk_div = mclk_in_hz / bclk_freq_in_hz;
if (!bclk_div || (bclk_div > (I2S_CFGR_BCLK_DIV_MASK >> I2S_CFGR_BCLK_DIV_SHIFT))) {
return status_invalid_argument;
Expand Down
1 change: 1 addition & 0 deletions drivers/src/hpm_jpeg_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ hpm_stat_t jpeg_start_decode(JPEG_Type *ptr,
ptr->INDMABASE = JPEG_INDMABASE_ADDR_SET(config->in_buffer);
/* TODO: check if it has to use the compressed length */
ptr->INDMA_CTRL0 = JPEG_INDMA_CTRL0_TTLEN_SET(length);
ptr->INDMA_CTRL1 = JPEG_INDMA_CTRL1_ROWLEN_SET(length >> 16);
ptr->INXT_CMD = JPEG_INXT_CMD_ADDR_SET(0x14) | JPEG_INXT_CMD_OP_VALID_MASK;

/* output DMA setting */
Expand Down
8 changes: 4 additions & 4 deletions drivers/src/hpm_pdma_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,16 +665,16 @@ static void pdma_calculate_scale(uint32_t t, uint32_t target_t,
{
uint32_t tmp;
tmp = ((t << PDMA_SCALE_FRAC_BITS) / target_t) >> PDMA_SCALE_FRAC_BITS;
if (tmp > 16) {
if (tmp >= 16) {
*dec = pdma_decimation_by_8;
*scale = 2;
return;
}
if (tmp > 8) {
if (tmp >= 8) {
*dec = pdma_decimation_by_8;
} else if (tmp > 4) {
} else if (tmp >= 4) {
*dec = pdma_decimation_by_4;
} else if (tmp > 2) {
} else if (tmp >= 2) {
*dec = pdma_decimation_by_2;
} else {
*dec = pdma_decimation_by_1;
Expand Down
4 changes: 2 additions & 2 deletions drivers/src/hpm_wdg_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ interrupt_interval_t wdg_convert_interrupt_interval_from_us(const uint32_t src_f
src_clk_one_tick_in_ns = 1U;
}

uint32_t interrupt_interval_ticks = (uint32_t) ((uint64_t) interval_us * 1000UL) / src_clk_one_tick_in_ns;
uint32_t interrupt_interval_ticks = ((uint64_t) interval_us * 1000UL) / src_clk_one_tick_in_ns;

for (uint32_t i = 0; i < ARRAY_SIZE(k_interrupt_interval_map); i++) {
if (interrupt_interval_ticks <= k_interrupt_interval_map[i].top) {
Expand Down Expand Up @@ -164,4 +164,4 @@ uint32_t wdg_get_total_reset_interval_in_us(WDG_Type *base, const uint32_t src_f
}

return time_in_us;
}
}
9 changes: 5 additions & 4 deletions middleware/audio_codec/wav/hpm_decoder/hpm_wav_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ uint32_t hpm_wav_decode(hpm_wav_ctrl *wav_ctrl, uint8_t *buf, uint32_t size)
pbuf = (uint32_t *)buf;
if (wav_ctrl->wav_head.fmt_chunk.bitspersample == 32) {
if (wav_ctrl->wav_head.fmt_chunk.channels == 2) {
word_size = size;
readlen = word_size;
word_size = size >> 2;
readlen = word_size << 2;
if (wav_ctrl->remaining_data >= readlen) {
wav_ctrl->remaining_data -= readlen;
} else {
Expand All @@ -80,9 +80,10 @@ uint32_t hpm_wav_decode(hpm_wav_ctrl *wav_ctrl, uint8_t *buf, uint32_t size)
pbuf[n++] = (*(uint32_t *)&p8[0]);
p8 += 4;
}
buf_len = read;
} else if (wav_ctrl->wav_head.fmt_chunk.channels == 1) {
word_size = size;
readlen = word_size >> 1;
word_size = size >> 2;
readlen = word_size << 1;
if (wav_ctrl->remaining_data >= readlen) {
wav_ctrl->remaining_data -= readlen;
} else {
Expand Down
6 changes: 3 additions & 3 deletions middleware/lwip/src/include/lwip/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

/** Platform specific diagnostic output.\n
* Note the default implementation pulls in printf, which may
* in turn pull in a lot of standard libary code. In resource-constrained
* in turn pull in a lot of standard libary code. In resource-constrained
* systems, this should be defined to something less resource-consuming.
*/
#ifndef LWIP_PLATFORM_DIAG
Expand All @@ -85,7 +85,7 @@

/** Platform specific assertion handling.\n
* Note the default implementation pulls in printf, fflush and abort, which may
* in turn pull in a lot of standard libary code. In resource-constrained
* in turn pull in a lot of standard libary code. In resource-constrained
* systems, this should be defined to something less resource-consuming.
*/
#ifndef LWIP_PLATFORM_ASSERT
Expand Down Expand Up @@ -268,7 +268,7 @@ typedef int ssize_t;
* \#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u32_t variable_name[(size + sizeof(u32_t) - 1) / sizeof(u32_t)]
*/
#ifndef LWIP_DECLARE_MEMORY_ALIGNED
#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) u8_t variable_name[LWIP_MEM_ALIGN_BUFFER(size)]
#define LWIP_DECLARE_MEMORY_ALIGNED(variable_name, size) LWIP_MEM_SECTION u8_t variable_name[LWIP_MEM_ALIGN_BUFFER(size)]
#endif

/** Calculate memory size for an aligned buffer - returns the next highest
Expand Down
8 changes: 4 additions & 4 deletions samples/audio_codec/decoder_wav/src/audio_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ hpm_wav_ctrl wav_ctrl;
uint32_t i2s_mclk_hz;
ATTR_ALIGN(4) uint8_t wav_header_buff[512];
uint8_t search_file_buff[FIL_SEARCH_NUM][FIL_SEARCH_LENGTH];
ATTR_ALIGN(32) uint8_t i2s_buff1[CODEC_BUFF_SIZE];
ATTR_ALIGN(32) uint8_t i2s_buff2[CODEC_BUFF_SIZE];
ATTR_ALIGN(HPM_L1C_CACHELINE_SIZE) uint8_t i2s_buff1[CODEC_BUFF_SIZE];
ATTR_ALIGN(HPM_L1C_CACHELINE_SIZE) uint8_t i2s_buff2[CODEC_BUFF_SIZE];

hpm_stat_t hpm_audiocodec_search_file(char * file_name, HPM_AUDIOCODEC_FILE * fil)
{
Expand Down Expand Up @@ -130,8 +130,8 @@ hpm_stat_t get_audio_clock_div(uint16_t *div1, uint32_t sample_rate, uint8_t aud
m = 0;
do {
prop = audio_freq_in_hz / bclk_freq_in_hz;
for (i = 20; i <= 256; i--) {
for (j = 512; j >= 10; j--) {
for (i = 5; i <= (SYSCTL_CLOCK_DIV_MASK >> SYSCTL_CLOCK_DIV_SHIFT); i++) {
for (j = (I2S_CFGR_BCLK_DIV_MASK >> I2S_CFGR_BCLK_DIV_SHIFT); j >= 5; j--) {
if ((i * j) == prop) {
*div1 = i;
return status_success;
Expand Down
1 change: 1 addition & 0 deletions samples/drivers/i2s/i2s_dma/src/audio_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void test_i2s_dma(void)
i2s_get_default_transfer_config(&transfer);
transfer.data_line = I2S_DATA_LINE_2;
transfer.sample_rate = CODEC_SAMPLE_RATE_HZ;
transfer.channel_slot_mask = I2S_CHANNEL_SLOT_MASK(0); /* mono left */
transfer.master_mode = true;
i2s_mclk_hz = clock_get_frequency(CODEC_I2S_CLK_NAME);
if (status_success != i2s_config_transfer(CODEC_I2S, i2s_mclk_hz, &transfer)) {
Expand Down
10 changes: 5 additions & 5 deletions samples/drivers/i2s/i2s_interrupt/src/audio_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ sgtl_context_t sgtl5000_context = {
.ptr = CODEC_I2C,
.slave_address = CODEC_I2C_ADDRESS, /* I2C address */
};
uint32_t * data_tx;
uint32_t t_count = 0;
uint32_t sin_1khz_48khz[] = {
0x00000000, 0x0D5DAA00, 0x1A80C900, 0x272FD100, 0x33333300, 0x3E565100, 0x48686100, 0x513D4800,
Expand All @@ -53,10 +52,10 @@ void isr_i2s(void)
s = CODEC_I2S->STA;
CODEC_I2S->STA = s;
if ((s & I2S_CTRL_TX_EN_SET(4))) {
data_tx = (uint32_t *)&sin_1khz_48khz[(t_count)%sizeof(sin_1khz_48khz)];
i2s_send_data(CODEC_I2S, CODEC_I2S_DATA_LINE, data_tx, 8);
i2s_send_data(CODEC_I2S, CODEC_I2S_DATA_LINE, data_tx, 8);
t_count += 8;
i2s_send_data(CODEC_I2S, CODEC_I2S_DATA_LINE, &sin_1khz_48khz[t_count], 1);
i2s_send_data(CODEC_I2S, CODEC_I2S_DATA_LINE, &sin_1khz_48khz[t_count], 1);
t_count++;
t_count = t_count % ARRAY_SIZE(sin_1khz_48khz);
}

}
Expand All @@ -71,6 +70,7 @@ void test_interrupt(void)

/* Config I2S interface to CODEC */
i2s_get_default_config(CODEC_I2S, &i2s_config);
i2s_config.fifo_threshold = 2;
i2s_config.enable_mclk_out = true;
i2s_init(CODEC_I2S, &i2s_config);

Expand Down
1 change: 0 additions & 1 deletion samples/drivers/plic/src/plic.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ void isr_plicsw(void)
{
printf("plicsw start\n");
printf("plicsw end\n");
intc_m_disable_swi();
}
SDK_DECLARE_SWI_ISR(isr_plicsw)

Expand Down
14 changes: 11 additions & 3 deletions samples/jpeg/common/inc/file_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@
extern "C" {
#endif /* __cplusplus */

#if BOARD_SDRAM_SIZE >= (32*SIZE_1MB)
/*JPG data buff length*/
#define FILEBUFFLEN 27000

#define FILEBUFFLEN 10485760
/*rgb565 data buff length*/
#define RGBBUFFLEN 16777216
#else
/*JPG data buff length*/
#define FILEBUFFLEN 4194304
/*rgb565 data buff length*/
#define RGBBUFFLEN 200000
#define RGBBUFFLEN 7340032
#endif



#define FILENAMENUM 10
#define FILENAMELENGTH 255
Expand Down
Loading

0 comments on commit b6ff51c

Please sign in to comment.