Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "uart.h"
- #include "adc.h"
- #define F_CPU 14745600UL
- #include <avr/io.h>
- #include <util/delay.h>
- #include <string.h>
- #include <stdio.h>
- #define BUFF_SIZE 300
- #define VT_HI 140
- #define VT_LO 110
- uint8_t buff_0[BUFF_SIZE];
- uint8_t buff_1[BUFF_SIZE];
- void send_buffer(uint8_t *buffer){
- int i;
- for (i = 0; i<BUFF_SIZE;i++){
- uart_send_byte(buffer[i]);
- }
- }
- void UART_SendOscData(uint8_t* buff_0, uint8_t* buff_1, uint16_t buff_size){
- uint8_t low = buff_size & 0xff;
- uint8_t high = (buff_size >> 8);
- uart_send_byte(0xA0);
- uart_send_byte(0xA3);
- uart_send_byte(0xB0);
- uart_send_byte(0xB3);
- uart_send_byte(high);
- uart_send_byte(low);
- send_buffer(buff_0);
- send_buffer(buff_1);
- uart_send_byte(0x00);
- uart_send_byte(0x00);
- }
- void negative_trigger(int channel){
- int i = 0;
- //uint8_t channel_0_value = read_adc(0);
- while ( read_adc(channel) < VT_HI){
- continue;
- }
- while ( read_adc(channel) > VT_LO){
- continue;
- }
- while (i < BUFF_SIZE)
- {
- buff_0[i] = read_adc(0);
- buff_1[i] = read_adc(1);
- i++;
- }
- UART_SendOscData(buff_0,buff_1,BUFF_SIZE);
- }
- void pozitive_trigger(int channel){
- int i = 0;
- //uint8_t channel_0_value = read_adc(0);
- while ( read_adc(channel) > VT_LO){
- continue;
- }
- while ( read_adc(channel) < VT_HI){
- continue;
- }
- while (i < BUFF_SIZE)
- {
- buff_0[i] = read_adc(0);
- buff_1[i] = read_adc(1);
- i++;
- }
- UART_SendOscData(buff_0,buff_1,BUFF_SIZE);
- }
- int main()
- {
- uart_init();
- //char ch = 'a';
- //char str[50];
- //int i = 0;
- //uint32_t val;
- adc_init();
- //uint32_t converted_adch;
- while (1)
- {
- negative_trigger(1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement