Skip to content

Commit

Permalink
Finishing The Driver [#1] [#2] [#3]
Browse files Browse the repository at this point in the history
  • Loading branch information
Hosam committed Oct 15, 2022
1 parent d6c89f4 commit 5e04ff0
Show file tree
Hide file tree
Showing 105 changed files with 4,854 additions and 1,648 deletions.
52 changes: 33 additions & 19 deletions Source/APP/main.c
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
/*
* AVR-COTS-Application.c
* main.c
*
* Created: 10/14/2022 1:09:46 PM
* Author : hosam
*/
* Created on: Sep 21, 2022
* Author: Dell
*/
#include "../lib/std_types.h"
#include "../lib/bit_map.h"

#include "main.h"
#include "../MCAL/DIO/DIO_int.h"
#include "../RTOS_STACK/TMU/RTOS_int.h"


int main(void)
#include "../HAL/LCD/LCD_int.h"
#include "../HAL/EEPROM/EEPROM_int.h"
#include <avr/delay.h>
void TASK_1()
{
DIO_vTogPinVal(PORTA_ID, PIN3_ID);
}
void TASK_2()
{
DIO_vTogPinVal(PORTA_ID, PIN4_ID);
}
void TASK_3()
{
Mcu_Init();

/* Replace with your application code */
DIO_vTogPinVal(PORTA_ID, PIN5_ID);
}
int main()
{
DIO_vSetPinDir(PORTA_ID, PIN3_ID, DIR_OUTPUT);
DIO_vSetPinDir(PORTA_ID, PIN4_ID, DIR_OUTPUT);
DIO_vSetPinDir(PORTA_ID, PIN5_ID, DIR_OUTPUT);

RTOS_vStartSchedular();
RTOS_vInit();
RTOS_vCreateTask(0, 1, TASK_1);
RTOS_vCreateTask(1, 2, TASK_2);
RTOS_vCreateTask(2, 3, TASK_3);
while (1)
{
u16 x = 0x0F; u08 *y;

DIO_WriteChannel(PORT_A, PIN0, HIGH);
if(!DIO_ReadChannel(PORT_C, PIN0)) DIO_ToggleChannel(PORT_A, PIN2);
for(int i= 0 ; i<1000 ; i++);
UART_ReceiveByte(y);
UART_TransmitByte(*y);

}
}

18 changes: 0 additions & 18 deletions Source/APP/main.h

This file was deleted.

130 changes: 130 additions & 0 deletions Source/APP/mainICU.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* main.c
*
* Created on: Aug 15, 2022
* Author: Dell
*/

#define F_CPU 8000000UL
#include "../LIB/std_types.h"
#include "../LIB/bit_map.h"

#include "../MCAL/DIO/DIO_int.h"
#include "../MCAL/TIMER/TIMER_int.h"
#include "../MCAL/TIMER/TIMER_reg.h"
#include "../MCAL/TIMER/TIMER_cfg.h"
#include "../MCAL/TIMER/TIMER_pri.h"

#include "../MCAL/EXI/EXI_int.h"
#include "../MCAL/GIE/GIE_int.h"

#include "../HAL/LED/LED_int.h"
#include "../HAL/SWITCHES/SWITCHES_int.h"
#include "../HAL/SSD/SSD_int.h"
#include "../HAL/LCD/LCD_int.h"
#include "../HAL/SERVO/SERVO_int.h"
#include <avr/delay.h>

volatile u32 G_u32Counts_Read1 = 0, G_u32Counts_Read2 = 0, G_u32Counts_Read3 = 0;
volatile u8 Flag = 0;
volatile u16 PeriodTime = 0, DutyCycle = 0, TimeOn = 0;
volatile u16 G_u16Cov = 0;
void ICU_HW();
void TIM1_OVF();

int mainICU()
{
/* INIT LCD */
LCD_vInit();
LCD_vDisplayString("Start");

/* Enable Global Interrupt */
GIE_vSetGlobalInterrupt();
/* SWT PWM to 25 Duty Cycle This Sets OCR0 to 64 */
TIMER_vPWMSignal(TIMER0, 35);
/* Init Timer 0 */
TIMER_vInit(TIMER0);
/* ******************************* */

/* Enanle ICU TIMER 1 */
TIMER_vsetCallBackFunctionIcuTIMER1(&ICU_HW);
TIMER_vsetCallBackFunctionOvfTIMER1(&TIM1_OVF);
TIMER_vCongfigureICU();
TIMER_vSetTriggeringICU(RISING);

while (1)
{
if (Flag == 1)
{
DutyCycle = (TimeOn * 1.0 / PeriodTime) * 100;
LCD_vSetPostion(ROW0, COLUMN0);
LCD_vDisplayString("TimePeriod:");
LCD_vDisplayNumInteger(PeriodTime);
LCD_vDisplayString("us");
LCD_vSetPostion(ROW1, COLUMN0);
LCD_vDisplayString("DutyCycle : ");
LCD_vDisplayNumInteger(DutyCycle);
LCD_vDisplayString("%");
Flag = 0;
}
else
{
// do nothing
}
}
return 0;
}
void ICU_HW(void)
{
static u8 counter = 0;
counter++;
if (counter == 2)
{
G_u32Counts_Read1 = TIMER_u16GetICU() + (G_u16Cov * 65536);
}
else if (counter == 3)
{
G_u32Counts_Read2 = TIMER_u16GetICU() + (G_u16Cov * 65536);
PeriodTime = G_u32Counts_Read2 - G_u32Counts_Read1;
/* SET TRTIGGER TO Falling EDGE */
TIMER_vSetTriggeringICU(FALLING);
}
else if (counter == 4)
{
G_u32Counts_Read3 = TIMER_u16GetICU() + (G_u16Cov * 65536);
TimeOn = G_u32Counts_Read3 - G_u32Counts_Read2;
TIMER_vDisableIntICU();
Flag = 1;
}
else
{
// DO Nothing
}
}
void TIM1_OVF()
{
G_u16Cov++;
}
/* SERVO */

/*
int main()
{
SERVO_vInit();
while (1)
{
SERVO_vMoveToInitialAngle();
_delay_ms(1000);
SERVO_vMoveToAngle(45);
_delay_ms(1000);
SERVO_vMoveToAngle(90);
_delay_ms(1000);
SERVO_vMoveToAngle(135);
_delay_ms(1000);
SERVO_vMoveToAngle(180);
_delay_ms(1000);
}
return 0;
}
*/
39 changes: 0 additions & 39 deletions Source/COMMON/Bit_Math.h

This file was deleted.

80 changes: 0 additions & 80 deletions Source/COMMON/Platform_Types.h

This file was deleted.

Loading

0 comments on commit 5e04ff0

Please sign in to comment.