#include "debug.h"
#include "string.h"
#include <stdlib.h>
/* DATA ADDRESS Length Definition */
#define Address_8bit 0
#define Address_16bit 1
/* DATA ADDRESS Length Selection */
#define Address_Lenth Address_8bit
//#define Address_Lenth Address_16bit
#define X_LED (6) //横向LED数量
#define Y_LED (15) //纵向LED数量
#define SCALINGS (15) //scaling数量
#define DATA_MAX 60//(X_LED*Y_LED)
#define DATA_SIZE sizeof(data[DATA_MAX])
#define DEVICE1 0
#define DEVICE2 1
typedef struct{
u8 B;
u8 G;
u8 R;
}RGB_LED;
RGB_LED data[DATA_MAX];
/*******************************************************************************
* Function Name : IS31F3729_I2c_Init
* Description : Initializes the IIC peripheral.
* Input : None
* Return : None
********************************************************************************/
void IS31F3729_I2c_Init( u32 bound, u16 address)
{
GPIO_InitTypeDef GPIO_InitStructure;
I2C_InitTypeDef I2C_InitTSturcture;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO, ENABLE );
GPIO_PinRemapConfig(GPIO_Remap_I2C1, ENABLE);
RCC_APB1PeriphClockCmd( RCC_APB1Periph_I2C1, ENABLE );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init( GPIOB, &GPIO_InitStructure );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init( GPIOB, &GPIO_InitStructure );
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init( GPIOB, &GPIO_InitStructure );
GPIO_SetBits(GPIOB, GPIO_Pin_6); //拉高使能脚
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init( GPIOC, &GPIO_InitStructure );
GPIO_ResetBits(GPIOC, GPIO_Pin_13);
I2C_InitTSturcture.I2C_ClockSpeed = bound;
I2C_InitTSturcture.I2C_Mode = I2C_Mode_I2C;
I2C_InitTSturcture.I2C_DutyCycle = I2C_DutyCycle_2;
I2C_InitTSturcture.I2C_OwnAddress1 = address;
I2C_InitTSturcture.I2C_Ack = I2C_Ack_Enable;
I2C_InitTSturcture.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
I2C_Init( I2