diff options
| author | Dawsyn Schraiber <[email protected]> | 2024-05-09 02:08:42 -0400 |
|---|---|---|
| committer | Dawsyn Schraiber <[email protected]> | 2024-05-09 02:08:42 -0400 |
| commit | 8fbd08fe29bbc2246a78b481b219c241f62ff420 (patch) | |
| tree | cc8f3f414a5560fa232677bc82d72348fd46660d | |
| parent | 93acde052369568beaefb0d99629d8797f5c191f (diff) | |
| download | active-drag-system-8fbd08fe29bbc2246a78b481b219c241f62ff420.tar.gz active-drag-system-8fbd08fe29bbc2246a78b481b219c241f62ff420.tar.bz2 active-drag-system-8fbd08fe29bbc2246a78b481b219c241f62ff420.zip | |
Remove Residual BeagleBone Black Related Files
| -rw-r--r-- | ads.service | 15 | ||||
| -rw-r--r-- | ads_config.service | 16 | ||||
| -rw-r--r-- | src/pru/AM335x_PRU.cmd | 86 | ||||
| -rw-r--r-- | src/pru/intc_map.h | 81 | ||||
| -rw-r--r-- | src/pru/pru_pwm.c | 102 | ||||
| -rw-r--r-- | src/pru/pwm_test.c | 82 | ||||
| -rw-r--r-- | src/pru/resource_table_empty.h | 38 | ||||
| -rw-r--r-- | test_launch.c | 239 | ||||
| -rw-r--r-- | test_launch.sh | 4 |
9 files changed, 0 insertions, 663 deletions
diff --git a/ads.service b/ads.service deleted file mode 100644 index 8f05a77..0000000 --- a/ads.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=ADS -StartLimitIntervalSec=30 -StartLimitBurst=3 -After=generic-board-startup.service - -[Service] -Type=simple -User=root -Restart=on-failure -RestartSec=30 -ExecStart=/usr/sbin/test_launch - -[Install] -WantedBy=multi-user.target diff --git a/ads_config.service b/ads_config.service deleted file mode 100644 index 36d16f1..0000000 --- a/ads_config.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=ADS Config -StartLimitIntervalSec=30 -StartLimitBurst=3 -After=generic-board-startup.service - -[Service] -Type=simple -User=root -Group=root -Restart=on-failure -RestartSec=30 -ExecStart=/usr/sbin/test_launch.sh - -[Install] -WantedBy=multi-user.target diff --git a/src/pru/AM335x_PRU.cmd b/src/pru/AM335x_PRU.cmd deleted file mode 100644 index b62f044..0000000 --- a/src/pru/AM335x_PRU.cmd +++ /dev/null @@ -1,86 +0,0 @@ -/****************************************************************************/ -/* AM335x_PRU.cmd */ -/* Copyright (c) 2015 Texas Instruments Incorporated */ -/* */ -/* Description: This file is a linker command file that can be used for */ -/* linking PRU programs built with the C compiler and */ -/* the resulting .out file on an AM335x device. */ -/****************************************************************************/ - --cr /* Link using C conventions */ - -/* Specify the System Memory Map */ -MEMORY -{ - PAGE 0: - PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ - - PAGE 1: - - /* RAM */ - - PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ - PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ - - PAGE 2: - PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ - - DDR : org = 0x80000000 len = 0x00000100 CREGISTER=31 - L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 - - - /* Peripherals */ - - PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 - PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 - PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 - PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 - PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 - - DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 - DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 - DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 - PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 - PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 - PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 - GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 - I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 - I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 - MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 - MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 - MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 - MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 - MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 - SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 - TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 - UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 - UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 - - RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 - RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 - RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 - RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 - -} - -/* Specify the sections allocation into memory */ -SECTIONS { - /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading - an ELF file, but useful when loading a binary */ - .text:_c_int00* > 0x0, PAGE 0 - - .text > PRU_IMEM, PAGE 0 - .stack > PRU_DMEM_0_1, PAGE 1 - .bss > PRU_DMEM_0_1, PAGE 1 - .cio > PRU_DMEM_0_1, PAGE 1 - .data > PRU_DMEM_0_1, PAGE 1 - .switch > PRU_DMEM_0_1, PAGE 1 - .sysmem > PRU_DMEM_0_1, PAGE 1 - .cinit > PRU_DMEM_0_1, PAGE 1 - .rodata > PRU_DMEM_0_1, PAGE 1 - .rofardata > PRU_DMEM_0_1, PAGE 1 - .farbss > PRU_DMEM_0_1, PAGE 1 - .fardata > PRU_DMEM_0_1, PAGE 1 - - .resource_table > PRU_DMEM_0_1, PAGE 1 -} diff --git a/src/pru/intc_map.h b/src/pru/intc_map.h deleted file mode 100644 index eebf27b..0000000 --- a/src/pru/intc_map.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com/ - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - * * Neither the name of Texas Instruments Incorporated nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _INTC_MAP_0_H_ -#define _INTC_MAP_0_H_ - -/* - * ======== PRU INTC Map ======== - * - * Define the INTC mapping for interrupts going to the ICSS / ICSSG: - * ICSS Host interrupts 0, 1 - * ICSSG Host interrupts 0, 1, 10-19 - * - * Note that INTC interrupts going to the ARM Linux host should not be defined - * in this file (ICSS/ICSSG Host interrupts 2-9). - * - * The INTC configuration for interrupts going to the ARM host should be defined - * in the device tree node of the client driver, "interrupts" property. - * See Documentation/devicetree/bindings/interrupt-controller/ti,pruss-intc.yaml - * entry #interrupt-cells for more. - * - * For example, on ICSSG: - * - * &client_driver0 { - * interrupt-parent = <&icssg0_intc>; - * interrupts = <21 2 2>, <22 3 3>; - * interrupt-names = "interrupt_name1", "interrupt_name2"; - * }; - * - */ - -#include <stddef.h> -#include <rsc_types.h> - -/* - * .pru_irq_map is used by the RemoteProc driver during initialization. However, - * the map is NOT used by the PRU firmware. That means DATA_SECTION and RETAIN - * are required to prevent the PRU compiler from optimizing out .pru_irq_map. - */ -#pragma DATA_SECTION(my_irq_rsc, ".pru_irq_map") -#pragma RETAIN(my_irq_rsc) - -struct pru_irq_rsc my_irq_rsc = { - 0, /* type = 0 */ - 1, /* number of system events being mapped */ - { - {7, 1, 1}, /* {sysevt, channel, host interrupt} */ - }, -}; - -#endif /* _INTC_MAP_0_H_ */ diff --git a/src/pru/pru_pwm.c b/src/pru/pru_pwm.c deleted file mode 100644 index 796040b..0000000 --- a/src/pru/pru_pwm.c +++ /dev/null @@ -1,102 +0,0 @@ -#include <stdint.h> -#include <pru_cfg.h> -#include <pru_intc.h> -#include <pru_iep.h> -#include "intc_map.h" -#include "resource_table_empty.h" - -#define CYCLES_PER_SECOND 200000000 -#define CYCLES_PER_PERIOD (CYCLES_PER_SECOND / 800) -#define DEFAULT_DUTY_CYCLE 0 -#define P8_12 (1 << 14) -#define P8_12_n ~(1 << 14) -#define PRU0_DRAM 0x00000 // Offset to DRAM -#define PRU_TIMER_PASSCODE 0x31138423 -#define BURN_TIME 2 // seconds for motor burn - -volatile uint32_t *pru0_dram = (uint32_t *) (PRU0_DRAM + 0x200); - - -volatile register uint32_t __R30; -volatile register uint32_t __R31; - - -void main(void) { - uint32_t duty_cycle = DEFAULT_DUTY_CYCLE; - uint32_t off_cycles = ((100 - duty_cycle) * CYCLES_PER_PERIOD / 100); - uint32_t on_cycles = ((100 - (100 - duty_cycle)) * CYCLES_PER_PERIOD / 100); - uint32_t off_count = off_cycles; - uint32_t on_count = on_cycles; - *pru0_dram = duty_cycle; - - /* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */ - CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; - - while (1) { - if (pru0_dram[1] == PRU_TIMER_PASSCODE) { - /* Disable counter */ - CT_IEP.TMR_GLB_CFG_bit.CNT_EN = 0; - - /* Reset Count register */ - CT_IEP.TMR_CNT = 0x0; - - /* Clear overflow status register */ - CT_IEP.TMR_GLB_STS_bit.CNT_OVF = 0x1; - - /* Set compare value */ - CT_IEP.TMR_CMP0 = (BURN_TIME * CYCLES_PER_SECOND); // 10 seconds @ 200MHz - - /* Clear compare status */ - CT_IEP.TMR_CMP_STS_bit.CMP_HIT = 0xFF; - - /* Disable compensation */ - CT_IEP.TMR_COMPEN_bit.COMPEN_CNT = 0x0; - - /* Enable CMP0 and reset on event */ - CT_IEP.TMR_CMP_CFG_bit.CMP0_RST_CNT_EN = 0x1; - CT_IEP.TMR_CMP_CFG_bit.CMP_EN = 0x1; - - /* Clear the status of all interrupts */ - CT_INTC.SECR0 = 0xFFFFFFFF; - CT_INTC.SECR1 = 0xFFFFFFFF; - - /* Enable counter */ - CT_IEP.TMR_GLB_CFG = 0x11; - break; - } - } - - /* Poll until R31.31 is set */ - do { - while ((__R31 & 0x80000000) == 0) { - } - /* Verify that the IEP is the source of the interrupt */ - } while ((CT_INTC.SECR0 & (1 << 7)) == 0); - - /* Disable counter */ - CT_IEP.TMR_GLB_CFG_bit.CNT_EN = 0x0; - - /* Disable Compare0 */ - CT_IEP.TMR_CMP_CFG = 0x0; - - /* Clear Compare status */ - CT_IEP.TMR_CMP_STS = 0xFF; - - /* Clear the status of the interrupt */ - CT_INTC.SECR0 = (1 << 7); - - while (1) { - if (on_count) { - __R30 |= P8_12; // Set the GPIO pin to 1 - on_count--; - __delay_cycles(3); - } else if (off_count) { - __R30 &= P8_12_n; // Clear the GPIO pin - off_count--; - } else { - duty_cycle = *pru0_dram; - off_count = ((100 - duty_cycle) * CYCLES_PER_PERIOD / 100); - on_count = ((100 - (100 - duty_cycle)) * CYCLES_PER_PERIOD / 100); - } - } -} diff --git a/src/pru/pwm_test.c b/src/pru/pwm_test.c deleted file mode 100644 index 9c19314..0000000 --- a/src/pru/pwm_test.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * pwm tester - * The on cycle and off cycles are stored in each PRU's Data memory - * - */ - -#include <stdio.h> -#include <stdint.h> -#include <fcntl.h> -#include <sys/mman.h> - -#define PRU_ADDR 0x4A300000 // Start of PRU memory Page 184 am335x TRM -#define PRU_LEN 0x80000 // Length of PRU memory -#define PRU0_DRAM 0x00000 // Offset to DRAM -#define PRU1_DRAM 0x02000 -#define PRU_SHAREDMEM 0x10000 // Offset to shared memory - -#define CYCLES_PER_SECOND 200000000 -#define CYCLES_PER_PERIOD (CYCLES_PER_SECOND / 800) -#define PRU_TIMER_PASSCODE 0x31138423 - -uint32_t *pru0DRAM_32int_ptr; // Points to the start of local DRAM -uint32_t *pru1DRAM_32int_ptr; // Points to the start of local DRAM -uint32_t *prusharedMem_32int_ptr; // Points to the start of the shared memory - -/******************************************************************************* -* int start_pwm_count(int ch, int countOn, int countOff) -* -* Starts a pwm pulse on for countOn and off for countOff to a single channel (ch) -*******************************************************************************/ -int start_pwm_count(uint32_t duty_cycle) { - uint32_t *pruDRAM_32int_ptr = pru0DRAM_32int_ptr; - uint32_t old_duty_cycle = pruDRAM_32int_ptr[0]; - uint32_t old_count_on = (100 - (100 - old_duty_cycle)) * CYCLES_PER_PERIOD / 100; - uint32_t old_count_off = (100 - old_duty_cycle) * CYCLES_PER_PERIOD / 100; - uint32_t new_count_on = (100 - (100 - duty_cycle)) * CYCLES_PER_PERIOD / 100; - uint32_t new_count_off = (100 - duty_cycle) * CYCLES_PER_PERIOD / 100; - - printf("old:\n\tcountOn: %d, countOff: %d, count: %d\nnew:\n\tcountOn: %d, countOff: %d, count: %d\n", old_count_on, old_count_off, old_count_off + old_count_on, new_count_on, new_count_off, new_count_off + new_count_on); - // write to PRU shared memory - pruDRAM_32int_ptr[1] = PRU_TIMER_PASSCODE; - pruDRAM_32int_ptr[0] = duty_cycle; // On time - return 0; -} - -int main(int argc, char *argv[]) -{ - uint32_t *pru; // Points to start of PRU memory. - int fd; - printf("Servo tester\n"); - - fd = open ("/dev/mem", O_RDWR | O_SYNC); - if (fd == -1) { - printf ("ERROR: could not open /dev/mem.\n\n"); - return 1; - } - pru = mmap (0, PRU_LEN, PROT_READ | PROT_WRITE, MAP_SHARED, fd, PRU_ADDR); - if (pru == MAP_FAILED) { - printf ("ERROR: could not map memory.\n\n"); - return 1; - } - close(fd); - printf ("Using /dev/mem.\n"); - - pru0DRAM_32int_ptr = pru + PRU0_DRAM/4 + 0x200/4; // Points to 0x200 of PRU0 memory - pru1DRAM_32int_ptr = pru + PRU1_DRAM/4 + 0x200/4; // Points to 0x200 of PRU1 memory - prusharedMem_32int_ptr = pru + PRU_SHAREDMEM/4; // Points to start of shared memory - - uint32_t desired_duty_cycle = 0; - while (1) { - printf("Enter a duty cycle: "); - scanf("%d", &desired_duty_cycle); - start_pwm_count(desired_duty_cycle); - } - - if(munmap(pru, PRU_LEN)) { - printf("munmap failed\n"); - } else { - printf("munmap succeeded\n"); - } -} diff --git a/src/pru/resource_table_empty.h b/src/pru/resource_table_empty.h deleted file mode 100644 index 8e7743e..0000000 --- a/src/pru/resource_table_empty.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * ======== resource_table_empty.h ======== - * - * Define the resource table entries for all PRU cores. This will be - * incorporated into corresponding base images, and used by the remoteproc - * on the host-side to allocated/reserve resources. Note the remoteproc - * driver requires that all PRU firmware be built with a resource table. - * - * This file contains an empty resource table. It can be used either as: - * - * 1) A template, or - * 2) As-is if a PRU application does not need to configure PRU_INTC - * or interact with the rpmsg driver - * - */ - -#ifndef _RSC_TABLE_PRU_H_ -#define _RSC_TABLE_PRU_H_ - -#include <stddef.h> -#include <rsc_types.h> - -struct my_resource_table { - struct resource_table base; - - uint32_t offset[1]; /* Should match 'num' in actual definition */ -}; - -#pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") -#pragma RETAIN(pru_remoteproc_ResourceTable) -struct my_resource_table pru_remoteproc_ResourceTable = { - 1, /* we're the first version that implements this */ - 0, /* number of entries in the table */ - 0, 0, /* reserved, must be zero */ - 0, /* offset[0] */ -}; - -#endif /* _RSC_TABLE_PRU_H_ */ diff --git a/test_launch.c b/test_launch.c deleted file mode 100644 index 2086269..0000000 --- a/test_launch.c +++ /dev/null @@ -1,239 +0,0 @@ -// Distributed with a free-will license. -// Use it any way you want, profit or free, provided it fits in the licenses of its associated works. -// MPL3115A2 -// This code is designed to work with the MPL3115A2_I2CS I2C Mini Module available from ControlEverything.com. -// https://www.controleverything.com/products - -#include <stdio.h> -#include <stdlib.h> -#include <linux/i2c-dev.h> -#include <unistd.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <time.h> - -#include <stdint.h> -#include <sys/mman.h> - -#define BILLION 1000000000L; - -#define PRU_ADDR 0x4A300000 // Start of PRU memory Page 184 am335x TRM -#define PRU_LEN 0x80000 // Length of PRU memory -#define PRU0_DRAM 0x00000 // Offset to DRAM -#define PRU1_DRAM 0x02000 -#define PRU_SHAREDMEM 0x10000 // Offset to shared memory - -#define CYCLES_PER_SECOND 200000000 -#define CYCLES_PER_PERIOD (CYCLES_PER_SECOND / 800) -#define PRU_TIMER_PASSCODE 0x31138423 - -volatile uint32_t *pru0DRAM_32int_ptr; // Points to the start of local DRAM -volatile uint32_t *pru1DRAM_32int_ptr; // Points to the start of local DRAM -volatile uint32_t *prusharedMem_32int_ptr; // Points to the start of the shared memory - -typedef enum { - PAD, - MOTOR_BURN, - COAST, - APOGEE, - RECOVERY, - END -} rocket_state; - -typedef enum { - RETRACT, - EXTEND -} ads_state; - -int start_pwm_count(uint32_t duty_cycle) { - // write to PRU shared memory - pru0DRAM_32int_ptr[0] = duty_cycle; // On time - return 0; -} - -void update_state(rocket_state* state, int base_altitude, int current_alt, int prev_alt, double time_delta) { - double velocity = ((current_alt - prev_alt) / time_delta); - static double motor_burn_time = 0.0f; - static double recovery_time = 0.0f; - switch (*state) { - case PAD: - if (velocity >= 50.0f) { - *state = MOTOR_BURN; - pru0DRAM_32int_ptr[1] = PRU_TIMER_PASSCODE; - } - break; - case MOTOR_BURN: - if (motor_burn_time >= 1.8f) { - *state = COAST; - break; - } - motor_burn_time += time_delta; - break; - case COAST: - if (velocity <= -50.0f) { - *state = APOGEE; - } - break; - case APOGEE: - *state = RECOVERY; - break; - case RECOVERY: - if (recovery_time >= 30.0f) { - *state = END; - break; - } - recovery_time += time_delta; - break; - } -} - -void update_ads(ads_state state) { - switch (state) { - case RETRACT: - start_pwm_count(15); - break; - case EXTEND: - start_pwm_count(3); - break; - } -} - -void main() { - int base_altitude = -1; - int curr_altitude = 0; - int prev_altitude = 0; - rocket_state r_state = PAD; - struct timespec start, current, previous; - double time_delta; - - system("echo 'stop' > /sys/class/remoteproc/remoteproc1/state"); - system("cp -r /home/debian/bbb_pru_test_act/pru_pwm /lib/firmware/am335x-pru0-fw"); - system("echo 'start' > /sys/class/remoteproc/remoteproc1/state"); - - // Create I2C bus - int file; - char *bus = "/dev/i2c-2"; - if((file = open(bus, O_RDWR)) < 0) - { - printf("Failed to open the bus. \n"); - exit(1); - } - // Get I2C device, TSL2561 I2C address is 0x60(96) - ioctl(file, I2C_SLAVE, 0x60); - - // Select control register(0x26) - // Active mode, OSR = 128, altimeter mode(0xB9) - char config[2] = {0}; - config[0] = 0x26; - config[1] = 0xB9; - write(file, config, 2); - // Select data configuration register(0x13) - // Data ready event enabled for altitude, pressure, temperature(0x07) - config[0] = 0x13; - config[1] = 0x07; - write(file, config, 2); - // Select control register(0x26) - // Active mode, OSR = 128, altimeter mode(0xB9) - config[0] = 0x26; - config[1] = 0xB9; - write(file, config, 2); - sleep(1); - -////////////////////////// SERVO SHIT - uint32_t *pru; // Points to start of PRU memory. - int fd; - printf("Servo tester\n"); - - fd = open ("/dev/mem", O_RDWR | O_SYNC); - if (fd == -1) { - printf ("ERROR: could not open /dev/mem.\n\n"); - } - pru = mmap (0, PRU_LEN, PROT_READ | PROT_WRITE, MAP_SHARED, fd, PRU_ADDR); - if (pru == MAP_FAILED) { - printf ("ERROR: could not map memory.\n\n"); - } - close(fd); - pru0DRAM_32int_ptr = pru + PRU0_DRAM/4 + 0x200/4; // Points to 0x200 of PRU0 memory - pru1DRAM_32int_ptr = pru + PRU1_DRAM/4 + 0x200/4; // Points to 0x200 of PRU1 memory - prusharedMem_32int_ptr = pru + PRU_SHAREDMEM/4; // Points to start of shared memory - -//////////////////////////////// - while (base_altitude == -1) { - char reg[1] = {0x00}; - write(file, reg, 1); - char data[4] = {0}; - if(read(file, data, 4) == 4) { - base_altitude = (((data[1] << 16) | (data[2] << 8) | (data[3] & 0xF0)) >> 8); - curr_altitude = base_altitude; - prev_altitude = base_altitude; - break; - } - } - clock_gettime( CLOCK_REALTIME, &start); - clock_gettime( CLOCK_REALTIME, ¤t); - FILE* log = fopen("ads_log", "a"); - int pad_logged = 0; - while (1) { - // Read 6 bytes of data from address 0x00(00) - // status, tHeight msb1, tHeight msb, tHeight lsb, temp msb, temp lsb - char reg[1] = {0x00}; - write(file, reg, 1); - char data[4] = {0}; - if(read(file, data, 4) != 4) { - printf("Error : Input/Output error \n"); - continue; - } - - // Convert the data - prev_altitude = curr_altitude; - curr_altitude = (((data[1] << 16) | (data[2] << 8) | (data[3] & 0xF0)) >> 8); - previous = current; - clock_gettime( CLOCK_REALTIME, ¤t); - time_delta = ( current.tv_sec - previous.tv_sec ) + ((double) ( current.tv_nsec - previous.tv_nsec )) / BILLION; - - update_state(&r_state, base_altitude, curr_altitude, prev_altitude, time_delta); - double time_since_start = ( current.tv_sec - start.tv_sec ) + ((double) ( current.tv_nsec - start.tv_nsec )) / BILLION; - - switch (r_state) { - case PAD: - update_ads(RETRACT); - if (pad_logged) { - fprintf(log, "%.2f - PAD: ", time_since_start); - pad_logged = 1; - } - break; - case MOTOR_BURN: - update_ads(RETRACT); - fprintf(log, "%.2f - MOTOR_BURN: ", time_since_start); - break; - case COAST: - update_ads(EXTEND); - fprintf(log, "%.2f - COAST: ", time_since_start); - break; - case APOGEE: - update_ads(RETRACT); - fprintf(log, "%.2f - APOGEE: ", time_since_start); - break; - case RECOVERY: - update_ads(RETRACT); - fprintf(log, "%.2f - RECOVERY: ", time_since_start); - break; - case END: - break; - } - - fprintf(log, "Altitude: %d m Velocity: %.2f Time Delta: %.2f\n", curr_altitude, ((curr_altitude - prev_altitude) / time_delta), time_delta); - fflush(log); - usleep(250000); - } - - close(file); - fclose(log); - if(munmap(pru, PRU_LEN)) { - printf("munmap failed\n"); - } else { - printf("munmap succeeded\n"); - } - exit(0); -} - diff --git a/test_launch.sh b/test_launch.sh deleted file mode 100644 index 2e5bd4c..0000000 --- a/test_launch.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -config-pin p8.12 pruout -echo 'start' > /sys/class/remoteproc/remoteproc1/state |
