Software adaption

Example devicetree

The following implements Devicetree nodes are implementing the P140 functionallity for the tca6408 and pca9685 component.

The following devicetree snippet is only an example. The IĀ²C controller depends on your hardware setup.

/*
 * Copyright (c) 2023, AUVIDEA. All rights reserved.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or any
 * later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 */

/ {
    i2c@c240000 {
        p140_control_tca6408: p140_tca6408@21 {
            compatible = "ti,tca6408";
            reg = <0x21>;
	    vcc-supply = <&battery_reg>;
            gpio-controller;
            #gpio-cells = <2>;
            gpio-line-names = "", "", "RESET_POE", "/INT", "EN_PCA", "PGOOD_48V", "EN_48V", ""; 
            
            // this is required for the PCA to be enabled
            en_pca { 
		gpio-hog;
		gpios = <4 0>;
		output-low;
		line-name = "EN_PCA";
	    };
        };

        p140_control_pca9685: p140_pca9685@54 {
            compatible = "nxp,pca9685-pwm";
            #pwm-cells = <2>;
            reg = <0x54>;
	    gpio-line-names = "", "LED4_G", "LED4_R", "LED4_B", "LED3_G", "LED3_R", "LED3_B",
                                "LED2_G", "LED2_R", "LED2_B", "LED1_G", "LED1_R", "LED1_B",
                                "LED0_G", "LED0_R", "LED0_B", "CTL_ALL";
        };
    };
};

Bash Script

Ethernet Switch (KSZ9896C)

This code is meant to initializing the board correctly. Because the settings will reset every time you reboot the board, it is necessary to run this script on every start of the board. The script can take some time to show some response, so wait some time and set the script run until it prints ā€œDone!ā€ in the console.

GPIO Control

This script is made to control specific GPIO Ports which are connected to preset outputs/inputs to check there status or set them to a specific state

All action

OptionSuboption 1Description

-h (--help)

Shows help menu

-en48V (--enable48V)

0|1

Enable/Disable 48V

-enPCA (--enablePCA)

0|1

Enable/Disable PCA

-rPoE (--resetPoE)

Reset PoE

-c48V (--check48V)

Check 48V Status

Example

ActionCommand

Show help menu and enable 48V

./gpio_control.sh -h -en48V 1

Disable PCA and check 48V

./gpio_control.sh -enPCA 0 -c48V

PWM Controller (PCA9685)

This script is made to control the PWM Controller, to turn on/off specific/all LEDs on the board

All action

OptionValue 1Value 2Description

-h (--help)

Shows help menu

-led0

red|blue|green

on|off

Turn on/off LED0 color

-led1

red|blue|green

on|off

Turn on/off LED1 color

-led2

red|blue|green

on|off

Turn on/off LED2 color

-led3

red|blue|green

on|off

Turn on/off LED3 color

-led4

red|blue|green

on|off

Turn on/off LED4 color

-o (--off)

Turn all LEDs off

Example

ActionCommand

Shows help menu and turns color red on led0 on

./PWM_LED_controller.sh -h -led0 red on

Turns color blue on led1 on and turns color green on led 2 off

./PWM_LED_controller.sh -led1 blue on -led2 green off

PoE Power Controller (TPS23861)

This script is made to control the PoE Controller on the board. It is possible to set specific ports to on, off or change there mode or turn them off completely

All action

argumentDescription

-h (--help)

Shows help menu

-b (--bus)

Set bus

-a (-address)

Set chip address

-s (--status)

Checks status

-on[PORT|a]

Turn all or specific port(s) on

-off[PORT|a]

Turn all or specific port(s) off

-dis[PORT|a]

Disable all or specific port(s)

-man[PORT|a]

Set all or specific port(s) to manual mode

-sauto[PORT|a]

Set all or specific port(s) to semi auto mode

-auto[PORT|a]

Set all or specific port(s) to auto mode

Example

ActionCommand

Set all ports to manual mode and turn on all ports and checks status

./TPS23861_PoE.sh -mana -ona -s

Set bus to 1, set port 3 to manual, set port 2 to auto, turn on port 3 and check status

./TPS23861_PoE.sh -b 1 -man3 -auto2 -on3 -s

Last updated