mirror of
https://github.com/ArteryTek/AT32F413_Firmware_Library.git
synced 2026-05-21 09:22:02 +00:00
update version to v2.0.4
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief header file of clock program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_conf.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief at32f413 config header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -150,7 +150,7 @@ extern "C" {
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief header file of main interrupt service routines.
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file communicationdma/readme.txt
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief readme
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief system clock config program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
/* includes ------------------------------------------------------------------*/
|
||||
#include "at32f413_clock.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief system clock config program
|
||||
* @note the system clock is configured as follow:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief main interrupt service routines.
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -30,10 +30,10 @@
|
||||
|
||||
extern i2c_handle_type hi2cx;
|
||||
|
||||
#define I2Cx_DMA_TX_IRQHandler DMA1_Channel6_IRQHandler
|
||||
#define I2Cx_DMA_TX_IRQHandler DMA1_Channel6_IRQHandler
|
||||
#define I2Cx_DMA_RX_IRQHandler DMA1_Channel7_IRQHandler
|
||||
#define I2Cx_EVT_IRQHandler I2C1_EVT_IRQHandler
|
||||
#define I2Cx_ERR_IRQHandler I2C1_ERR_IRQHandler
|
||||
#define I2Cx_EVT_IRQHandler I2C1_EVT_IRQHandler
|
||||
#define I2Cx_ERR_IRQHandler I2C1_ERR_IRQHandler
|
||||
|
||||
/** @addtogroup AT32F413_periph_examples
|
||||
* @{
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file main.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief main program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -31,37 +31,37 @@
|
||||
/** @addtogroup AT32F413_periph_examples
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup 413_I2C_communication_dma I2C_communication_dma
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define I2C_TIMEOUT 0xFFFFFFFF
|
||||
|
||||
|
||||
#define I2Cx_SPEED 100000
|
||||
#define I2Cx_ADDRESS 0xA0
|
||||
|
||||
#define I2Cx_PORT I2C1
|
||||
#define I2Cx_CLK CRM_I2C1_PERIPH_CLOCK
|
||||
|
||||
#define I2Cx_SCL_PIN GPIO_PINS_6
|
||||
#define I2Cx_SCL_GPIO_PORT GPIOB
|
||||
#define I2Cx_SCL_PIN GPIO_PINS_6
|
||||
#define I2Cx_SCL_GPIO_PORT GPIOB
|
||||
#define I2Cx_SCL_GPIO_CLK CRM_GPIOB_PERIPH_CLOCK
|
||||
|
||||
#define I2Cx_SDA_PIN GPIO_PINS_7
|
||||
#define I2Cx_SDA_GPIO_PORT GPIOB
|
||||
#define I2Cx_SDA_PIN GPIO_PINS_7
|
||||
#define I2Cx_SDA_GPIO_PORT GPIOB
|
||||
#define I2Cx_SDA_GPIO_CLK CRM_GPIOB_PERIPH_CLOCK
|
||||
|
||||
#define I2Cx_DMA_CLK CRM_DMA1_PERIPH_CLOCK
|
||||
#define I2Cx_DMA_CLK CRM_DMA1_PERIPH_CLOCK
|
||||
#define I2Cx_DMA_TX_CHANNEL DMA1_CHANNEL6
|
||||
#define I2Cx_DMA_TX_IRQn DMA1_Channel6_IRQn
|
||||
|
||||
#define I2Cx_DMA_RX_CHANNEL DMA1_CHANNEL7
|
||||
#define I2Cx_DMA_RX_CHANNEL DMA1_CHANNEL7
|
||||
#define I2Cx_DMA_RX_IRQn DMA1_Channel7_IRQn
|
||||
|
||||
#define I2Cx_EVT_IRQn I2C1_EVT_IRQn
|
||||
#define I2Cx_ERR_IRQn I2C1_ERR_IRQn
|
||||
|
||||
|
||||
#define BUF_SIZE 8
|
||||
#define MASTER_BOARD
|
||||
|
||||
@@ -97,7 +97,7 @@ void error_handler(uint32_t error_code)
|
||||
uint32_t buffer_compare(uint8_t* buffer1, uint8_t* buffer2, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
if(buffer1[i] != buffer2[i])
|
||||
@@ -117,43 +117,43 @@ uint32_t buffer_compare(uint8_t* buffer1, uint8_t* buffer2, uint32_t len)
|
||||
void i2c_lowlevel_init(i2c_handle_type* hi2c)
|
||||
{
|
||||
gpio_init_type gpio_initstructure;
|
||||
|
||||
|
||||
if(hi2c->i2cx == I2Cx_PORT)
|
||||
{
|
||||
{
|
||||
/* i2c periph clock enable */
|
||||
crm_periph_clock_enable(I2Cx_CLK, TRUE);
|
||||
crm_periph_clock_enable(I2Cx_CLK, TRUE);
|
||||
crm_periph_clock_enable(I2Cx_SCL_GPIO_CLK, TRUE);
|
||||
crm_periph_clock_enable(I2Cx_SDA_GPIO_CLK, TRUE);
|
||||
|
||||
/* gpio configuration */
|
||||
gpio_initstructure.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
||||
gpio_initstructure.gpio_pull = GPIO_PULL_UP;
|
||||
gpio_initstructure.gpio_mode = GPIO_MODE_MUX;
|
||||
|
||||
/* gpio configuration */
|
||||
gpio_initstructure.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
||||
gpio_initstructure.gpio_pull = GPIO_PULL_UP;
|
||||
gpio_initstructure.gpio_mode = GPIO_MODE_MUX;
|
||||
gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
||||
|
||||
/* configure i2c pins: scl */
|
||||
|
||||
/* configure i2c pins: scl */
|
||||
gpio_initstructure.gpio_pins = I2Cx_SCL_PIN;
|
||||
gpio_init(I2Cx_SCL_GPIO_PORT, &gpio_initstructure);
|
||||
|
||||
/* configure i2c pins: sda */
|
||||
/* configure i2c pins: sda */
|
||||
gpio_initstructure.gpio_pins = I2Cx_SDA_PIN;
|
||||
gpio_init(I2Cx_SDA_GPIO_PORT, &gpio_initstructure);
|
||||
|
||||
/* configure and enable i2c dma channel interrupt */
|
||||
|
||||
/* configure and enable i2c dma channel interrupt */
|
||||
nvic_irq_enable(I2Cx_DMA_TX_IRQn, 0, 0);
|
||||
nvic_irq_enable(I2Cx_DMA_RX_IRQn, 0, 0);
|
||||
|
||||
nvic_irq_enable(I2Cx_DMA_RX_IRQn, 0, 0);
|
||||
|
||||
/* i2c dma tx and rx channels configuration */
|
||||
/* enable the dma clock */
|
||||
crm_periph_clock_enable(I2Cx_DMA_CLK, TRUE);
|
||||
|
||||
|
||||
/* i2c dma channel configuration */
|
||||
dma_reset(hi2c->dma_tx_channel);
|
||||
dma_reset(hi2c->dma_rx_channel);
|
||||
|
||||
dma_reset(hi2c->dma_rx_channel);
|
||||
|
||||
hi2c->dma_tx_channel = I2Cx_DMA_TX_CHANNEL;
|
||||
hi2c->dma_rx_channel = I2Cx_DMA_RX_CHANNEL;
|
||||
|
||||
|
||||
dma_default_para_init(&hi2c->dma_init_struct);
|
||||
hi2c->dma_init_struct.peripheral_inc_enable = FALSE;
|
||||
hi2c->dma_init_struct.memory_inc_enable = TRUE;
|
||||
@@ -162,12 +162,12 @@ void i2c_lowlevel_init(i2c_handle_type* hi2c)
|
||||
hi2c->dma_init_struct.loop_mode_enable = FALSE;
|
||||
hi2c->dma_init_struct.priority = DMA_PRIORITY_LOW;
|
||||
hi2c->dma_init_struct.direction = DMA_DIR_MEMORY_TO_PERIPHERAL;
|
||||
|
||||
dma_init(hi2c->dma_tx_channel, &hi2c->dma_init_struct);
|
||||
dma_init(hi2c->dma_rx_channel, &hi2c->dma_init_struct);
|
||||
|
||||
|
||||
dma_init(hi2c->dma_tx_channel, &hi2c->dma_init_struct);
|
||||
dma_init(hi2c->dma_rx_channel, &hi2c->dma_init_struct);
|
||||
|
||||
i2c_init(hi2c->i2cx, I2C_FSMODE_DUTY_2_1, I2Cx_SPEED);
|
||||
|
||||
|
||||
i2c_own_address1_set(hi2c->i2cx, I2C_ADDRESS_MODE_7BIT, I2Cx_ADDRESS);
|
||||
}
|
||||
}
|
||||
@@ -185,49 +185,49 @@ int main(void)
|
||||
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
|
||||
|
||||
system_clock_config();
|
||||
|
||||
|
||||
at32_board_init();
|
||||
|
||||
|
||||
hi2cx.i2cx = I2Cx_PORT;
|
||||
|
||||
|
||||
i2c_config(&hi2cx);
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
#if defined (MASTER_BOARD)
|
||||
|
||||
|
||||
#if defined (MASTER_BOARD)
|
||||
|
||||
/* wait for key USER_BUTTON press before starting the communication */
|
||||
while(at32_button_press() != USER_BUTTON)
|
||||
{
|
||||
}
|
||||
|
||||
/* start the request reception process */
|
||||
|
||||
/* start the request reception process */
|
||||
if((i2c_status = i2c_master_transmit_dma(&hi2cx, I2Cx_ADDRESS, tx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
|
||||
delay_ms(10);
|
||||
|
||||
/* start the request reception process */
|
||||
|
||||
/* start the request reception process */
|
||||
if((i2c_status = i2c_master_receive_dma(&hi2cx, I2Cx_ADDRESS, rx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
if(buffer_compare(tx_buf, rx_buf, BUF_SIZE) == 0)
|
||||
{
|
||||
at32_led_on(LED3);
|
||||
@@ -236,33 +236,33 @@ int main(void)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
/* wait for key USER_BUTTON press before starting the communication */
|
||||
while(at32_button_press() != USER_BUTTON)
|
||||
{
|
||||
}
|
||||
|
||||
/* start the transmission process */
|
||||
|
||||
/* start the transmission process */
|
||||
if((i2c_status = i2c_slave_receive_dma(&hi2cx, rx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
|
||||
if((i2c_status = i2c_slave_transmit_dma(&hi2cx, tx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
@@ -275,16 +275,16 @@ int main(void)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief header file of clock program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_conf.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief at32f413 config header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -150,7 +150,7 @@ extern "C" {
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief header file of main interrupt service routines.
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file communicationint/readme.txt
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief readme
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief system clock config program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
/* includes ------------------------------------------------------------------*/
|
||||
#include "at32f413_clock.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief system clock config program
|
||||
* @note the system clock is configured as follow:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief main interrupt service routines.
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
extern i2c_handle_type hi2cx;
|
||||
|
||||
#define I2Cx_EVT_IRQHandler I2C1_EVT_IRQHandler
|
||||
#define I2Cx_ERR_IRQHandler I2C1_ERR_IRQHandler
|
||||
#define I2Cx_EVT_IRQHandler I2C1_EVT_IRQHandler
|
||||
#define I2Cx_ERR_IRQHandler I2C1_ERR_IRQHandler
|
||||
|
||||
/** @addtogroup AT32F413_periph_examples
|
||||
* @{
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file main.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief main program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -31,25 +31,25 @@
|
||||
/** @addtogroup AT32F413_periph_examples
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup 413_I2C_communication_int I2C_communication_int
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define I2C_TIMEOUT 0xFFFFFFFF
|
||||
|
||||
|
||||
#define I2Cx_SPEED 100000
|
||||
#define I2Cx_ADDRESS 0xA0
|
||||
|
||||
#define I2Cx_PORT I2C1
|
||||
#define I2Cx_CLK CRM_I2C1_PERIPH_CLOCK
|
||||
|
||||
#define I2Cx_SCL_PIN GPIO_PINS_6
|
||||
#define I2Cx_SCL_GPIO_PORT GPIOB
|
||||
#define I2Cx_SCL_PIN GPIO_PINS_6
|
||||
#define I2Cx_SCL_GPIO_PORT GPIOB
|
||||
#define I2Cx_SCL_GPIO_CLK CRM_GPIOB_PERIPH_CLOCK
|
||||
|
||||
#define I2Cx_SDA_PIN GPIO_PINS_7
|
||||
#define I2Cx_SDA_GPIO_PORT GPIOB
|
||||
#define I2Cx_SDA_PIN GPIO_PINS_7
|
||||
#define I2Cx_SDA_GPIO_PORT GPIOB
|
||||
#define I2Cx_SDA_GPIO_CLK CRM_GPIOB_PERIPH_CLOCK
|
||||
|
||||
#define I2Cx_EVT_IRQn I2C1_EVT_IRQn
|
||||
@@ -91,7 +91,7 @@ void error_handler(uint32_t error_code)
|
||||
uint32_t buffer_compare(uint8_t* buffer1, uint8_t* buffer2, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
if(buffer1[i] != buffer2[i])
|
||||
@@ -111,34 +111,34 @@ uint32_t buffer_compare(uint8_t* buffer1, uint8_t* buffer2, uint32_t len)
|
||||
void i2c_lowlevel_init(i2c_handle_type* hi2c)
|
||||
{
|
||||
gpio_init_type gpio_initstructure;
|
||||
|
||||
|
||||
if(hi2c->i2cx == I2Cx_PORT)
|
||||
{
|
||||
{
|
||||
/* i2c periph clock enable */
|
||||
crm_periph_clock_enable(I2Cx_CLK, TRUE);
|
||||
crm_periph_clock_enable(I2Cx_CLK, TRUE);
|
||||
crm_periph_clock_enable(I2Cx_SCL_GPIO_CLK, TRUE);
|
||||
crm_periph_clock_enable(I2Cx_SDA_GPIO_CLK, TRUE);
|
||||
|
||||
/* gpio configuration */
|
||||
gpio_initstructure.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
||||
gpio_initstructure.gpio_pull = GPIO_PULL_UP;
|
||||
gpio_initstructure.gpio_mode = GPIO_MODE_MUX;
|
||||
|
||||
/* gpio configuration */
|
||||
gpio_initstructure.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
||||
gpio_initstructure.gpio_pull = GPIO_PULL_UP;
|
||||
gpio_initstructure.gpio_mode = GPIO_MODE_MUX;
|
||||
gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
||||
|
||||
/* configure i2c pins: scl */
|
||||
|
||||
/* configure i2c pins: scl */
|
||||
gpio_initstructure.gpio_pins = I2Cx_SCL_PIN;
|
||||
gpio_init(I2Cx_SCL_GPIO_PORT, &gpio_initstructure);
|
||||
|
||||
/* configure i2c pins: sda */
|
||||
/* configure i2c pins: sda */
|
||||
gpio_initstructure.gpio_pins = I2Cx_SDA_PIN;
|
||||
gpio_init(I2Cx_SDA_GPIO_PORT, &gpio_initstructure);
|
||||
|
||||
/* configure and enable i2c interrupt */
|
||||
|
||||
/* configure and enable i2c interrupt */
|
||||
nvic_irq_enable(I2Cx_EVT_IRQn, 0, 0);
|
||||
nvic_irq_enable(I2Cx_ERR_IRQn, 0, 0);
|
||||
|
||||
nvic_irq_enable(I2Cx_ERR_IRQn, 0, 0);
|
||||
|
||||
i2c_init(hi2c->i2cx, I2C_FSMODE_DUTY_2_1, I2Cx_SPEED);
|
||||
|
||||
|
||||
i2c_own_address1_set(hi2c->i2cx, I2C_ADDRESS_MODE_7BIT, I2Cx_ADDRESS);
|
||||
}
|
||||
}
|
||||
@@ -156,49 +156,49 @@ int main(void)
|
||||
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
|
||||
|
||||
system_clock_config();
|
||||
|
||||
|
||||
at32_board_init();
|
||||
|
||||
hi2cx.i2cx = I2Cx_PORT;
|
||||
|
||||
|
||||
i2c_config(&hi2cx);
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
#if defined (MASTER_BOARD)
|
||||
|
||||
|
||||
#if defined (MASTER_BOARD)
|
||||
|
||||
/* wait for key USER_BUTTON press before starting the communication */
|
||||
while(at32_button_press() != USER_BUTTON)
|
||||
{
|
||||
}
|
||||
|
||||
/* start the request reception process */
|
||||
|
||||
/* start the request reception process */
|
||||
if((i2c_status = i2c_master_transmit_int(&hi2cx, I2Cx_ADDRESS, tx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
delay_ms(10);
|
||||
|
||||
/* start the request reception process */
|
||||
if((i2c_status = i2c_master_receive_int(&hi2cx, I2Cx_ADDRESS, rx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
|
||||
delay_ms(10);
|
||||
|
||||
/* start the request reception process */
|
||||
if((i2c_status = i2c_master_receive_int(&hi2cx, I2Cx_ADDRESS, rx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
if(buffer_compare(tx_buf, rx_buf, BUF_SIZE) == 0)
|
||||
{
|
||||
at32_led_on(LED3);
|
||||
@@ -207,37 +207,37 @@ int main(void)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
/* wait for key USER_BUTTON press before starting the communication */
|
||||
while(at32_button_press() != USER_BUTTON)
|
||||
{
|
||||
}
|
||||
|
||||
/* start the transmission process */
|
||||
|
||||
/* start the transmission process */
|
||||
if((i2c_status = i2c_slave_receive_int(&hi2cx, rx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
if((i2c_status = i2c_slave_transmit_int(&hi2cx, tx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
if(buffer_compare(tx_buf, rx_buf, BUF_SIZE) == 0)
|
||||
{
|
||||
at32_led_on(LED3);
|
||||
@@ -247,14 +247,14 @@ int main(void)
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief header file of clock program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_conf.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief at32f413 config header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -150,7 +150,7 @@ extern "C" {
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief header file of main interrupt service routines.
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file communication_poll/readme.txt
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief readme
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief system clock config program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
/* includes ------------------------------------------------------------------*/
|
||||
#include "at32f413_clock.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief system clock config program
|
||||
* @note the system clock is configured as follow:
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief main interrupt service routines.
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -30,7 +30,7 @@
|
||||
/** @addtogroup AT32F413_periph_examples
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup 413_I2C_communication_poll
|
||||
* @{
|
||||
*/
|
||||
@@ -134,8 +134,8 @@ void SysTick_Handler(void)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file main.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief main program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -31,25 +31,25 @@
|
||||
/** @addtogroup AT32F413_periph_examples
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup 413_I2C_communication_poll I2C_communication_poll
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define I2C_TIMEOUT 0xFFFFFFFF
|
||||
|
||||
|
||||
#define I2Cx_SPEED 100000
|
||||
#define I2Cx_ADDRESS 0xA0
|
||||
|
||||
#define I2Cx_PORT I2C1
|
||||
#define I2Cx_CLK CRM_I2C1_PERIPH_CLOCK
|
||||
|
||||
#define I2Cx_SCL_PIN GPIO_PINS_6
|
||||
#define I2Cx_SCL_GPIO_PORT GPIOB
|
||||
#define I2Cx_SCL_PIN GPIO_PINS_6
|
||||
#define I2Cx_SCL_GPIO_PORT GPIOB
|
||||
#define I2Cx_SCL_GPIO_CLK CRM_GPIOB_PERIPH_CLOCK
|
||||
|
||||
#define I2Cx_SDA_PIN GPIO_PINS_7
|
||||
#define I2Cx_SDA_GPIO_PORT GPIOB
|
||||
#define I2Cx_SDA_PIN GPIO_PINS_7
|
||||
#define I2Cx_SDA_GPIO_PORT GPIOB
|
||||
#define I2Cx_SDA_GPIO_CLK CRM_GPIOB_PERIPH_CLOCK
|
||||
|
||||
#define BUF_SIZE 8
|
||||
@@ -88,7 +88,7 @@ void error_handler(uint32_t error_code)
|
||||
uint32_t buffer_compare(uint8_t* buffer1, uint8_t* buffer2, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
if(buffer1[i] != buffer2[i])
|
||||
@@ -108,30 +108,30 @@ uint32_t buffer_compare(uint8_t* buffer1, uint8_t* buffer2, uint32_t len)
|
||||
void i2c_lowlevel_init(i2c_handle_type* hi2c)
|
||||
{
|
||||
gpio_init_type gpio_initstructure;
|
||||
|
||||
|
||||
if(hi2c->i2cx == I2Cx_PORT)
|
||||
{
|
||||
{
|
||||
/* i2c periph clock enable */
|
||||
crm_periph_clock_enable(I2Cx_CLK, TRUE);
|
||||
crm_periph_clock_enable(I2Cx_CLK, TRUE);
|
||||
crm_periph_clock_enable(I2Cx_SCL_GPIO_CLK, TRUE);
|
||||
crm_periph_clock_enable(I2Cx_SDA_GPIO_CLK, TRUE);
|
||||
|
||||
/* gpio configuration */
|
||||
gpio_initstructure.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
||||
gpio_initstructure.gpio_pull = GPIO_PULL_UP;
|
||||
gpio_initstructure.gpio_mode = GPIO_MODE_MUX;
|
||||
|
||||
/* gpio configuration */
|
||||
gpio_initstructure.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
||||
gpio_initstructure.gpio_pull = GPIO_PULL_UP;
|
||||
gpio_initstructure.gpio_mode = GPIO_MODE_MUX;
|
||||
gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
||||
|
||||
/* configure i2c pins: scl */
|
||||
|
||||
/* configure i2c pins: scl */
|
||||
gpio_initstructure.gpio_pins = I2Cx_SCL_PIN;
|
||||
gpio_init(I2Cx_SCL_GPIO_PORT, &gpio_initstructure);
|
||||
|
||||
/* configure i2c pins: sda */
|
||||
/* configure i2c pins: sda */
|
||||
gpio_initstructure.gpio_pins = I2Cx_SDA_PIN;
|
||||
gpio_init(I2Cx_SDA_GPIO_PORT, &gpio_initstructure);
|
||||
|
||||
|
||||
i2c_init(hi2c->i2cx, I2C_FSMODE_DUTY_2_1, I2Cx_SPEED);
|
||||
|
||||
|
||||
i2c_own_address1_set(hi2c->i2cx, I2C_ADDRESS_MODE_7BIT, I2Cx_ADDRESS);
|
||||
}
|
||||
}
|
||||
@@ -144,39 +144,39 @@ void i2c_lowlevel_init(i2c_handle_type* hi2c)
|
||||
int main(void)
|
||||
{
|
||||
i2c_status_type i2c_status;
|
||||
|
||||
|
||||
system_clock_config();
|
||||
|
||||
|
||||
at32_board_init();
|
||||
|
||||
|
||||
hi2cx.i2cx = I2Cx_PORT;
|
||||
|
||||
|
||||
i2c_config(&hi2cx);
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
#if defined (MASTER_BOARD)
|
||||
|
||||
|
||||
#if defined (MASTER_BOARD)
|
||||
|
||||
/* wait for key USER_BUTTON press before starting the communication */
|
||||
while(at32_button_press() != USER_BUTTON)
|
||||
{
|
||||
}
|
||||
|
||||
/* start the request reception process */
|
||||
|
||||
/* start the request reception process */
|
||||
if((i2c_status = i2c_master_transmit(&hi2cx, I2Cx_ADDRESS, tx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
delay_ms(10);
|
||||
|
||||
/* start the request reception process */
|
||||
|
||||
/* start the request reception process */
|
||||
if((i2c_status = i2c_master_receive(&hi2cx, I2Cx_ADDRESS, rx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(buffer_compare(tx_buf, rx_buf, BUF_SIZE) == 0)
|
||||
{
|
||||
at32_led_on(LED3);
|
||||
@@ -186,20 +186,20 @@ int main(void)
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
#else
|
||||
|
||||
|
||||
/* wait for key USER_BUTTON press before starting the communication */
|
||||
while(at32_button_press() != USER_BUTTON)
|
||||
{
|
||||
}
|
||||
|
||||
/* start the transmission process */
|
||||
|
||||
/* start the transmission process */
|
||||
if((i2c_status = i2c_slave_receive(&hi2cx, rx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
if((i2c_status = i2c_slave_transmit(&hi2cx, tx_buf, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
@@ -212,14 +212,14 @@ int main(void)
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief header file of clock program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_conf.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief at32f413 config header file
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -150,7 +150,7 @@ extern "C" {
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.h
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief header file of main interrupt service routines.
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file eeprom/readme.txt
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief readme
|
||||
**************************************************************************
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_clock.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief system clock config program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
/* includes ------------------------------------------------------------------*/
|
||||
#include "at32f413_clock.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief system clock config program
|
||||
* @note the system clock is configured as follow:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file at32f413_int.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief main interrupt service routines.
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
@@ -30,10 +30,10 @@
|
||||
|
||||
extern i2c_handle_type hi2cx;
|
||||
|
||||
#define I2Cx_DMA_TX_IRQHandler DMA1_Channel6_IRQHandler
|
||||
#define I2Cx_DMA_TX_IRQHandler DMA1_Channel6_IRQHandler
|
||||
#define I2Cx_DMA_RX_IRQHandler DMA1_Channel7_IRQHandler
|
||||
#define I2Cx_EVT_IRQHandler I2C1_EVT_IRQHandler
|
||||
#define I2Cx_ERR_IRQHandler I2C1_ERR_IRQHandler
|
||||
#define I2Cx_EVT_IRQHandler I2C1_EVT_IRQHandler
|
||||
#define I2Cx_ERR_IRQHandler I2C1_ERR_IRQHandler
|
||||
|
||||
/** @addtogroup AT32F413_periph_examples
|
||||
* @{
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file main.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief main program
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -31,32 +31,32 @@
|
||||
/** @addtogroup AT32F413_periph_examples
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @addtogroup 413_I2C_eeprom I2C_eeprom
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define I2C_TIMEOUT 0xFFFFFFFF
|
||||
|
||||
|
||||
#define I2Cx_SPEED 100000
|
||||
#define I2Cx_ADDRESS 0xA0
|
||||
|
||||
#define I2Cx_PORT I2C1
|
||||
#define I2Cx_CLK CRM_I2C1_PERIPH_CLOCK
|
||||
|
||||
#define I2Cx_SCL_PIN GPIO_PINS_6
|
||||
#define I2Cx_SCL_GPIO_PORT GPIOB
|
||||
#define I2Cx_SCL_PIN GPIO_PINS_6
|
||||
#define I2Cx_SCL_GPIO_PORT GPIOB
|
||||
#define I2Cx_SCL_GPIO_CLK CRM_GPIOB_PERIPH_CLOCK
|
||||
|
||||
#define I2Cx_SDA_PIN GPIO_PINS_7
|
||||
#define I2Cx_SDA_GPIO_PORT GPIOB
|
||||
#define I2Cx_SDA_PIN GPIO_PINS_7
|
||||
#define I2Cx_SDA_GPIO_PORT GPIOB
|
||||
#define I2Cx_SDA_GPIO_CLK CRM_GPIOB_PERIPH_CLOCK
|
||||
|
||||
#define I2Cx_DMA_CLK CRM_DMA1_PERIPH_CLOCK
|
||||
#define I2Cx_DMA_CLK CRM_DMA1_PERIPH_CLOCK
|
||||
#define I2Cx_DMA_TX_CHANNEL DMA1_CHANNEL6
|
||||
#define I2Cx_DMA_TX_IRQn DMA1_Channel6_IRQn
|
||||
|
||||
#define I2Cx_DMA_RX_CHANNEL DMA1_CHANNEL7
|
||||
#define I2Cx_DMA_RX_CHANNEL DMA1_CHANNEL7
|
||||
#define I2Cx_DMA_RX_IRQn DMA1_Channel7_IRQn
|
||||
|
||||
#define I2Cx_EVT_IRQn I2C1_EVT_IRQn
|
||||
@@ -101,7 +101,7 @@ void error_handler(uint32_t error_code)
|
||||
uint32_t buffer_compare(uint8_t* buffer1, uint8_t* buffer2, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
if(buffer1[i] != buffer2[i])
|
||||
@@ -121,47 +121,47 @@ uint32_t buffer_compare(uint8_t* buffer1, uint8_t* buffer2, uint32_t len)
|
||||
void i2c_lowlevel_init(i2c_handle_type* hi2c)
|
||||
{
|
||||
gpio_init_type gpio_initstructure;
|
||||
|
||||
|
||||
if(hi2c->i2cx == I2Cx_PORT)
|
||||
{
|
||||
{
|
||||
/* i2c periph clock enable */
|
||||
crm_periph_clock_enable(I2Cx_CLK, TRUE);
|
||||
crm_periph_clock_enable(I2Cx_CLK, TRUE);
|
||||
crm_periph_clock_enable(I2Cx_SCL_GPIO_CLK, TRUE);
|
||||
crm_periph_clock_enable(I2Cx_SDA_GPIO_CLK, TRUE);
|
||||
|
||||
/* gpio configuration */
|
||||
gpio_initstructure.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
||||
gpio_initstructure.gpio_pull = GPIO_PULL_UP;
|
||||
gpio_initstructure.gpio_mode = GPIO_MODE_MUX;
|
||||
|
||||
/* gpio configuration */
|
||||
gpio_initstructure.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
||||
gpio_initstructure.gpio_pull = GPIO_PULL_UP;
|
||||
gpio_initstructure.gpio_mode = GPIO_MODE_MUX;
|
||||
gpio_initstructure.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
||||
|
||||
/* configure i2c pins: scl */
|
||||
|
||||
/* configure i2c pins: scl */
|
||||
gpio_initstructure.gpio_pins = I2Cx_SCL_PIN;
|
||||
gpio_init(I2Cx_SCL_GPIO_PORT, &gpio_initstructure);
|
||||
|
||||
/* configure i2c pins: sda */
|
||||
/* configure i2c pins: sda */
|
||||
gpio_initstructure.gpio_pins = I2Cx_SDA_PIN;
|
||||
gpio_init(I2Cx_SDA_GPIO_PORT, &gpio_initstructure);
|
||||
|
||||
/* configure and enable i2c dma channel interrupt */
|
||||
|
||||
/* configure and enable i2c dma channel interrupt */
|
||||
nvic_irq_enable(I2Cx_DMA_TX_IRQn, 0, 0);
|
||||
nvic_irq_enable(I2Cx_DMA_RX_IRQn, 0, 0);
|
||||
|
||||
/* configure and enable i2c interrupt */
|
||||
nvic_irq_enable(I2Cx_DMA_RX_IRQn, 0, 0);
|
||||
|
||||
/* configure and enable i2c interrupt */
|
||||
nvic_irq_enable(I2Cx_EVT_IRQn, 0, 0);
|
||||
nvic_irq_enable(I2Cx_ERR_IRQn, 0, 0);
|
||||
|
||||
nvic_irq_enable(I2Cx_ERR_IRQn, 0, 0);
|
||||
|
||||
/* i2c dma tx and rx channels configuration */
|
||||
/* enable the dma clock */
|
||||
crm_periph_clock_enable(I2Cx_DMA_CLK, TRUE);
|
||||
|
||||
|
||||
/* i2c dma channel configuration */
|
||||
dma_reset(hi2c->dma_tx_channel);
|
||||
dma_reset(hi2c->dma_rx_channel);
|
||||
|
||||
dma_reset(hi2c->dma_rx_channel);
|
||||
|
||||
hi2c->dma_tx_channel = I2Cx_DMA_TX_CHANNEL;
|
||||
hi2c->dma_rx_channel = I2Cx_DMA_RX_CHANNEL;
|
||||
|
||||
|
||||
dma_default_para_init(&hi2c->dma_init_struct);
|
||||
hi2c->dma_init_struct.peripheral_inc_enable = FALSE;
|
||||
hi2c->dma_init_struct.memory_inc_enable = TRUE;
|
||||
@@ -170,12 +170,12 @@ void i2c_lowlevel_init(i2c_handle_type* hi2c)
|
||||
hi2c->dma_init_struct.loop_mode_enable = FALSE;
|
||||
hi2c->dma_init_struct.priority = DMA_PRIORITY_LOW;
|
||||
hi2c->dma_init_struct.direction = DMA_DIR_MEMORY_TO_PERIPHERAL;
|
||||
|
||||
dma_init(hi2c->dma_tx_channel, &hi2c->dma_init_struct);
|
||||
dma_init(hi2c->dma_rx_channel, &hi2c->dma_init_struct);
|
||||
|
||||
|
||||
dma_init(hi2c->dma_tx_channel, &hi2c->dma_init_struct);
|
||||
dma_init(hi2c->dma_rx_channel, &hi2c->dma_init_struct);
|
||||
|
||||
i2c_init(hi2c->i2cx, I2C_FSMODE_DUTY_2_1, I2Cx_SPEED);
|
||||
|
||||
|
||||
i2c_own_address1_set(hi2c->i2cx, I2C_ADDRESS_MODE_7BIT, I2Cx_ADDRESS);
|
||||
}
|
||||
}
|
||||
@@ -193,85 +193,85 @@ int main(void)
|
||||
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
|
||||
|
||||
system_clock_config();
|
||||
|
||||
|
||||
at32_board_init();
|
||||
|
||||
hi2cx.i2cx = I2Cx_PORT;
|
||||
|
||||
|
||||
i2c_config(&hi2cx);
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
/* wait for key USER_BUTTON press before starting the communication */
|
||||
while(at32_button_press() != USER_BUTTON)
|
||||
{
|
||||
}
|
||||
|
||||
/* write data to memory device */
|
||||
|
||||
/* write data to memory device */
|
||||
if((i2c_status = i2c_memory_write(&hi2cx, I2Cx_ADDRESS, 0, tx_buf1, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
|
||||
delay_ms(5);
|
||||
|
||||
/* read data from memory device */
|
||||
|
||||
/* read data from memory device */
|
||||
if((i2c_status = i2c_memory_read(&hi2cx, I2Cx_ADDRESS, 0, rx_buf1, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* write data to memory device */
|
||||
/* write data to memory device */
|
||||
if((i2c_status = i2c_memory_write_int(&hi2cx, I2Cx_ADDRESS, 0, tx_buf2, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
delay_ms(5);
|
||||
|
||||
/* read data from memory device */
|
||||
if((i2c_status = i2c_memory_read_int(&hi2cx, I2Cx_ADDRESS, 0, rx_buf2, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
|
||||
delay_ms(5);
|
||||
|
||||
/* read data from memory device */
|
||||
if((i2c_status = i2c_memory_read_int(&hi2cx, I2Cx_ADDRESS, 0, rx_buf2, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
}
|
||||
|
||||
/* write data to memory device */
|
||||
/* write data to memory device */
|
||||
if((i2c_status = i2c_memory_write_dma(&hi2cx, I2Cx_ADDRESS, 0, tx_buf3, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
delay_ms(5);
|
||||
|
||||
/* read data from memory device */
|
||||
if((i2c_status = i2c_memory_read_dma(&hi2cx, I2Cx_ADDRESS, 0, rx_buf3, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
|
||||
delay_ms(5);
|
||||
|
||||
/* read data from memory device */
|
||||
if((i2c_status = i2c_memory_read_dma(&hi2cx, I2Cx_ADDRESS, 0, rx_buf3, BUF_SIZE, I2C_TIMEOUT)) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
/* wait for the communication to end */
|
||||
if(i2c_wait_end(&hi2cx, I2C_TIMEOUT) != I2C_OK)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
}
|
||||
|
||||
if((buffer_compare(tx_buf1, rx_buf1, BUF_SIZE) == 0) &&
|
||||
(buffer_compare(tx_buf2, rx_buf2, BUF_SIZE) == 0) &&
|
||||
@@ -283,14 +283,14 @@ int main(void)
|
||||
{
|
||||
error_handler(i2c_status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user