지금 하고있는 졸작 프로젝트에 맞춘것임. 용도불명인 내용이 많을 수 있음.

Bluetooth.zip


헤더부터 살펴보면

1.

#define GPIO_Bluetooth  GPIOA

#define GPIO_Bluetooth_Rx_Pin GPIO_Pin_3

#define GPIO_Bluetooth_Tx_Pin GPIO_Pin_2


PortA의 2번과 3번핀을 사용하였다. Cortex회로도를 보면 알겠지만 각각 USART2의 TX와 RX이다.


//-----------------Buffer Size-------------------------

#define U2_BUFFER_SIZE 100

//----------------------------------------------------

void Blutooth_RCC_Configuration(void);

void Blutooth_NVIC_Configuration(void);

void Blutooth_GPIO_Configuration(void);

void Blutooth_UART2_Configuration(void);

void Blutooth_Setting(void);    //위의 RCC~UART2까지를 함수하나로 부르려고 한것이다.


//void USART2_IRQHandler(void);

void PutChar_blue(uint8_t c);        //블루투스에 한문자를 전송

void PutString_blue(uint8_t *s);    //문자단위로 문자열을 전송

void Send_Command_test(uint16_t Command);    //전송테스트용. 패킷을 위루어 전송

void Transmit_data(uint8_t *s);    //실질적으로 문자단위로 전송하는 부분

//********************Status Test**************************

bool input_check(void);

bool Connection_Check(void);

//********************Send Speed***************************

void Send_EncoderState(uint16_t Speed);



그냥보면은 용도를 알 수 없는 함수가 꽤 있다. 실제 내가 복습하려고 만들어 놓은 내용이니..

몇곳만 짚어 적어둔다.


1.NVIC : 실제로는 부르지 않게 해놓았다. 이걸 부르면 어쩐지 시리얼 통신부분에서 진행하질 못한다. 딱히 할 필요성은 못느낌

2.USART_ITConfig     수신에 대한 인터럽트를 가능하게 해준단다.

3.USART_SendData(USART2,c);    데이터 보낼 때

4.

intData=0;

  Command_Data[4]=(0x00ff)&intData;

  Command_Data[3]=((0xff00)&intData)>>8;


intData에 저장한 값을 PC가 받게 하려고 할 때, 다음과 같이 넣어서 보내면 의도한 값을 컴퓨터에서 받을 수 있다.

'중도연재종료 > CORTEX M3' 카테고리의 다른 글

엔코더값 읽기.  (0) 2013.09.02
Bluetooth 사용기(팁 포함)  (0) 2013.09.02
스텝모터 돌리기  (0) 2013.09.02
진행방식을 바꾼다...  (0) 2013.06.23
함수표 참조 설명  (0) 2013.06.23
Posted by 십자성군